67194f9505a2667644bc4b09b8dfed681244c497
[mdsal.git] / dom / mdsal-dom-broker / src / test / java / org / opendaylight / mdsal / dom / broker / RoutedDOMRpcRoutingTableEntryTest.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.dom.broker;
9
10 import static org.junit.Assert.assertNotNull;
11 import static org.junit.Assert.assertTrue;
12 import static org.junit.Assert.fail;
13 import static org.mockito.Mockito.doReturn;
14 import static org.mockito.Mockito.mock;
15
16 import java.util.HashMap;
17 import org.junit.Test;
18 import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException;
19 import org.opendaylight.mdsal.dom.broker.util.TestModel;
20 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
21 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
22
23 public class RoutedDOMRpcRoutingTableEntryTest extends TestUtils {
24
25     @Test
26     public void basicTest() throws Exception {
27         final RpcDefinition rpcDefinition = mock(RpcDefinition.class);
28         doReturn(SchemaPath.ROOT).when(rpcDefinition).getPath();
29
30         final RoutedDOMRpcRoutingTableEntry routedDOMRpcRoutingTableEntry =
31                 new RoutedDOMRpcRoutingTableEntry(rpcDefinition, TestModel.TEST_PATH, new HashMap<>());
32         assertNotNull(routedDOMRpcRoutingTableEntry.newInstance(new HashMap<>()));
33
34         try {
35             routedDOMRpcRoutingTableEntry.invokeRpc(TEST_CHILD).checkedGet();
36             fail("Expected DOMRpcImplementationNotAvailableException");
37         } catch (final Exception e) {
38             assertTrue(e instanceof DOMRpcImplementationNotAvailableException);
39         }
40     }
41 }