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
9 package org.opendaylight.netconf.topology.singleton.impl.utils;
11 import static org.junit.Assert.assertEquals;
13 import org.junit.Test;
14 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
21 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
22 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
23 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
24 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
25 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27 public class NetconfTopologyUtilTest {
30 public void testCreateRemoteDeviceId() {
31 final Host host = new Host(new IpAddress(new Ipv4Address("127.0.0.1")));
32 final NetconfNode netconfNode = new NetconfNodeBuilder().setHost(host).setPort(new PortNumber(9999)).build();
33 final NodeId nodeId = new NodeId("testing-node");
34 final RemoteDeviceId id = NetconfTopologyUtils.createRemoteDeviceId(nodeId, netconfNode);
36 assertEquals("testing-node", id.getName());
37 assertEquals(host, id.getHost());
38 assertEquals(9999, id.getAddress().getPort());
42 public void testCreateActorPath() {
43 final String actorPath = NetconfTopologyUtils.createActorPath("member", "name");
44 assertEquals("member/user/name", actorPath);
48 public void testCreateListPath() {
49 final InstanceIdentifier<Node> listPath =
50 NetconfTopologyUtils.createTopologyNodeListPath(new NodeKey(new NodeId("nodeId")), "topologyId");
52 assertEquals("nodeId", listPath.firstKeyOf(Node.class).getNodeId().getValue());
53 assertEquals("topologyId", listPath.firstKeyOf(Topology.class).getTopologyId().getValue());
55 assertEquals("topologyId", NetconfTopologyUtils.createTopologyNodePath("topologyId")
56 .firstKeyOf(Topology.class).getTopologyId().getValue());