Bump MRI upstreams
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / SetAsyncInputMessageFactoryTest.java
index 1f2ff731d089df2c67220354f663ee4c354abdd8..2504a38949e3da65cce0f68fc23666edd6919921 100644 (file)
@@ -5,15 +5,12 @@
  * 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.serialization.factories;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.UnpooledByteBufAllocator;
-
-import java.util.ArrayList;
 import java.util.List;
-
+import java.util.Set;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -36,6 +33,8 @@ 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;
 
 /**
+ * Unit tests for SetAsyncInputMessageFactory.
+ *
  * @author timotej.kubas
  * @author michal.polkorab
  */
@@ -45,19 +44,18 @@ public class SetAsyncInputMessageFactoryTest {
     private OFSerializer<SetAsyncInput> setAsyncFactory;
 
     /**
-     * Initializes serializer registry and stores correct factory in field
+     * Initializes serializer registry and stores correct factory in field.
      */
     @Before
     public void startUp() {
         registry = new SerializerRegistryImpl();
         registry.init();
         setAsyncFactory = registry.getSerializer(
-                new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, SetAsyncInput.class));
+                new MessageTypeKey<>(EncodeConstants.OF_VERSION_1_3, SetAsyncInput.class));
     }
 
     /**
-     * @throws Exception
-     * Testing of {@link SetAsyncInputMessageFactory} for correct translation from POJO
+     * Testing of {@link SetAsyncInputMessageFactory} for correct translation from POJO.
      */
     @Test
     public void testSetAsyncInputMessage() throws Exception {
@@ -82,66 +80,41 @@ public class SetAsyncInputMessageFactoryTest {
     }
 
     private static List<PacketInMask> createPacketInMask() {
-        List<PacketInMask> masks = new ArrayList<>();
-        PacketInMaskBuilder builder;
-        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
-        builder = new PacketInMaskBuilder();
-        List<PacketInReason> packetInReasonList = new ArrayList<>();
-        packetInReasonList.add(PacketInReason.OFPRNOMATCH);
-        packetInReasonList.add(PacketInReason.OFPRACTION);
-        packetInReasonList.add(PacketInReason.OFPRINVALIDTTL);
-        builder.setMask(packetInReasonList);
-        masks.add(builder.build());
-        // OFPCR_ROLE_SLAVE
-        builder = new PacketInMaskBuilder();
-        packetInReasonList = new ArrayList<>();
-        builder.setMask(packetInReasonList);
-        masks.add(builder.build());
-        return masks;
+        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> masks = new ArrayList<>();
-        PortStatusMaskBuilder builder;
-        builder = new PortStatusMaskBuilder();
-        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
-        List<PortReason> portReasonList = new ArrayList<>();
-        portReasonList.add(PortReason.OFPPRADD);
-        portReasonList.add(PortReason.OFPPRDELETE);
-        portReasonList.add(PortReason.OFPPRMODIFY);
-        builder.setMask(portReasonList);
-        masks.add(builder.build());
-        // OFPCR_ROLE_SLAVE
-        builder = new PortStatusMaskBuilder();
-        portReasonList = new ArrayList<>();
-        builder.setMask(portReasonList);
-        masks.add(builder.build());
-        return masks;
+        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> createFlowRemowedMask() {
-        List<FlowRemovedMask> masks = new ArrayList<>();
-        FlowRemovedMaskBuilder builder;
-        // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER
-        builder = new FlowRemovedMaskBuilder();
-        List<FlowRemovedReason> flowRemovedReasonList = new ArrayList<>();
-        flowRemovedReasonList.add(FlowRemovedReason.OFPRRIDLETIMEOUT);
-        flowRemovedReasonList.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
-        flowRemovedReasonList.add(FlowRemovedReason.OFPRRDELETE);
-        flowRemovedReasonList.add(FlowRemovedReason.OFPRRGROUPDELETE);
-        builder.setMask(flowRemovedReasonList);
-        masks.add(builder.build());
-        // OFPCR_ROLE_SLAVE
-        builder = new FlowRemovedMaskBuilder();
-        flowRemovedReasonList = new ArrayList<>();
-        builder.setMask(flowRemovedReasonList);
-        masks.add(builder.build());
-        return masks;
+        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());
     }
 
     /**
-     * @throws Exception
-     * Testing of {@link SetAsyncInputMessageFactory} for correct translation from POJO
+     * Testing of {@link SetAsyncInputMessageFactory} for correct translation from POJO.
      */
     @Test
     public void testSetAsyncInputWithNullMasks() throws Exception {
@@ -158,4 +131,4 @@ public class SetAsyncInputMessageFactoryTest {
         BufferHelper.checkHeaderV13(out,(byte) 28, 8);
         Assert.assertTrue("Unexpected data", out.readableBytes() == 0);
     }
-}
\ No newline at end of file
+}