12344ba0605cf3f20c03f8f3b37cea1d31cd6c06
[mdsal.git] / binding / yang-binding / src / test / java / org / opendaylight / yangtools / yang / binding / util / 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.yangtools.yang.binding.util;
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 java.net.URI;
15 import java.util.Date;
16 import org.junit.BeforeClass;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.binding.RpcService;
19 import org.opendaylight.yangtools.yang.common.QName;
20 import org.opendaylight.yangtools.yang.common.QNameModule;
21
22 public class LocalNameRpcServiceInvokerTest {
23
24     private static RpcServiceInvoker rpcServiceInvoker;
25     private static final QNameModule Q_NAME_MODULE =
26             QNameModule.create(URI.create("testURI"), new Date(System.currentTimeMillis()));
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("test"), Object.class.getDeclaredMethod("hashCode")));
33
34         assertNotNull(rpcServiceInvoker);
35     }
36
37     @Test(expected = IllegalArgumentException.class)
38     public void qnameToKeyTest() throws Exception {
39         rpcServiceInvoker.invokeRpc(RPC_SERVICE, QName.create(Q_NAME_MODULE, "test"), null);
40     }
41
42     @Test(expected = IllegalArgumentException.class)
43     public void qnameToKeyWithNullTest() throws Exception {
44         rpcServiceInvoker.invokeRpc(RPC_SERVICE, QName.create("test"), null);
45     }
46 }