@Test
public void testBinaryJavascriptOutgoingMapping() {

    final ThingId thingId = ThingId.of("org.eclipse.ditto:foo-bar-binary");
    final String correlationId = UUID.randomUUID().toString();
    final Thing newThing = Thing.newBuilder()
            .setId(thingId)
            .setAttributes(Attributes.newBuilder().set("foo", "bar").build())
            .build();
    final CreateThing createThing =
            CreateThing.of(newThing, null, DittoHeaders.newBuilder().correlationId(correlationId).build());
    final Adaptable adaptable = DittoProtocolAdapter.newInstance().toAdaptable(createThing);
    assertThat(javaScriptRhinoMapperBinary.map(adaptable)).allSatisfy(rawMessage -> {
        System.out.println(rawMessage);
        final long startTs = System.nanoTime();
        System.out.println(
                "testBinaryJavascriptOutgoingMapping Duration: " + (System.nanoTime() - startTs) / 1_000_000.0 +
                        "ms");
        assertThat(rawMessage.findContentType()).contains(CONTENT_TYPE_BINARY);
        assertThat(rawMessage.findHeader(HEADER_CORRELATION_ID)).contains(correlationId);
        assertThat(rawMessage.isTextMessage()).isFalse();
        assertThat(rawMessage.isBytesMessage()).isTrue();
        assertThat(rawMessage.getTextPayload()).isEmpty();
        assertThat(rawMessage.getBytePayload()).map(JavaScriptMessageMapperRhinoTest::byteBuffer2String)
                .contains(thingId.toString());
    });
}