@Test
public void testEncoding() throws IOException {

    SlicingCodec<String> codec = new SlicingCodec(wrapped, sizeExpr);
    when(sizeExpr.eval(resolver)).thenReturn(3);
    codec.encode("DONE", channel, resolver);
    ArgumentCaptor<BitChannel> bitChannelCaptor = ArgumentCaptor.forClass(BitChannel.class);
    verify(wrapped).encode(eq("DONE"), bitChannelCaptor.capture(), eq(resolver));
    verify(sizeExpr).eval(resolver);
    assertThat(bitChannelCaptor.getValue(), instanceOf(BoundedBitChannel.class));
    verifyNoMoreInteractions(wrapped, sizeExpr, resolver);
}