Merge "BUG 2317 : StatisticsManager does not unregister from yang notifications on...
[controller.git] / opendaylight / md-sal / compatibility / sal-compatibility / src / test / java / org / opendaylight / controller / sal / compatibility / test / MDFlowMappingTest.java
index 4e5f318d4c479711b137cce98d4b59ad6cda33d9..2490ace648cd37436a710831142e219534587fdd 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -7,16 +7,20 @@
  */
 package org.opendaylight.controller.sal.compatibility.test;
 
-import junit.framework.Assert;
-
+import org.junit.Assert;
 import org.junit.Test;
+import org.opendaylight.controller.sal.action.Action;
+import org.opendaylight.controller.sal.action.PushVlan;
 import org.opendaylight.controller.sal.compatibility.MDFlowMapping;
 import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.Node.NodeIDType;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
+import org.opendaylight.controller.sal.utils.EtherTypes;
+
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
 
 /**
  * test for {@link MDFlowMapping}
@@ -36,4 +40,29 @@ public class MDFlowMappingTest {
         Assert.assertEquals("openflow:41:42", observed.getValue());
     }
 
+    /**
+     * Test method for {@link MDFlowMapping#toAction(Action, int)}.
+     */
+    @Test
+    public void testToAction() {
+        // PUSH_VLAN test.
+        EtherTypes[] tags = {EtherTypes.VLANTAGGED, EtherTypes.QINQ};
+        int order = 0;
+        for (EtherTypes tag: tags) {
+            Action action = new PushVlan(tag);
+            org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.
+                rev131112.action.list.Action mdActionList =
+                MDFlowMapping.toAction(action, order);
+            Assert.assertEquals(order, mdActionList.getOrder().intValue());
+
+            org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.
+                rev131112.action.Action mdAction = mdActionList.getAction();
+            Assert.assertTrue(mdAction instanceof PushVlanActionCase);
+            PushVlanActionCase pushVlan = (PushVlanActionCase)mdAction;
+            Assert.assertEquals(tag.intValue(),
+                                pushVlan.getPushVlanAction().getEthernetType().
+                                intValue());
+            order++;
+        }
+    }
 }