### Question:
GetFeaturesOutputFactory implements OFSerializer<GetFeaturesOutput>, SerializerRegistryInjector { @Override public void serialize(GetFeaturesOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeLong(message.getDatapathId().longValue()); outBuffer.writeInt(message.getBuffers().intValue()); outBuffer.writeByte(message.getTables().intValue()); outBuffer.writeByte(message.getAuxiliaryId().intValue()); outBuffer.writeZero(PADDING); writeCapabilities(message.getCapabilities(), outBuffer); outBuffer.writeInt(message.getReserved().intValue()); ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void serialize(GetFeaturesOutput message, ByteBuf outBuffer); @Override void injectSerializerRegistry(final SerializerRegistry serializerRegistry);  }### Answer:
@Test public void testSerialize() throws Exception { GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setDatapathId(BigInteger.valueOf(1234L)); builder.setBuffers(1234L); builder.setTables((short) 12); builder.setAuxiliaryId((short) 12); builder.setCapabilities(new Capabilities(true, false, true, false, true, false, true)); builder.setReserved(1234L); GetFeaturesOutput message = builder.build(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); factory.serialize(message, serializedBuffer); BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 32); Assert.assertEquals("Wrong DatapathId", message.getDatapathId().longValue(), serializedBuffer.readLong()); Assert.assertEquals("Wrong Buffer ID", message.getBuffers().longValue(), serializedBuffer.readInt()); Assert.assertEquals("Wrong tables", message.getTables().shortValue(), serializedBuffer.readUnsignedByte()); Assert.assertEquals("Wrong auxiliary ID", message.getAuxiliaryId().shortValue(), serializedBuffer.readUnsignedByte()); serializedBuffer.skipBytes(PADDING); Assert.assertEquals("Wrong Capabilities", message.getCapabilities(), createCapabilities(serializedBuffer.readInt())); Assert.assertEquals("Wrong reserved", message.getReserved().longValue(), serializedBuffer.readInt()); }
@Test public void testSerialize() { GetFeaturesOutputFactory serializer = new GetFeaturesOutputFactory(); SerializerRegistry registry = new NetIdeSerializerRegistryImpl(); registry.init(); serializer.injectSerializerRegistry(registry); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(message, serializedBuffer); BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 32); Assert.assertEquals("Wrong DatapathId", message.getDatapathId().longValue(), serializedBuffer.readLong()); Assert.assertEquals("Wrong Buffer ID", message.getBuffers().longValue(), serializedBuffer.readInt()); Assert.assertEquals("Wrong tables", message.getTables().shortValue(), serializedBuffer.readUnsignedByte()); Assert.assertEquals("Wrong auxiliary ID", message.getAuxiliaryId().shortValue(), serializedBuffer.readUnsignedByte()); serializedBuffer.skipBytes(PADDING); Assert.assertEquals("Wrong Capabilities", message.getCapabilities(), createCapabilities(serializedBuffer.readInt())); Assert.assertEquals("Wrong reserved", message.getReserved().longValue(), serializedBuffer.readInt()); }