Bump upstreams for 2022.09 Chlorine
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / FlowModInputMessageFactoryTest.java
index 5f6268e08fd4b20e6d479173e214cf8e3abd94f2..01aede96d814a99644d97ae64fb3f5f7e498c32a 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 
 import io.netty.buffer.ByteBuf;
-import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 import org.junit.Assert;
@@ -49,6 +48,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
+import org.opendaylight.yangtools.yang.common.Uint8;
 
 /**
  * Unit tests for FlowModInputMessageFactory.
@@ -66,7 +69,7 @@ public class FlowModInputMessageFactoryTest {
         DeserializerRegistry registry = new DeserializerRegistryImpl();
         registry.init();
         flowFactory = registry
-                .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 14, FlowModInput.class));
+                .getDeserializer(new MessageCodeKey(EncodeConstants.OF_VERSION_1_3, 14, FlowModInput.class));
     }
 
     @Test
@@ -78,17 +81,16 @@ public class FlowModInputMessageFactoryTest {
             + "09 30 00 30 00 04 00 18 00 00 00 00 00 00 00 10 00 00 00 2a 00 34 00 00 00 00 00 00");
         FlowModInput deserializedMessage = BufferHelper.deserialize(flowFactory, bb);
         BufferHelper.checkHeaderV13(deserializedMessage);
-        byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 };
-        Assert.assertEquals("Wrong cookie", new BigInteger(1, cookie), deserializedMessage.getCookie());
-        byte[] cookieMask = new byte[] { (byte) 0xFF, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30 };
-        Assert.assertEquals("Wrong cookie mask", new BigInteger(1, cookieMask), deserializedMessage.getCookieMask());
-        Assert.assertEquals("Wrong table id", new TableId(65L), deserializedMessage.getTableId());
+        Assert.assertEquals("Wrong cookie", Uint64.valueOf("FF01040106000701", 16), deserializedMessage.getCookie());
+        Assert.assertEquals("Wrong cookie mask", Uint64.valueOf("FF05000009300030", 16),
+            deserializedMessage.getCookieMask());
+        Assert.assertEquals("Wrong table id", new TableId(Uint32.valueOf(65)), deserializedMessage.getTableId());
         Assert.assertEquals("Wrong command", FlowModCommand.forValue(2), deserializedMessage.getCommand());
         Assert.assertEquals("Wrong idle timeout", 12, deserializedMessage.getIdleTimeout().intValue());
         Assert.assertEquals("Wrong hard timeout", 0, deserializedMessage.getHardTimeout().intValue());
         Assert.assertEquals("Wrong priority", 126, deserializedMessage.getPriority().intValue());
         Assert.assertEquals("Wrong buffer id ", 2L, deserializedMessage.getBufferId().longValue());
-        Assert.assertEquals("Wrong out port", new PortNumber(4422L), deserializedMessage.getOutPort());
+        Assert.assertEquals("Wrong out port", new PortNumber(Uint32.valueOf(4422)), deserializedMessage.getOutPort());
         Assert.assertEquals("Wrong out group", 98L, deserializedMessage.getOutGroup().longValue());
         Assert.assertEquals("Wrong flags", new FlowModFlags(true, false, true, false, true),
                 deserializedMessage.getFlags());
@@ -97,12 +99,12 @@ public class FlowModInputMessageFactoryTest {
 
     }
 
-    private List<Instruction> createInstructions() {
+    private static List<Instruction> createInstructions() {
         final List<Instruction> instructions = new ArrayList<>();
         InstructionBuilder insBuilder = new InstructionBuilder();
         GotoTableCaseBuilder goToCaseBuilder = new GotoTableCaseBuilder();
         GotoTableBuilder instructionBuilder = new GotoTableBuilder();
-        instructionBuilder.setTableId((short) 43);
+        instructionBuilder.setTableId(Uint8.valueOf(43));
         goToCaseBuilder.setGotoTable(instructionBuilder.build());
         insBuilder.setInstructionChoice(goToCaseBuilder.build());
         instructions.add(insBuilder.build());
@@ -122,8 +124,8 @@ public class FlowModInputMessageFactoryTest {
         final ActionBuilder actionBuilder = new ActionBuilder();
         OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
         OutputActionBuilder outputBuilder = new OutputActionBuilder();
-        outputBuilder.setPort(new PortNumber(42L));
-        outputBuilder.setMaxLength(52);
+        outputBuilder.setPort(new PortNumber(Uint32.valueOf(42)));
+        outputBuilder.setMaxLength(Uint16.valueOf(52));
         caseBuilder.setOutputAction(outputBuilder.build());
         actionBuilder.setActionChoice(caseBuilder.build());
         actions.add(actionBuilder.build());
@@ -134,31 +136,30 @@ public class FlowModInputMessageFactoryTest {
         return instructions;
     }
 
-    private Match createMatch() {
+    private static Match createMatch() {
         MatchBuilder matchBuilder = new MatchBuilder();
-        matchBuilder.setType(OxmMatchType.class);
+        matchBuilder.setType(OxmMatchType.VALUE);
         final List<MatchEntry> entries = new ArrayList<>();
         MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
-        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
-        entriesBuilder.setOxmMatchField(InPhyPort.class);
+        entriesBuilder.setOxmClass(OpenflowBasicClass.VALUE);
+        entriesBuilder.setOxmMatchField(InPhyPort.VALUE);
         entriesBuilder.setHasMask(false);
         InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
         InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
-        inPhyPortBuilder.setPortNumber(new PortNumber(42L));
+        inPhyPortBuilder.setPortNumber(new PortNumber(Uint32.valueOf(42)));
         inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
         entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
         entries.add(entriesBuilder.build());
-        entriesBuilder.setOxmClass(OpenflowBasicClass.class);
-        entriesBuilder.setOxmMatchField(IpEcn.class);
+        entriesBuilder.setOxmClass(OpenflowBasicClass.VALUE);
+        entriesBuilder.setOxmMatchField(IpEcn.VALUE);
         entriesBuilder.setHasMask(false);
         IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
         IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
-        ipEcnBuilder.setEcn((short) 4);
+        ipEcnBuilder.setEcn(Uint8.valueOf(4));
         ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
         entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
         entries.add(entriesBuilder.build());
         matchBuilder.setMatchEntry(entries);
         return matchBuilder.build();
     }
-
 }