### Question:
QueryCommandPacket extends AbstractCommandPacket { @Override public ByteBuf toByteBuf() { ByteBuf result = ByteBufAllocator.DEFAULT.heapBuffer(); DataTypesCodec.writeByte(getCommand(), result); DataTypesCodec.writeBytes(queryString.getBytes(StandardCharsets.UTF_8), result); return result; } QueryCommandPacket(); @Override ByteBuf toByteBuf();  }### Answer:
@Test public void assertToByteBuf() { QueryCommandPacket queryCommandPacket = new QueryCommandPacket(); queryCommandPacket.setQueryString("SELECT 1"); assertThat(queryCommandPacket.toByteBuf(), is(mockExpectedByteBuf())); }