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.dom.broker;
10 import static org.junit.Assert.assertFalse;
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;
16 import java.util.ArrayList;
17 import java.util.HashMap;
18 import java.util.List;
20 import org.junit.Test;
21 import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
22 import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException;
23 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
24 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
25 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
27 public class GlobalDOMRpcRoutingTableEntryTest extends TestUtils {
30 public void basicTest() throws Exception {
31 final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> rpcImplementations = new HashMap<>();
32 final List<DOMRpcImplementation> rpcImplementation = new ArrayList<>();
33 final RpcDefinition rpcDefinition = mock(RpcDefinition.class);
34 final YangInstanceIdentifier yangInstanceIdentifier = YangInstanceIdentifier.builder().build();
36 doReturn(SchemaPath.ROOT).when(rpcDefinition).getPath();
37 final GlobalDOMRpcRoutingTableEntry globalDOMRpcRoutingTableEntry = new GlobalDOMRpcRoutingTableEntry(
38 rpcDefinition, new HashMap<>());
39 rpcImplementation.add(getTestRpcImplementation());
40 rpcImplementations.put(yangInstanceIdentifier, rpcImplementation);
42 assertTrue(globalDOMRpcRoutingTableEntry.getSchemaPath().equals(SchemaPath.ROOT));
43 assertTrue(globalDOMRpcRoutingTableEntry.getImplementations().isEmpty());
44 assertFalse(globalDOMRpcRoutingTableEntry.newInstance(rpcImplementations).getImplementations().isEmpty());
45 assertTrue(globalDOMRpcRoutingTableEntry.newInstance(rpcImplementations).getImplementations().containsValue(
49 globalDOMRpcRoutingTableEntry.newInstance(rpcImplementations)
50 .invokeRpc(TEST_CONTAINER).checkedGet();
51 fail("Expected DOMRpcImplementationNotAvailableException");
52 } catch (DOMRpcImplementationNotAvailableException e) {
53 assertTrue(e.getMessage().contains(EXCEPTION_TEXT));