DittoMessageMapper extends AbstractMessageMapper { @Override public List<Adaptable> map(final ExternalMessage message) { final String payload = extractPayloadAsString(message); final JsonifiableAdaptable jsonifiableAdaptable = DittoJsonException.wrapJsonRuntimeException(() -> ProtocolFactory.jsonifiableAdaptableFromJson(JsonFactory.newObject(payload)) ); final DittoHeaders mergedHeaders = jsonifiableAdaptable.getDittoHeaders(); return singletonList( ProtocolFactory.newAdaptableBuilder(jsonifiableAdaptable).withHeaders(mergedHeaders).build()); }  @Override List<Adaptable> map(final ExternalMessage message); @Override List<ExternalMessage> map(final Adaptable adaptable); @Override JsonObject getDefaultOptions(); static final MappingContext CONTEXT; }
@Test public void mapMessage() { createValidIncomingMappings().forEach((in, out) -> assertThat(underTest.map(in)).isEqualTo(out)); }
@Test public void mapMessageFails() { createInvalidIncomingMappings().forEach((in, e) -> assertThatExceptionOfType(e.getClass()).isThrownBy( () -> underTest.map(in))); }
@Test public void mapAdaptable() { createValidOutgoingMappings().forEach((in, out) -> assertThat(underTest.map(in)).isEqualTo(out)); }
@Test public void mapAdaptableFails() { createInvalidOutgoingMappings().forEach((in, e) -> assertThatExceptionOfType(e.getClass()).isThrownBy( () -> underTest.map(in))); }