BUG-1866: sal-compatibility does not register some services
[controller.git] / opendaylight / md-sal / compatibility / sal-compatibility / src / test / java / org / opendaylight / controller / sal / compatibility / test / NodeMappingTest.java
index 8a23ebc933b54359ed7f4dc0d5b4786c05a17d21..759e69f5eb980844ed89b8dca581f57637486313 100644 (file)
@@ -101,6 +101,16 @@ public class NodeMappingTest {
         } catch (ConstructionException e) {
             Assert.fail("should succeed to construct Node: "+e.getMessage());
         }
+
+        final String nodeUriPrefix = "opendaylight-inventory:nodes/node/";
+        nodeId = new NodeId(nodeUriPrefix + "iosv-2");
+        try {
+            observed = NodeMapping.toADNode(nodeId);
+            Assert.assertEquals("PR|opendaylight-inventory:nodes/node/iosv-2", observed.toString());
+        } catch (ConstructionException e) {
+            Assert.fail("should succeed to construct Node: "+e.getMessage());
+        }
+
     }
 
     /**
@@ -174,6 +184,31 @@ public class NodeMappingTest {
         Assert.assertEquals("openflow:1", observedNodeConnectorId);
     }
 
+    /**
+     * Test method for
+     * {@link org.opendaylight.controller.sal.compatibility.NodeMapping#openflowFullNodeIdToLong(String)}
+     * .
+     * @throws ConstructionException
+     */
+    @Test
+    public void testOpenflowFullNodeIdToLong() throws ConstructionException {
+        Assert.assertEquals(42L, NodeMapping.openflowFullNodeIdToLong("42").longValue());
+        Assert.assertEquals(0xCC4E241C4A000000L, NodeMapping.openflowFullNodeIdToLong("14721743935839928320").longValue());
+    }
+
+    /**
+     * Test method for
+     * {@link org.opendaylight.controller.sal.compatibility.NodeMapping#toNodeKey(org.opendaylight.controller.sal.core.Node)}
+     * .
+     * @throws ConstructionException
+     */
+    @Test
+    public void testToNodeKey() throws ConstructionException {
+        org.opendaylight.controller.sal.core.Node aDNode = new org.opendaylight.controller.sal.core.Node(NodeIDType.OPENFLOW, 42L);
+        NodeKey nodeKey = NodeMapping.toNodeKey(aDNode);
+        Assert.assertEquals("openflow:42", nodeKey.getId().getValue());
+    }
+
     /**
      * @param nodeId
      * @param portId