RunWithMetadataMessageEncoder implements MessageEncoder { @Override public void encode( Message message, ValuePacker packer ) throws IOException { checkArgument( message, RunWithMetadataMessage.class ); RunWithMetadataMessage runMessage = (RunWithMetadataMessage) message; packer.packStructHeader( 3, runMessage.signature() ); packer.pack( runMessage.query() ); packer.pack( runMessage.parameters() ); packer.pack( runMessage.metadata() ); }  @Override void encode( Message message, ValuePacker packer );  }
@Test void shouldFailToEncodeWrongMessage() { assertThrows( IllegalArgumentException.class, () -> encoder.encode( DISCARD_ALL, packer ) ); }