Bump MRI upstreams
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / GetAsyncReplyMessageFactoryTest.java
index 4cb07da24f9b5af458ef13e82533e96442868ba1..361b7a6781baa4ba218273bfe04281c119ee7b07 100644 (file)
@@ -5,23 +5,20 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 
 import io.netty.buffer.ByteBuf;
-
-import java.util.ArrayList;
 import java.util.List;
-
+import java.util.Set;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
-import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
@@ -34,97 +31,71 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder;
 
 /**
- * @author timotej.kubas
+ * Unit tests for GetAsyncReplyMessageFactory.
  *
+ * @author timotej.kubas
  */
 public class GetAsyncReplyMessageFactoryTest {
 
     private OFDeserializer<GetAsyncOutput> asyncFactory;
 
     /**
-     * Initializes deserializer registry and lookups correct deserializer
+     * Initializes deserializer registry and lookups correct deserializer.
      */
     @Before
     public void startUp() {
         DeserializerRegistry registry = new DeserializerRegistryImpl();
         registry.init();
         asyncFactory = registry.getDeserializer(
-                new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 27, GetAsyncOutput.class));
+                new MessageCodeKey(EncodeConstants.OF_VERSION_1_3, 27, GetAsyncOutput.class));
     }
 
     /**
-     * Testing {@link GetAsyncReplyMessageFactory} for correct translation into POJO
+     * Testing {@link GetAsyncReplyMessageFactory} for correct translation into POJO.
      */
     @Test
     public void testGetAsyncReplyMessage() {
-        ByteBuf bb = BufferHelper.buildBuffer("00 00 00 07 "+
-                                              "00 00 00 00 "+
-                                              "00 00 00 07 "+
-                                              "00 00 00 00 "+
-                                              "00 00 00 0F "+
-                                              "00 00 00 00");
+        ByteBuf bb = BufferHelper.buildBuffer(
+                "00 00 00 07 " + "00 00 00 00 " + "00 00 00 07 " + "00 00 00 00 " + "00 00 00 0F " + "00 00 00 00");
         GetAsyncOutput builtByFactory = BufferHelper.deserialize(asyncFactory, bb);
 
         BufferHelper.checkHeaderV13(builtByFactory);
-        Assert.assertEquals("Wrong packetInMask",createPacketInMask(), builtByFactory.getPacketInMask());
-        Assert.assertEquals("Wrong portStatusMask",createPortStatusMask(), builtByFactory.getPortStatusMask());
-        Assert.assertEquals("Wrong flowRemovedMask",createFlowRemovedMask(), builtByFactory.getFlowRemovedMask());
+        Assert.assertEquals("Wrong packetInMask", createPacketInMask(), builtByFactory.getPacketInMask());
+        Assert.assertEquals("Wrong portStatusMask", createPortStatusMask(), builtByFactory.getPortStatusMask());
+        Assert.assertEquals("Wrong flowRemovedMask", createFlowRemovedMask(), builtByFactory.getFlowRemovedMask());
     }
 
     private static List<PacketInMask> createPacketInMask() {
-        List<PacketInMask> inMasks = new ArrayList<>();
-        PacketInMaskBuilder maskBuilder;
-        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
-        maskBuilder = new PacketInMaskBuilder();
-        List<PacketInReason> reasons = new ArrayList<>();
-        reasons.add(PacketInReason.OFPRNOMATCH);
-        reasons.add(PacketInReason.OFPRACTION);
-        reasons.add(PacketInReason.OFPRINVALIDTTL);
-        maskBuilder.setMask(reasons);
-        inMasks.add(maskBuilder.build());
-        // OFPCR_ROLE_SLAVE
-        maskBuilder = new PacketInMaskBuilder();
-        reasons = new ArrayList<>();
-        maskBuilder.setMask(reasons);
-        inMasks.add(maskBuilder.build());
-        return inMasks;
+        return List.of(
+            // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
+            new PacketInMaskBuilder()
+                .setMask(Set.of(PacketInReason.OFPRNOMATCH, PacketInReason.OFPRACTION, PacketInReason.OFPRINVALIDTTL))
+                .build(),
+            // OFPCR_ROLE_SLAVE
+            new PacketInMaskBuilder().setMask(Set.of()).build());
     }
 
     private static List<PortStatusMask> createPortStatusMask() {
-        List<PortStatusMask> inMasks = new ArrayList<>();
-        PortStatusMaskBuilder maskBuilder;
-        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
-        maskBuilder = new PortStatusMaskBuilder();
-        List<PortReason> reasons = new ArrayList<>();
-        reasons.add(PortReason.OFPPRADD);
-        reasons.add(PortReason.OFPPRDELETE);
-        reasons.add(PortReason.OFPPRMODIFY);
-        inMasks.add(maskBuilder.setMask(reasons).build());
-        // OFPCR_ROLE_SLAVE
-        maskBuilder = new PortStatusMaskBuilder();
-        reasons = new ArrayList<>();
-        maskBuilder.setMask(reasons);
-        inMasks.add(maskBuilder.build());
-        return inMasks;
+        return List.of(
+            // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
+            new PortStatusMaskBuilder()
+                .setMask(Set.of(PortReason.OFPPRADD, PortReason.OFPPRDELETE, PortReason.OFPPRMODIFY))
+                .build(),
+            // OFPCR_ROLE_SLAVE
+            new PortStatusMaskBuilder().setMask(Set.of()).build());
     }
 
     private static List<FlowRemovedMask> createFlowRemovedMask() {
-        List<FlowRemovedMask> inMasks = new ArrayList<>();
-        FlowRemovedMaskBuilder maskBuilder;
-        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
-        maskBuilder = new FlowRemovedMaskBuilder();
-        List<FlowRemovedReason> reasons = new ArrayList<>();
-        reasons.add(FlowRemovedReason.OFPRRIDLETIMEOUT);
-        reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
-        reasons.add(FlowRemovedReason.OFPRRDELETE);
-        reasons.add(FlowRemovedReason.OFPRRGROUPDELETE);
-        maskBuilder.setMask(reasons);
-        inMasks.add(maskBuilder.build());
-        // OFPCR_ROLE_SLAVE
-        maskBuilder = new FlowRemovedMaskBuilder();
-        reasons = new ArrayList<>();
-        maskBuilder.setMask(reasons);
-        inMasks.add(maskBuilder.build());
-        return inMasks;
+        return List.of(
+            // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
+            new FlowRemovedMaskBuilder()
+                .setMask(Set.of(
+                    FlowRemovedReason.OFPRRIDLETIMEOUT,
+                    FlowRemovedReason.OFPRRHARDTIMEOUT,
+                    FlowRemovedReason.OFPRRDELETE,
+                    FlowRemovedReason.OFPRRGROUPDELETE))
+                .build(),
+            // OFPCR_ROLE_SLAVE
+            new FlowRemovedMaskBuilder().setMask(Set.of()).build());
     }
-}
\ No newline at end of file
+}