ImmutableAcknowledgements implements Acknowledgements { @Override public Optional<JsonValue> getEntity(final JsonSchemaVersion schemaVersion) { final int acknowledgementsSize = acknowledgements.size(); final Optional<JsonValue> result; if (0 == acknowledgementsSize) { result = Optional.empty(); } else if (1 == acknowledgementsSize) { final Acknowledgement soleAcknowledgement = acknowledgements.get(0); result = soleAcknowledgement.getEntity(schemaVersion); } else { result = Optional.of(acknowledgementsEntitiesToJson(schemaVersion)); } return result; } 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 getEntityReturnsExpected() { final Optional<JsonValue> actual = knownAcknowledgementsWith2Acks.getEntity(); assertThat(actual).contains(knownAcknowledgementsGetEntityJsonRepresentation); }
@Test public void getEntityWith2AcksReturnsExpected() { final Optional<JsonValue> actual = knownAcknowledgementsWith2Acks.getEntity(JsonSchemaVersion.LATEST); assertThat(actual).contains(knownAcknowledgementsGetEntityJsonRepresentation); }