Instruction experimenterId fix
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / util / TypeKeyMakerFactoryTest.java
index ba445321416c2a2b9aa95803bef95abdc61d8399..0cfb09407df58b85b905de0146480fb207af6bd7 100644 (file)
@@ -10,34 +10,33 @@ package org.opendaylight.openflowjava.protocol.impl.util;
 
 import org.junit.Assert;
 import org.junit.Test;
-import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;
 import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
-import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey;
-import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
 
 /**
  * @author michal.polkorab
@@ -54,13 +53,13 @@ public class TypeKeyMakerFactoryTest {
         Assert.assertNotNull("Null keyMaker", keyMaker);
 
         ActionBuilder builder = new ActionBuilder();
-        builder.setType(Output.class);
+        builder.setActionChoice(new OutputActionCaseBuilder().build());
         Action action = builder.build();
         MessageTypeKey<?> key = keyMaker.make(action);
 
         Assert.assertNotNull("Null key", key);
         Assert.assertEquals("Wrong key", new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID,
-                        Output.class, null), key);
+                        OutputActionCase.class, null), key);
     }
 
     /**
@@ -71,18 +70,15 @@ public class TypeKeyMakerFactoryTest {
         TypeKeyMaker<Action> keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID);
         Assert.assertNotNull("Null keyMaker", keyMaker);
 
-        ActionBuilder builder = new ActionBuilder();
-        builder.setType(Experimenter.class);
-        ExperimenterIdActionBuilder expIdBuilder = new ExperimenterIdActionBuilder();
-        expIdBuilder.setExperimenter(new ExperimenterId(42L));
-        expIdBuilder.setSubType(ActionSubtypeClass.class);
-        builder.addAugmentation(ExperimenterIdAction.class, expIdBuilder.build());
+        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder builder = new ActionBuilder();
+        builder.setExperimenterId(new ExperimenterId(42L));
+        builder.setActionChoice(new CopyTtlInCaseBuilder().build());
         Action action = builder.build();
         MessageTypeKey<?> key = keyMaker.make(action);
 
         Assert.assertNotNull("Null key", key);
-        Assert.assertEquals("Wrong key", new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L,
-                ActionSubtypeClass.class), key);
+        Assert.assertEquals("Wrong key", new ActionSerializerKey(EncodeConstants.OF13_VERSION_ID,
+                CopyTtlInCase.class, 42L), key);
     }
 
     /**
@@ -94,13 +90,13 @@ public class TypeKeyMakerFactoryTest {
         Assert.assertNotNull("Null keyMaker", keyMaker);
 
         InstructionBuilder builder = new InstructionBuilder();
-        builder.setType(GotoTable.class);
+        builder.setInstructionChoice(new GotoTableCaseBuilder().build());
         Instruction instruction = builder.build();
         MessageTypeKey<?> key = keyMaker.make(instruction);
 
         Assert.assertNotNull("Null key", key);
         Assert.assertEquals("Wrong key", new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID,
-                        GotoTable.class, null), key);
+                        GotoTableCase.class, null), key);
     }
 
     /**
@@ -112,17 +108,14 @@ public class TypeKeyMakerFactoryTest {
         Assert.assertNotNull("Null keyMaker", keyMaker);
 
         InstructionBuilder builder = new InstructionBuilder();
-        builder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
-                .common.instruction.rev130731.Experimenter.class);
-        ExperimenterIdInstructionBuilder expIdBuilder = new ExperimenterIdInstructionBuilder();
-        expIdBuilder.setExperimenter(new ExperimenterId(42L));
-        builder.addAugmentation(ExperimenterIdInstruction.class, expIdBuilder.build());
+        builder.setExperimenterId(new ExperimenterId(42L));
+        builder.setInstructionChoice(new ClearActionsCaseBuilder().build());
         Instruction instruction = builder.build();
         MessageTypeKey<?> key = keyMaker.make(instruction);
 
         Assert.assertNotNull("Null key", key);
-        Assert.assertEquals("Wrong key", new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID,
-                        42L), key);
+        Assert.assertEquals("Wrong key", new InstructionSerializerKey(EncodeConstants.OF13_VERSION_ID,
+                        ClearActionsCase.class, 42L), key);
     }
 
     /**
@@ -130,14 +123,14 @@ public class TypeKeyMakerFactoryTest {
      */
     @Test
     public void testMatchEntriesKeyMaker() {
-        TypeKeyMaker<MatchEntries> keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);
+        TypeKeyMaker<MatchEntry> keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);
         Assert.assertNotNull("Null keyMaker", keyMaker);
 
-        MatchEntriesBuilder builder = new MatchEntriesBuilder();
+        MatchEntryBuilder builder = new MatchEntryBuilder();
         builder.setOxmClass(OpenflowBasicClass.class);
         builder.setOxmMatchField(InPort.class);
         builder.setHasMask(true);
-        MatchEntries entry = builder.build();
+        MatchEntry entry = builder.build();
         MessageTypeKey<?> key = keyMaker.make(entry);
 
         Assert.assertNotNull("Null key", key);
@@ -151,17 +144,19 @@ public class TypeKeyMakerFactoryTest {
      */
     @Test
     public void testExperimenterMatchEntriesKeyMaker() {
-        TypeKeyMaker<MatchEntries> keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);
+        TypeKeyMaker<MatchEntry> keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);
         Assert.assertNotNull("Null keyMaker", keyMaker);
 
-        MatchEntriesBuilder builder = new MatchEntriesBuilder();
+        MatchEntryBuilder builder = new MatchEntryBuilder();
         builder.setOxmClass(ExperimenterClass.class);
         builder.setOxmMatchField(OxmMatchFieldClass.class);
         builder.setHasMask(true);
-        ExperimenterIdMatchEntryBuilder expIdBuilder = new ExperimenterIdMatchEntryBuilder();
-        expIdBuilder.setExperimenter(new ExperimenterId(42L));
-        builder.addAugmentation(ExperimenterIdMatchEntry.class, expIdBuilder.build());
-        MatchEntries entry = builder.build();
+        ExperimenterIdCaseBuilder caseBuilder = new ExperimenterIdCaseBuilder();
+        ExperimenterBuilder expBuilder = new ExperimenterBuilder();
+        expBuilder.setExperimenter(new ExperimenterId(42L));
+        caseBuilder.setExperimenter(expBuilder.build());
+        builder.setMatchEntryValue(caseBuilder.build());
+        MatchEntry entry = builder.build();
         MessageTypeKey<?> key = keyMaker.make(entry);
 
         Assert.assertNotNull("Null key", key);