ImmutableAcknowledgements implements Acknowledgements { static ImmutableAcknowledgements of(final Collection<? extends Acknowledgement> acknowledgements, final DittoHeaders dittoHeaders) { argumentNotEmpty(acknowledgements, "acknowledgements"); return new ImmutableAcknowledgements(getEntityId(acknowledgements), acknowledgements, getCombinedStatusCode(acknowledgements), dittoHeaders); } 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 tryToGetInstanceWithNullAcknowledgements() { assertThatNullPointerException() .isThrownBy(() -> ImmutableAcknowledgements.of(null, KNOWN_DITTO_HEADERS)) .withMessage("The acknowledgements must not be null!") .withNoCause(); }
@Test public void tryToGetInstanceWithEmptyAcknowledgements() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ImmutableAcknowledgements.of(Collections.emptySet(), KNOWN_DITTO_HEADERS)) .withMessage("The argument 'acknowledgements' must not be empty!") .withNoCause(); }
@Test public void tryToGetInstanceWithAcknowledgementsWithDifferentEntityIds() { final ThingId otherEntityId = ThingId.of("com.example:flux-condensator"); final Acknowledgement otherAcknowledgement = ImmutableAcknowledgement.of(DittoAcknowledgementLabel.TWIN_PERSISTED, otherEntityId, KNOWN_STATUS_CODE, KNOWN_DITTO_HEADERS, null); final List<Acknowledgement> acknowledgements = Lists.list(KNOWN_ACK_1, otherAcknowledgement); assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ImmutableAcknowledgements.of(acknowledgements, KNOWN_DITTO_HEADERS)) .withMessage("The entity ID <%s> is not compatible with <%s>!", otherEntityId, KNOWN_ENTITY_ID) .withNoCause(); }
@Test public void tryToGetInstanceWithNullDittoHeaders() { assertThatNullPointerException() .isThrownBy(() -> ImmutableAcknowledgements.of(knownAcknowledgements, null)) .withMessage("The dittoHeaders must not be null!") .withNoCause(); }