@Test
public void serializesGivenByteBuf() throws IOException {

    // given
    ByteBufSerializer serializer = new ByteBufSerializer();
    JsonGenerator jsonGenerator = mock(JsonGenerator.class);
    ByteBuf byteBuf = mock(ByteBuf.class);
    when(byteBuf.writerIndex()).thenReturn(10);
    // when
    serializer.serialize(byteBuf, jsonGenerator, mock(SerializerProvider.class));
    // then
    verify(byteBuf).resetReaderIndex();
    verify(jsonGenerator).writeBinary(any(), eq(10));
}