190d821b784c4a0d3d0ca2016b02fc09efbfca4a
[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 java.util.concurrent.ExecutionException;
18 import java.util.concurrent.TimeoutException;
19 import org.junit.Test;
20 import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException;
21 import org.opendaylight.mdsal.dom.broker.util.TestModel;
22 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
23 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
24
25 public class RoutedDOMRpcRoutingTableEntryTest extends TestUtils {
26
27     @SuppressWarnings("checkstyle:IllegalCatch")
28     @Test
29     public void basicTest() throws InterruptedException, TimeoutException {
30         final RpcDefinition rpcDefinition = mock(RpcDefinition.class);
31         doReturn(SchemaPath.ROOT).when(rpcDefinition).getPath();
32
33         final RoutedDOMRpcRoutingTableEntry routedDOMRpcRoutingTableEntry =
34                 new RoutedDOMRpcRoutingTableEntry(rpcDefinition, TestModel.TEST_PATH, new HashMap<>());
35         assertNotNull(routedDOMRpcRoutingTableEntry.newInstance(new HashMap<>()));
36
37         try {
38             routedDOMRpcRoutingTableEntry.invokeRpc(TEST_CHILD).get();
39             fail("Expected DOMRpcImplementationNotAvailableException");
40         } catch (ExecutionException e) {
41             assertTrue(e.getCause() instanceof DOMRpcImplementationNotAvailableException);
42         }
43     }
44 }