ImmutableAcknowledgements implements Acknowledgements { @Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) { final Predicate<JsonField> predicate = schemaVersion.and(thePredicate); final JsonObject acksJsonObject = acknowledgementsToJsonWithDisambiguation(schemaVersion, thePredicate, Acknowledgement::toJson); return JsonObject.newBuilder() .set(JsonFields.ENTITY_ID, entityId.toString(), predicate) .set(JsonFields.ENTITY_TYPE, getEntityType().toString(), predicate) .set(JsonFields.STATUS_CODE, statusCode.toInt(), predicate) .set(JsonFields.ACKNOWLEDGEMENTS, acksJsonObject, predicate) .set(JsonFields.DITTO_HEADERS, dittoHeaders.toJson(), predicate) .build(); } private  ImmutableAcknowledgements(final EntityIdWithType entityId,
            final Collection<? extends Acknowledgement> acknowledgements,
            final HttpStatusCode statusCode,
            final DittoHeaders dittoHeaders); @Override HttpStatusCode getStatusCode(); @Override Set<AcknowledgementLabel> getMissingAcknowledgementLabels(); @Override Set<Acknowledgement> getSuccessfulAcknowledgements(); @Override Set<Acknowledgement> getFailedAcknowledgements(); @Override Optional<Acknowledgement> getAcknowledgement(final AcknowledgementLabel acknowledgementLabel); @Override Iterator<Acknowledgement> iterator(); @Override int getSize(); @Override boolean isEmpty(); @Override Stream<Acknowledgement> stream(); @Override DittoHeaders getDittoHeaders(); @Override ImmutableAcknowledgements setDittoHeaders(final DittoHeaders dittoHeaders); @Override EntityIdWithType getEntityId(); @Override EntityType getEntityType(); @Override String getType(); @Override Optional<JsonValue> getEntity(final JsonSchemaVersion schemaVersion); @Override JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate); @Override boolean equals(@Nullable final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void toJsonReturnsExpected() { final JsonObject actual = knownAcknowledgementsWith2Acks.toJson(); assertThat(actual).isEqualTo(knownJsonRepresentation); }