### Question:
OF10PortStatusMessageFactory implements OFSerializer<PortStatusMessage> { @Override public void serialize(final PortStatusMessage message, final ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING); outBuffer.writeShort(message.getPortNo().intValue()); outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(message.getHwAddr())); writeName(message.getName(), outBuffer); writePortConfig(message.getConfigV10(), outBuffer); writePortState(message.getStateV10(), outBuffer); writePortFeature(message.getCurrentFeaturesV10(), outBuffer); writePortFeature(message.getAdvertisedFeaturesV10(), outBuffer); writePortFeature(message.getSupportedFeaturesV10(), outBuffer); writePortFeature(message.getPeerFeaturesV10(), outBuffer); ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void serialize(final PortStatusMessage message, final ByteBuf outBuffer);  }### Answer:
@Test public void testSerialize() throws Exception { PortStatusMessageBuilder builder = new PortStatusMessageBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); builder.setReason(PortReason.forValue(1)); builder.setPortNo(1L); builder.setHwAddr(new MacAddress("94:de:80:a6:61:40")); builder.setName("Port name"); builder.setConfigV10(new PortConfigV10(true, false, true, false, true, false, true)); builder.setStateV10(new PortStateV10(true, false, true, false, true, false, true, false)); builder.setCurrentFeaturesV10( new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false)); builder.setAdvertisedFeaturesV10( new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false)); builder.setSupportedFeaturesV10( new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false)); builder.setPeerFeaturesV10( new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false)); PortStatusMessage message = builder.build(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); factory.serialize(message, serializedBuffer); BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 64); Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte()); serializedBuffer.skipBytes(7); Assert.assertEquals("Wrong port No", message.getPortNo().intValue(), serializedBuffer.readShort()); byte[] address = new byte[6]; serializedBuffer.readBytes(address); Assert.assertEquals("Wrong MacAddress", message.getHwAddr().getValue().toLowerCase(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase()); byte[] name = new byte[16]; serializedBuffer.readBytes(name); Assert.assertEquals("Wrong name", message.getName(), new String(name).trim()); Assert.assertEquals("Wrong config", message.getConfigV10(), createPortConfig(serializedBuffer.readInt())); Assert.assertEquals("Wrong state", message.getStateV10(), createPortState(serializedBuffer.readInt())); Assert.assertEquals("Wrong current", message.getCurrentFeaturesV10(), createPortFeatures(serializedBuffer.readInt())); Assert.assertEquals("Wrong advertised", message.getAdvertisedFeaturesV10(), createPortFeatures(serializedBuffer.readInt())); Assert.assertEquals("Wrong supported", message.getSupportedFeaturesV10(), createPortFeatures(serializedBuffer.readInt())); Assert.assertEquals("Wrong peer", message.getPeerFeaturesV10(), createPortFeatures(serializedBuffer.readInt())); }