EnumCodec implements Codec<T> { public void encode(T object, BitChannel channel, Resolver resolver) throws IOException { channel.write(size.eval(resolver), inverseMapping.get(object), byteOrder); } EnumCodec(Class<T> type, Map<Long, T> mapping,
                     Expression<Integer, Resolver> sizeExpr, ByteOrder endian); T decode(BitBuffer buffer, Resolver resolver, Builder builder); void encode(T object, BitChannel channel, Resolver resolver); Class<?>[] getTypes(); Expression<Integer, Resolver> getSize(); Class<?> getType(); CodecDescriptor getCodecDescriptor();  }
@Test public void shouldEncodeCorrectly() throws IOException { int nrbits = 2; EnumCodec<Direction> codec = new EnumCodec<Direction>(Direction.class, map, size, BigEndian); when(size.eval(org.mockito.Matchers.any(Resolver.class))).thenReturn(nrbits); codec.encode(Direction.Backward, channel, resolver); verify(channel).write(nrbits, 2L, BigEndian); verifyNoMoreInteractions(channel); verifyNoMoreInteractions(resolver); }