Remove trailing whitespace
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / serialization / factories / GroupModInputMessageFactoryTest.java
index ba129d3f2e4fb07e6d29034f8a46c9300f4ee6f0..c158b7067c51ec0d266d1d35553e61b1b8d6c8c2 100644 (file)
@@ -20,9 +20,9 @@ import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;
@@ -67,7 +67,7 @@ public class GroupModInputMessageFactoryTest {
         List<BucketsList> exp = createBucketsList();
         builder.setBucketsList(exp);
         GroupModInput message = builder.build();
-        
+
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
         groupModFactory.serialize(message, out);
 
@@ -79,7 +79,7 @@ public class GroupModInputMessageFactoryTest {
         List<BucketsList> rec = createBucketsListFromBufer(out);
         Assert.assertArrayEquals("Wrong bucketList", exp.toArray(), rec.toArray());
     }
-    
+
     private static List<BucketsList> createBucketsList(){
         List<BucketsList> bucketsList = new ArrayList<>();
         BucketsListBuilder bucketsBuilder = new BucketsListBuilder();
@@ -91,7 +91,7 @@ public class GroupModInputMessageFactoryTest {
         bucketsList.add(bucket);
         return bucketsList;
     }
-    
+
     private static List<BucketsList> createBucketsListFromBufer(ByteBuf out){
         List<BucketsList> bucketsList = new ArrayList<>();
         BucketsListBuilder bucketsBuilder = new BucketsListBuilder();
@@ -105,4 +105,28 @@ public class GroupModInputMessageFactoryTest {
         bucketsList.add(bucket);
         return bucketsList;
     }
-}
+
+    /**
+     * Testing of {@link GroupModInputMessageFactory} for correct translation from POJO
+     * @throws Exception
+     */
+    @Test
+    public void testGroupModInputWithNoBuckets() throws Exception {
+        GroupModInputBuilder builder = new GroupModInputBuilder();
+        BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
+        builder.setCommand(GroupModCommand.forValue(2));
+        builder.setType(GroupType.forValue(3));
+        builder.setGroupId(new GroupId(256L));
+        GroupModInput message = builder.build();
+
+        ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        groupModFactory.serialize(message, out);
+
+        BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 16);
+        Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readUnsignedShort());
+        Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedByte());
+        out.skipBytes(PADDING_IN_GROUP_MOD_MESSAGE);
+        Assert.assertEquals("Wrong groupId", message.getGroupId().getValue().intValue(), out.readUnsignedInt());
+        Assert.assertTrue("Unexpected data", out.readableBytes() == 0);
+    }
+}
\ No newline at end of file