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