### Question:
OxmMetadataSerializer extends AbstractOxmMatchEntrySerializer { @Override public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); MetadataCase entryValue = (MetadataCase) entry.getMatchEntryValue(); outBuffer.writeBytes(entryValue.getMetadata().getMetadata()); if (entry.isHasMask()) { writeMask(entryValue.getMetadata().getMask(), outBuffer, EncodeConstants.SIZE_OF_LONG_IN_BYTES); } }  @Override void serialize(MatchEntry entry, ByteBuf outBuffer);  }### Answer:
@Test public void testSerializeWithoutMask() { MatchEntryBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); checkHeader(buffer, false); byte[] address = new byte[8]; buffer.readBytes(address); Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, address); assertTrue("Unexpected data", buffer.readableBytes() == 0); }
@Test public void testSerializeWithMask() { MatchEntryBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); checkHeader(buffer, true); byte[] address = new byte[8]; buffer.readBytes(address); Assert.assertArrayEquals("Wrong address", new byte[]{8, 9, 10, 11, 12, 13, 14, 15}, address); byte[] tmp = new byte[8]; buffer.readBytes(tmp); Assert.assertArrayEquals("Wrong mask", new byte[]{30, 30, 25, 25, 15, 15, 0, 0}, tmp); assertTrue("Unexpected data", buffer.readableBytes() == 0); }