Centralize NetconfNode/InetSocketAddress conversion
[netconf.git] / netconf / netconf-topology-singleton / src / test / java / org / opendaylight / netconf / topology / singleton / impl / utils / NetconfTopologyUtilTest.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.netconf.topology.singleton.impl.utils;
9
10 import static org.junit.Assert.assertEquals;
11
12 import org.junit.Test;
13 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
14 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
15 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
16 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18
19 public class NetconfTopologyUtilTest {
20     @Test
21     public void testCreateActorPath() {
22         final String actorPath = NetconfTopologyUtils.createActorPath("member", "name");
23         assertEquals("member/user/name", actorPath);
24     }
25
26     @Test
27     public void testCreateListPath() {
28         final InstanceIdentifier<Node> listPath =
29                 NetconfTopologyUtils.createTopologyNodeListPath(new NodeKey(new NodeId("nodeId")), "topologyId");
30
31         assertEquals("nodeId", listPath.firstKeyOf(Node.class).getNodeId().getValue());
32         assertEquals("topologyId", listPath.firstKeyOf(Topology.class).getTopologyId().getValue());
33
34         assertEquals("topologyId",  NetconfTopologyUtils.createTopologyNodePath("topologyId")
35                 .firstKeyOf(Topology.class).getTopologyId().getValue());
36     }
37 }