### Question:
RoleReplyMessageFactory implements OFSerializer<RoleRequestOutput> { @Override public void serialize(RoleRequestOutput message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getRole().getIntValue()); outBuffer.writeZero(PADDING); outBuffer.writeLong(message.getGenerationId().longValue()); ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void serialize(RoleRequestOutput message, ByteBuf outBuffer);  }### Answer:
@Test public void testSerialize() throws Exception { RoleRequestOutputBuilder builder = new RoleRequestOutputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setRole(ControllerRole.forValue(0)); builder.setGenerationId(BigInteger.valueOf(1L)); RoleRequestOutput message = builder.build(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); factory.serialize(message, serializedBuffer); BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24); Assert.assertEquals("Wrong role", message.getRole().getIntValue(), ControllerRole.forValue((int) serializedBuffer.readUnsignedInt()).getIntValue()); serializedBuffer.skipBytes(PADDING); byte[] genId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; serializedBuffer.readBytes(genId); Assert.assertEquals("Wrong generation ID", message.getGenerationId(), new BigInteger(1, genId)); }
@Test public void testSerialize() { RoleReplyMessageFactory serializer = new RoleReplyMessageFactory(); SerializerRegistry registry = new NetIdeSerializerRegistryImpl(); registry.init(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(message, serializedBuffer); BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24); Assert.assertEquals("Wrong role", message.getRole().getIntValue(), ControllerRole.forValue((int) serializedBuffer.readUnsignedInt()).getIntValue()); serializedBuffer.skipBytes(PADDING); byte[] genId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; serializedBuffer.readBytes(genId); Assert.assertEquals("Wrong generation ID", message.getGenerationId(), new BigInteger(1, genId)); }