2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.dom.adapter.invoke;
10 import static org.junit.Assert.assertNotNull;
11 import static org.mockito.Mockito.mock;
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;
22 public class LocalNameRpcServiceInvokerTest {
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);
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")));
35 assertNotNull(rpcServiceInvoker);
38 @Test(expected = IllegalArgumentException.class)
39 public void qnameToKeyTest() throws Exception {
40 rpcServiceInvoker.invokeRpc(RPC_SERVICE, QName.create(Q_NAME_MODULE, "test"), null);
43 @Test(expected = IllegalArgumentException.class)
44 public void qnameToKeyWithNullTest() throws Exception {
45 rpcServiceInvoker.invokeRpc(RPC_SERVICE, QName.create("", "test"), null);