### Question:
HeaderPacket implements Packet { @Override public ByteBuf toByteBuf() { ByteBuf result = ByteBufAllocator.DEFAULT.heapBuffer(4); result.writeByte((byte) (packetBodyLength & 0xFF)); result.writeByte((byte) (packetBodyLength >>> 8)); result.writeByte((byte) (packetBodyLength >>> 16)); result.writeByte(getPacketSequenceNumber()); return result; }  @Override ByteBuf toByteBuf(); @Override void fromByteBuf(final ByteBuf data);  }### Answer:
@Test public void assertToByteBuf() { HeaderPacket headerPacket = new HeaderPacket(); headerPacket.setPacketSequenceNumber((byte) 1); headerPacket.setPacketBodyLength(PACKET_LENGTH); assertThat(headerPacket.toByteBuf(), is(getHeaderPacketByteBuf())); }