JsonObjectBuilder metadataBuilder = JsonObjects.createObjectBuilderWithFilter(metadata.asJsonObject(),
x -> !Arrays.asList(ID, NAME, CAUSATION).contains(x));
final JsonObject jsonObject = metadataBuilder
.add(ID, UUID.randomUUID().toString())
.add(NAME, name)
<BUG>.add(CAUSATION, createCausation(metadata))
.build();</BUG>
return metadataFrom(jsonObject);
}
private JsonArray createCausation(final Metadata metadata) {

JsonObjectBuilder metadataBuilder = JsonObjects.createObjectBuilderWithFilter(metadata.asJsonObject(),
x -> !Arrays.asList(ID, NAME, CAUSATION).contains(x));
final JsonObject jsonObject = metadataBuilder
.add(ID, UUID.randomUUID().toString())
.add(NAME, name)
.add(CAUSATION, createCausation(metadata))
.add(CREATED_AT, ZonedDateTimes.toString(clock.now()))
.build();
return metadataFrom(jsonObject);
}
private JsonArray createCausation(final Metadata metadata) {
