@Test
public void appliesThingCreatedWithMetadata() {

    final ThingCreatedStrategy strategy = new ThingCreatedStrategy();
    final DittoHeaders dittoHeaders = DittoHeaders.newBuilder()
            .putMetadata(MetadataHeaderKey.of(JsonPointer.of("*/answer")), JsonValue.of(42))
            .build();
    final JsonObject metadataJson = JsonObject.newBuilder()
            .set("answer", 42)
            .build();
    final ThingCreated event = ThingCreated.of(THING, REVISION, TIMESTAMP, dittoHeaders, Metadata.newBuilder()
            .set(Thing.JsonFields.ID.getPointer(), metadataJson)
            .build());
    final Thing thingWithEventApplied = strategy.handle(event, null, NEXT_REVISION);
    final Thing expected = THING.toBuilder()
            .setLifecycle(ThingLifecycle.ACTIVE)
            .setRevision(NEXT_REVISION)
            .setModified(TIMESTAMP)
            .setCreated(TIMESTAMP)
            .setMetadata(Metadata.newBuilder()
                    .set(Thing.JsonFields.ID.getPointer(), metadataJson)
                    .build())
            .build();
    assertThat(thingWithEventApplied).isEqualTo(expected);
}