### Question:
HelloMessageFactory extends VersionAssignableFactory implements OFDeserializer<HelloMessage> { @Override public HelloMessage deserialize(ByteBuf rawMessage) { HelloMessageBuilder builder = new HelloMessageBuilder(); builder.setVersion(getVersion()); builder.setXid(rawMessage.readUnsignedInt()); if (rawMessage.readableBytes() > 0) { builder.setElements(readElement(rawMessage)); } return builder.build(); }  @Override HelloMessage deserialize(ByteBuf rawMessage);  }### Answer:
@Test public void testWithoutPadding() { ByteBuf bb = BufferHelper.buildBuffer("00 01 " + "00 08 " + "00 00 00 11" ); HelloMessage builtByFactory = BufferHelper.deserialize(factory, bb); List<Elements> element = createElement(4,HelloElementType.VERSIONBITMAP.getIntValue()); Assert.assertEquals("Wrong type", element.get(0).getType(), builtByFactory.getElements().get(0).getType()); Assert.assertEquals("Wrong versionBitmap", element.get(0).getVersionBitmap(), builtByFactory.getElements().get(0).getVersionBitmap()); }
@Test public void testWithPadding() { ByteBuf bb = BufferHelper.buildBuffer("00 01 " + "00 0c " + "00 00 00 11 " + "00 00 00 00 " + "00 00 00 00" ); HelloMessage builtByFactory = BufferHelper.deserialize(factory, bb); List<Elements> element = createElement(8,HelloElementType.VERSIONBITMAP.getIntValue()); Assert.assertEquals("Wrong type", element.get(0).getType(), builtByFactory.getElements().get(0).getType()); Assert.assertEquals("Wrong versionBitmap", element.get(0).getVersionBitmap(), builtByFactory.getElements().get(0).getVersionBitmap()); }
@Test public void testBadType(){ ByteBuf bb = BufferHelper.buildBuffer("00 02 " + "00 0c " + "00 00 00 11 " + "00 00 00 00 " + "00 00 00 00" ); HelloMessage builtByFactory = BufferHelper.deserialize(factory, bb); Assert.assertEquals("Wrong - no element has been expected", 0, builtByFactory.getElements().size()); }