BeginMessageEncoder implements MessageEncoder { @Override public void encode( Message message, ValuePacker packer ) throws IOException { checkArgument( message, BeginMessage.class ); BeginMessage beginMessage = (BeginMessage) message; packer.packStructHeader( 1, beginMessage.signature() ); packer.pack( beginMessage.metadata() ); }  @Override void encode( Message message, ValuePacker packer );  }
@Test void shouldFailToEncodeWrongMessage() { assertThrows( IllegalArgumentException.class, () -> encoder.encode( RESET, packer ) ); }