ByteBufferConverter implements Converter, HeaderConverter { @Override public SchemaAndValue toConnectData(String topic, byte[] value) { return new SchemaAndValue(Schema.OPTIONAL_BYTES_SCHEMA, value == null ? null : ByteBuffer.wrap(value)); }  @Override ConfigDef config(); @Override void configure(Map<String, ?> configs); @Override void configure(Map<String, ?> configs, boolean isKey); @Override byte[] fromConnectData(String topic, Schema schema, Object value); @Override SchemaAndValue toConnectData(String topic, byte[] value); @Override byte[] fromConnectHeader(String topic, String headerKey, Schema schema, Object value); @Override SchemaAndValue toConnectHeader(String topic, String headerKey, byte[] value); @Override void close(); static final String DELEGATE_CONVERTER_TYPE; }
@Test public void shouldConvertToConnectData() { SchemaAndValue schemaAndValue = converter.toConnectData(TOPIC, SAMPLE_BYTES); assertThat(schemaAndValue.schema()).isEqualTo(Schema.OPTIONAL_BYTES_SCHEMA); assertThat(schemaAndValue.value()).isEqualTo(ByteBuffer.wrap(SAMPLE_BYTES)); }
@Test public void shouldConvertToConnectDataForNullValue() { SchemaAndValue schemaAndValue = converter.toConnectData(TOPIC, null); assertThat(schemaAndValue.schema()).isEqualTo(Schema.OPTIONAL_BYTES_SCHEMA); assertThat(schemaAndValue.value()).isNull(); }