@Test void should_produce_camel_case_JSON() { Message message = converter.toMessage(CustomerAddedEvent.sample(), null); String json = new String(message.getBody(), StandardCharsets.UTF_8); assertThat(json, matchesPattern(".*\"customerId\":1,.*")); }
@Override public @NonNull Message toMessage( @NonNull Object object, @Nullable MessageProperties messagePropertiesArg) throws MessageConversionException { logger.debug("Converting {} to JSON", object); try { byte[] bytes = gson.toJson(object).getBytes(StandardCharsets.UTF_8.name()); MessageProperties messageProperties = messagePropertiesArg; if (messageProperties == null) { messageProperties = new MessageProperties(); } messageProperties.setAppId(settings.getApplicationName()); messageProperties.setContentEncoding(StandardCharsets.UTF_8.name()); messageProperties.setContentLength(bytes.length); messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON); messageProperties.setCorrelationId(CorrelationIdHolder.get()); messageProperties.setMessageId(UUID.randomUUID().toString()); messageProperties.setType(object.getClass().getName()); messageProperties.setTimestamp(Date.from(clock.instant())); return new Message(bytes, messageProperties); } catch (Exception e) { throw new MessageConversionException("Cannot convert to JSON", e); } }
CodekvastJsonMessageConverter implements MessageConverter { @Override public @NonNull Message toMessage( @NonNull Object object, @Nullable MessageProperties messagePropertiesArg) throws MessageConversionException { logger.debug("Converting {} to JSON", object); try { byte[] bytes = gson.toJson(object).getBytes(StandardCharsets.UTF_8.name()); MessageProperties messageProperties = messagePropertiesArg; if (messageProperties == null) { messageProperties = new MessageProperties(); } messageProperties.setAppId(settings.getApplicationName()); messageProperties.setContentEncoding(StandardCharsets.UTF_8.name()); messageProperties.setContentLength(bytes.length); messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON); messageProperties.setCorrelationId(CorrelationIdHolder.get()); messageProperties.setMessageId(UUID.randomUUID().toString()); messageProperties.setType(object.getClass().getName()); messageProperties.setTimestamp(Date.from(clock.instant())); return new Message(bytes, messageProperties); } catch (Exception e) { throw new MessageConversionException("Cannot convert to JSON", e); } } }
CodekvastJsonMessageConverter implements MessageConverter { @Override public @NonNull Message toMessage( @NonNull Object object, @Nullable MessageProperties messagePropertiesArg) throws MessageConversionException { logger.debug("Converting {} to JSON", object); try { byte[] bytes = gson.toJson(object).getBytes(StandardCharsets.UTF_8.name()); MessageProperties messageProperties = messagePropertiesArg; if (messageProperties == null) { messageProperties = new MessageProperties(); } messageProperties.setAppId(settings.getApplicationName()); messageProperties.setContentEncoding(StandardCharsets.UTF_8.name()); messageProperties.setContentLength(bytes.length); messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON); messageProperties.setCorrelationId(CorrelationIdHolder.get()); messageProperties.setMessageId(UUID.randomUUID().toString()); messageProperties.setType(object.getClass().getName()); messageProperties.setTimestamp(Date.from(clock.instant())); return new Message(bytes, messageProperties); } catch (Exception e) { throw new MessageConversionException("Cannot convert to JSON", e); } }  }
CodekvastJsonMessageConverter implements MessageConverter { @Override public @NonNull Message toMessage( @NonNull Object object, @Nullable MessageProperties messagePropertiesArg) throws MessageConversionException { logger.debug("Converting {} to JSON", object); try { byte[] bytes = gson.toJson(object).getBytes(StandardCharsets.UTF_8.name()); MessageProperties messageProperties = messagePropertiesArg; if (messageProperties == null) { messageProperties = new MessageProperties(); } messageProperties.setAppId(settings.getApplicationName()); messageProperties.setContentEncoding(StandardCharsets.UTF_8.name()); messageProperties.setContentLength(bytes.length); messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON); messageProperties.setCorrelationId(CorrelationIdHolder.get()); messageProperties.setMessageId(UUID.randomUUID().toString()); messageProperties.setType(object.getClass().getName()); messageProperties.setTimestamp(Date.from(clock.instant())); return new Message(bytes, messageProperties); } catch (Exception e) { throw new MessageConversionException("Cannot convert to JSON", e); } }  @Override @NonNull Message toMessage(
      @NonNull Object object, @Nullable MessageProperties messagePropertiesArg); @Override @NonNull Object fromMessage(@NonNull Message message); }
CodekvastJsonMessageConverter implements MessageConverter { @Override public @NonNull Message toMessage( @NonNull Object object, @Nullable MessageProperties messagePropertiesArg) throws MessageConversionException { logger.debug("Converting {} to JSON", object); try { byte[] bytes = gson.toJson(object).getBytes(StandardCharsets.UTF_8.name()); MessageProperties messageProperties = messagePropertiesArg; if (messageProperties == null) { messageProperties = new MessageProperties(); } messageProperties.setAppId(settings.getApplicationName()); messageProperties.setContentEncoding(StandardCharsets.UTF_8.name()); messageProperties.setContentLength(bytes.length); messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON); messageProperties.setCorrelationId(CorrelationIdHolder.get()); messageProperties.setMessageId(UUID.randomUUID().toString()); messageProperties.setType(object.getClass().getName()); messageProperties.setTimestamp(Date.from(clock.instant())); return new Message(bytes, messageProperties); } catch (Exception e) { throw new MessageConversionException("Cannot convert to JSON", e); } }  @Override @NonNull Message toMessage(
      @NonNull Object object, @Nullable MessageProperties messagePropertiesArg); @Override @NonNull Object fromMessage(@NonNull Message message);  }