Update junit Assert imports
[controller.git] / opendaylight / md-sal / compatibility / sal-compatibility / src / test / java / org / opendaylight / controller / sal / compatibility / topology / test / TopologyMappingTest.java
1 /**
2  * Copyright (c) 2014 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.controller.sal.compatibility.topology.test;
9
10 import static org.junit.Assert.assertEquals;
11
12 import org.junit.Test;
13 import org.opendaylight.controller.sal.compatibility.topology.TopologyMapping;
14 import org.opendaylight.controller.sal.core.ConstructionException;
15 import org.opendaylight.controller.sal.core.Node;
16 import org.opendaylight.controller.sal.core.NodeConnector;
17 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
18 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
19
20 /**
21  * test for {@link TopologyMapping}
22  */
23 public class TopologyMappingTest {
24
25     /**
26      * Test method for {@link org.opendaylight.controller.sal.compatibility.topology.TopologyMapping#toADNodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)}.
27      */
28     @Test
29     public void testToADNodeId() {
30         NodeId nodeId = new NodeId("openflow:1");
31         String observedNodeId = TopologyMapping.toADNodeId(nodeId);
32
33         assertEquals("1", observedNodeId);
34     }
35
36     /**
37      * Test method for {@link org.opendaylight.controller.sal.compatibility.topology.TopologyMapping#toADNodeConnector(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId, org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)}.
38      * @throws ConstructionException
39      */
40     @Test
41     public void testToADNodeConnector() throws ConstructionException {
42         NodeId nodeId = new NodeId("openflow:1");
43         TpId source = new TpId("foo:2");
44         NodeConnector observedNodeConnector = TopologyMapping.toADNodeConnector(source, nodeId);
45
46         assertEquals("OF|2@OF|00:00:00:00:00:00:00:01", observedNodeConnector.toString());
47     }
48
49     /**
50      * Test method for {@link org.opendaylight.controller.sal.compatibility.topology.TopologyMapping#toADNodeConnectorId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)}.
51      */
52     @Test
53     public void testToADNodeConnectorId() {
54         TpId source = new TpId("foo:2");
55         String observedNodeConnectorId = TopologyMapping.toADNodeConnectorId(source);
56
57         assertEquals("2", observedNodeConnectorId);
58     }
59
60     /**
61      * Test method for {@link org.opendaylight.controller.sal.compatibility.topology.TopologyMapping#toADNode(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)}.
62      * @throws ConstructionException
63      */
64     @Test
65     public void testToADNode() throws ConstructionException {
66         NodeId nodeId = new NodeId("openflow:1");
67         Node observedNode = TopologyMapping.toADNode(nodeId);
68
69         assertEquals("OF|00:00:00:00:00:00:00:01", observedNode.toString());
70     }
71
72     /**
73      * Test method for {@link org.opendaylight.controller.sal.compatibility.topology.TopologyMapping#toADNodeConnector(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId, org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)}.
74      * @throws ConstructionException
75      */
76     @Test
77     public void bug1309ToADNodeConnector() throws ConstructionException {
78         NodeId nodeId = new NodeId("some_unknown_node");
79         TpId source = new TpId("192.168.0.1");
80         NodeConnector observedNodeConnector = TopologyMapping.toADNodeConnector(source, nodeId);
81
82         assertEquals("MD_SAL_DEPRECATED|192.168.0.1@MD_SAL_DEPRECATED|some_unknown_node", observedNodeConnector.toString());
83     }
84
85 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.