### Question:
PortModInputMessageFactory implements OFSerializer<PortMod> { @Override public void serialize(final PortMod message, final ByteBuf outBuffer) { int index = outBuffer.writerIndex(); ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getPortNo().getValue().intValue()); outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_01); outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(message.getHwAddress())); outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_02); outBuffer.writeInt(createPortConfigBitmask(message.getConfig())); outBuffer.writeInt(createPortConfigBitmask(message.getMask())); outBuffer.writeInt(createPortFeaturesBitmask(message.getAdvertise())); outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_03); ByteBufUtils.updateOFHeaderLength(outBuffer, index); }  @Override void serialize(final PortMod message, final ByteBuf outBuffer);  }### Answer:
@Test public void testPortModInput() throws Exception { PortModInputBuilder builder = new PortModInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setPortNo(new PortNumber(9L)); builder.setHwAddress(new MacAddress("08:00:27:00:B0:EB")); builder.setConfig(new PortConfig(true, false, true, false)); builder.setMask(new PortConfig(false, true, false, true)); builder.setAdvertise(new PortFeatures(true, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false)); PortModInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); out.writeInt(1); out.writeZero(2); out.writeShort(3); portModFactory.serialize(message, out); out.readInt(); out.skipBytes(2); out.readShort(); BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH); Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedInt()); out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_01); byte[] address = new byte[6]; out.readBytes(address); Assert.assertEquals("Wrong MacAddress", message.getHwAddress().getValue(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue()); out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_02); Assert.assertEquals("Wrong config", message.getConfig(), createPortConfig(out.readInt())); Assert.assertEquals("Wrong mask", message.getMask(), createPortConfig(out.readInt())); Assert.assertEquals("Wrong advertise", message.getAdvertise(), createPortFeatures(out.readInt())); out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_03); }