### Question:
MeterModInputMessageFactory implements OFSerializer<MeterModInput>,
        SerializerRegistryInjector { @Override public void serialize(final MeterModInput message, final ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeShort(message.getCommand().getIntValue()); outBuffer.writeShort(createMeterFlagsBitmask(message.getFlags())); outBuffer.writeInt(message.getMeterId().getValue().intValue()); serializeBands(message.getBands(), outBuffer); ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void serialize(final MeterModInput message, final ByteBuf outBuffer); @Override void injectSerializerRegistry(final SerializerRegistry serializerRegistry);  }### Answer:
@Test public void testMeterModInputMessage() throws Exception { MeterModInputBuilder builder = new MeterModInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setCommand(MeterModCommand.forValue(1)); builder.setFlags(new MeterFlags(false, true, true, false)); builder.setMeterId(new MeterId(2248L)); builder.setBands(createBandsList()); MeterModInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); meterModFactory.serialize(message, out); BufferHelper.checkHeaderV13(out, (byte) 29, 48); Assert.assertEquals("Wrong meterModCommand", message.getCommand().getIntValue(), out.readUnsignedShort()); Assert.assertEquals("Wrong meterFlags", message.getFlags(), decodeMeterModFlags(out.readShort())); Assert.assertEquals("Wrong meterId", message.getMeterId().getValue().intValue(), out.readUnsignedInt()); Assert.assertEquals("Wrong bands", message.getBands(), decodeBandsList(out)); }
@Test public void testMeterModInputMessageWithNoBands() throws Exception { MeterModInputBuilder builder = new MeterModInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setCommand(MeterModCommand.forValue(1)); builder.setFlags(new MeterFlags(false, true, true, false)); builder.setMeterId(new MeterId(2248L)); builder.setBands(null); MeterModInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); meterModFactory.serialize(message, out); BufferHelper.checkHeaderV13(out, (byte) 29, 16); Assert.assertEquals("Wrong meterModCommand", message.getCommand().getIntValue(), out.readUnsignedShort()); Assert.assertEquals("Wrong meterFlags", message.getFlags(), decodeMeterModFlags(out.readShort())); Assert.assertEquals("Wrong meterId", message.getMeterId().getValue().intValue(), out.readUnsignedInt()); Assert.assertTrue("Unexpected data", out.readableBytes() == 0); }