JsonMessageContentWrapper { public UnwrappedMessageContent unwrapContent(byte[] json) { if (isWrapped(json)) { return unwrapMessageContent(json); } else { UUID id = UUID.randomUUID(); LOGGER.warn("Unwrapped message read by consumer (size={}, id={}).", json.length, id.toString()); return new UnwrappedMessageContent(new MessageMetadata(1L, id.toString(), ImmutableMap.of()), json); } } @Inject  JsonMessageContentWrapper(ConfigFactory config, ObjectMapper mapper);  JsonMessageContentWrapper(String contentRootName, String metadataRootName, ObjectMapper mapper); UnwrappedMessageContent unwrapContent(byte[] json);  }
@Test public void shouldTolerateUnwrappingUnwrappedMessage() { UnwrappedMessageContent result = contentWrapper.unwrapContent(CONTENT); assertThat(result.getMessageMetadata().getId()).isNotEmpty(); assertThat(result.getMessageMetadata().getTimestamp()).isEqualTo(1L); }
@Ignore @Test(expected = UnwrappingException.class) public void shouldThrowExceptionWhenMetadataNotFound() { contentWrapper.unwrapContent(CONTENT); }