### Question:
OxmIpv6ExtHdrSerializer extends AbstractOxmMatchEntrySerializer { @Override public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); Ipv6ExthdrCase entryValue = (Ipv6ExthdrCase) entry.getMatchEntryValue(); Ipv6ExthdrFlags pseudoField = entryValue.getIpv6Exthdr().getPseudoField(); int bitmap = ByteBufUtils.fillBitMask(0, pseudoField.isNonext(), pseudoField.isEsp(), pseudoField.isAuth(), pseudoField.isDest(), pseudoField.isFrag(), pseudoField.isRouter(), pseudoField.isHop(), pseudoField.isUnrep(), pseudoField.isUnseq()); outBuffer.writeShort(bitmap); if (entry.isHasMask()) { outBuffer.writeBytes(entryValue.getIpv6Exthdr().getMask()); } }  @Override void serialize(MatchEntry entry, ByteBuf outBuffer);  }### Answer:
@Test public void testSerializeWithoutMask() { MatchEntryBuilder builder = prepareIpv6ExtHdrMatchEntry(false, new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true)); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); checkHeader(buffer, false); assertEquals("Wrong value", 358, buffer.readUnsignedShort()); assertTrue("Unexpected data", buffer.readableBytes() == 0); }
@Test public void testSerializeWithMask() { MatchEntryBuilder builder = prepareIpv6ExtHdrMatchEntry(true, new Ipv6ExthdrFlags(false, true, false, true, false, true, false, true, false)); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); checkHeader(buffer, true); assertEquals("Wrong value", 153, buffer.readUnsignedShort()); byte[] tmp = new byte[2]; buffer.readBytes(tmp); Assert.assertArrayEquals("Wrong mask", new byte[]{0, 15}, tmp); assertTrue("Unexpected data", buffer.readableBytes() == 0); }