Bug 2021 - Continuous WARN log nodeConnector creation failed at node: OF|00:00:xx...
[controller.git] / opendaylight / md-sal / compatibility / sal-compatibility / src / test / java / org / opendaylight / controller / sal / compatibility / test / TestToSalConversionsUtils.java
index 54ffddbbe3114a13c1de1cd46824f8a52823ee4f..7c20c24becf8ffb3828372a07a35c60db073cb04 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.sal.compatibility.test;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.CRUDP;
 import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.ETHERNET_ARP;
@@ -199,6 +200,29 @@ public class TestToSalConversionsUtils {
         assertEquals("OF|1@OF|00:00:00:00:00:00:00:2a", nodeConnector.toString());
     }
 
+    @Test
+    public void testActionFrom() throws ConstructionException {
+        // Bug 2021: Convert AD-SAL notation into MD-SAL notation before calling NodeConnector
+        Node node = new Node(NodeIDType.OPENFLOW, 42L);
+        List<Action> odActions = new ArrayList<>();
+
+        OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
+        outputActionBuilder.setOutputNodeConnector(new Uri("CONTROLLER"));
+        OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
+        outputActionCaseBuilder.setOutputAction(outputActionBuilder.build());
+        odActions.add(new ActionBuilder().setAction(outputActionCaseBuilder.build()).build());
+
+        List<org.opendaylight.controller.sal.action.Action> targetAction =
+                ToSalConversionsUtils.actionFrom(odActions, node);
+        assertNotNull(targetAction);
+        assertTrue( Output.class.isInstance(targetAction.get(0)) );
+        Output targetActionOutput = (Output) targetAction.get(0);
+        NodeConnector port = targetActionOutput.getPort();
+        assertNotNull(port);
+        assertEquals(port.getType(), NodeConnectorIDType.CONTROLLER);
+        assertEquals(port.getID(), org.opendaylight.controller.sal.core.NodeConnector.SPECIALNODECONNECTORID);
+    }
+
     private void checkSalMatch(org.opendaylight.controller.sal.match.Match match, MtchType mt) throws ConstructionException {
         switch (mt) {
         case other: