Bump to odlparent-9.0.0/yangtools-7.0.1-SNAPSHOT
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / test / java / org / opendaylight / mdsal / binding / dom / adapter / invoke / LocalNameRpcServiceInvokerTest.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.mockito.Mockito.mock;
12
13 import com.google.common.collect.ImmutableMap;
14 import org.junit.BeforeClass;
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 LocalNameRpcServiceInvokerTest {
23
24     private static RpcServiceInvoker rpcServiceInvoker;
25     private static final QNameModule Q_NAME_MODULE = QNameModule.create(XMLNamespace.of("testURI"),
26         Revision.of("2017-10-26"));
27     private static final RpcService RPC_SERVICE = mock(RpcService.class);
28
29     @BeforeClass
30     public static void setUp() throws Exception {
31         rpcServiceInvoker = LocalNameRpcServiceInvoker.instanceFor(
32                 Q_NAME_MODULE, ImmutableMap.of(QName.create(Q_NAME_MODULE, "test"),
33                     Object.class.getDeclaredMethod("hashCode")));
34
35         assertNotNull(rpcServiceInvoker);
36     }
37
38     @Test(expected = IllegalArgumentException.class)
39     public void qnameToKeyTest() throws Exception {
40         rpcServiceInvoker.invokeRpc(RPC_SERVICE, QName.create(Q_NAME_MODULE, "test"), null);
41     }
42
43     @Test(expected = IllegalArgumentException.class)
44     public void qnameToKeyWithNullTest() throws Exception {
45         rpcServiceInvoker.invokeRpc(RPC_SERVICE, QName.create("", "test"), null);
46     }
47 }