Deprecate RpcServiceInvoker.from(Class)
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / test / java / org / opendaylight / mdsal / binding / dom / adapter / invoke / RpcServiceInvokerTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.mdsal.binding.dom.adapter.invoke;
9
10 import static org.junit.Assert.assertNotNull;
11 import static org.junit.Assert.fail;
12
13 import com.google.common.collect.ImmutableMap;
14 import java.lang.reflect.Method;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.binding.RpcService;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.common.QNameModule;
19 import org.opendaylight.yangtools.yang.common.Revision;
20 import org.opendaylight.yangtools.yang.common.XMLNamespace;
21
22 public class RpcServiceInvokerTest {
23
24     @Test
25     public void fromTest() throws Exception {
26         final Method method = this.getClass().getDeclaredMethod("testMethod");
27         method.setAccessible(true);
28         assertNotNull(RpcServiceInvoker.from(ImmutableMap.of(
29             QName.create(QNameModule.create(XMLNamespace.of("testURI"), Revision.of("2017-10-26")),"test"), method,
30             QName.create(QNameModule.create(XMLNamespace.of("testURI2"), Revision.of("2017-10-26")),"test"), method)));
31         assertNotNull(RpcServiceInvoker.from(ImmutableMap.of(
32             QName.create(QNameModule.create(XMLNamespace.of("testURI"), Revision.of("2017-10-26")), "test"), method)));
33     }
34
35     @Deprecated(forRemoval = true)
36     @Test(expected = IllegalArgumentException.class)
37     public void fromWithExceptionTest() {
38         RpcServiceInvoker.from(RpcService.class);
39         fail("Expected IllegalArgumentException");
40     }
41
42     private void testMethod() {
43         // NOOP
44     }
45 }