package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart;
import io.netty.buffer.ByteBuf;
-
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures;
/**
- * @author michal.polkorab
+ * Unit tests for MultipartReplyGroupFeatures.
*
+ * @author michal.polkorab
*/
public class MultipartReplyGroupFeaturesTest {
- private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory();
+ private final MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory();
/**
- * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
+ * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyGroupFeatures() {
- ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+
- "00 00 00 0F "+// types
- "00 00 00 0F "+// capabilities
- "00 00 00 01 "+// max groups
- "00 00 00 02 "+// max groups
- "00 00 00 03 "+// max groups
- "00 00 00 04 "+// max groups
- "0F FF 98 01 "+// actions bitmap (all actions included)
- "00 00 00 00 "+// actions bitmap (no actions included)
- "00 00 00 00 "+// actions bitmap (no actions included)
+ ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 " + //
+ "00 00 00 0F " + // types
+ "00 00 00 0F " + // capabilities
+ "00 00 00 01 " + // max groups
+ "00 00 00 02 " + // max groups
+ "00 00 00 03 " + // max groups
+ "00 00 00 04 " + // max groups
+ "0F FF 98 01 " + // actions bitmap (all actions included)
+ "00 00 00 00 " + // actions bitmap (no actions included)
+ "00 00 00 00 " + // actions bitmap (no actions included)
"00 00 00 00"// actions bitmap (no actions included)
);
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
Assert.assertEquals("Wrong max groups", 2, message.getMaxGroups().get(1).intValue());
Assert.assertEquals("Wrong max groups", 3, message.getMaxGroups().get(2).intValue());
Assert.assertEquals("Wrong max groups", 4, message.getMaxGroups().get(3).intValue());
- Assert.assertEquals("Wrong actions bitmap", new ActionType(true, true, true, true, false, true, true, true, true,
- true, true, true, true, true, true, true, true), message.getActionsBitmap().get(0));
- Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(1));
- Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(2));
- Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(3));
+ Assert.assertEquals("Wrong actions bitmap", new ActionType(true, true, true, true, false, true, true, true,
+ true, true, true, true, true, true, true, true, true), message.getActionsBitmap().get(0));
+ Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false, false, false),
+ message.getActionsBitmap().get(1));
+ Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false, false, false),
+ message.getActionsBitmap().get(2));
+ Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false,
+ false, false, false, false, false, false, false, false, false, false),
+ message.getActionsBitmap().get(3));
}
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
- * (with different group types and capabilities)
+ * (with different group types and capabilities).
*/
@Test
public void testMultipartReplyGroupFeatures2() {
- ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+
- "00 00 00 00 "+// types
- "00 00 00 00 "+// capabilities
- "00 00 00 01 "+// max groups
- "00 00 00 02 "+// max groups
- "00 00 00 03 "+// max groups
- "00 00 00 04 "+// max groups
- "00 00 00 00 "+// actions bitmap (all actions included)
- "00 00 00 00 "+// actions bitmap (no actions included)
- "00 00 00 00 "+// actions bitmap (no actions included)
+ ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 " + //
+ "00 00 00 00 " + // types
+ "00 00 00 00 " + // capabilities
+ "00 00 00 01 " + // max groups
+ "00 00 00 02 " + // max groups
+ "00 00 00 03 " + // max groups
+ "00 00 00 04 " + // max groups
+ "00 00 00 00 " + // actions bitmap (all actions included)
+ "00 00 00 00 " + // actions bitmap (no actions included)
+ "00 00 00 00 " + // actions bitmap (no actions included)
"00 00 00 00"// actions bitmap (no actions included)
);
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
Assert.assertEquals("Wrong capabilities", new GroupCapabilities(false, false, false, false),
message.getCapabilities());
}
-}
\ No newline at end of file
+}