AvroToJsonMessageConverter implements MessageConverter { @Override public Message convert(Message message, Topic topic) { return message() .fromMessage(message) .withContentType(ContentType.JSON) .withData(converter.convertToJson(recordWithoutMetadata(message.getData(), message.<Schema>getSchema().get().getSchema()))) .withNoSchema() .build(); } @Inject  AvroToJsonMessageConverter(); @Override Message convert(Message message, Topic topic);  }
@Test public void shouldConvertToJsonWithoutMetadata() throws IOException { Topic topic = topic("group.topic").build(); AvroUser avroUser = new AvroUser("Bob", 18, "blue"); Message source = message() .withData(avroUser.asBytes()) .withSchema(CompiledSchema.of(avroUser.getSchema(), 1, 0)) .withExternalMetadata(of()) .build(); AvroToJsonMessageConverter converter = new AvroToJsonMessageConverter(); Message target = converter.convert(source, topic); assertThatJson(new String(target.getData())).isEqualTo("{\"name\": \"Bob\", \"age\": 18, \"favoriteColor\": \"blue\"}"); }