### Question:
PacketInMessageFactory implements OFDeserializer<PacketInMessage>,
        DeserializerRegistryInjector { @Override public PacketInMessage deserialize(final ByteBuf rawMessage) { PacketInMessageBuilder builder = new PacketInMessageBuilder(); builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); builder.setXid(rawMessage.readUnsignedInt()); builder.setBufferId(rawMessage.readUnsignedInt()); builder.setTotalLen(rawMessage.readUnsignedShort()); builder.setReason(PacketInReason.forValue(rawMessage.readUnsignedByte())); builder.setTableId(new TableId((long)rawMessage.readUnsignedByte())); byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; rawMessage.readBytes(cookie); builder.setCookie(new BigInteger(1, cookie)); OFDeserializer<Match> matchDeserializer = registry.getDeserializer(MATCH_KEY); builder.setMatch(matchDeserializer.deserialize(rawMessage)); rawMessage.skipBytes(PADDING_IN_PACKET_IN_HEADER); byte[] data = new byte[rawMessage.readableBytes()]; rawMessage.readBytes(data); builder.setData(data); return builder.build(); }  @Override PacketInMessage deserialize(final ByteBuf rawMessage); @Override void injectDeserializerRegistry(final DeserializerRegistry deserializerRegistry);  }### Answer:
@Test public void test(){ ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 04 00 01 02 03 04 05 06 07 00 01 00 0C" + " 80 00 02 04 00 00 00 01 00 00 00 00 00 00 01 02 03 04"); PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong bufferID", 0x00010203L, builtByFactory.getBufferId().longValue()); Assert.assertEquals("Wrong totalLength", 0x0102, builtByFactory.getTotalLen().intValue()); Assert.assertEquals("Wrong reason", PacketInReason.OFPRACTION, builtByFactory.getReason()); Assert.assertEquals("Wrong tableID", new TableId(4L), builtByFactory.getTableId()); Assert.assertEquals("Wrong cookie", 0x0001020304050607L, builtByFactory.getCookie().longValue()); Assert.assertArrayEquals("Wrong data", ByteBufUtils.hexStringToBytes("01 02 03 04"), builtByFactory.getData()); }