@SuppressWarnings("OptionalUsedAsFieldOrParameterType") private <T> DittoHeadersAssert assertContains(final Optional<T> actual, final T expected, final String entityName) { final String errorMessage = MessageFormat.format("Expected {0} of DittoHeaders to be \n<%s> but it was\n<%s>", entityName); Assertions.assertThat(actual) .overridingErrorMessage(errorMessage, expected, actual.orElse(null)) .contains(expected); return myself; }
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") private <T> DittoHeadersAssert assertIsEmpty(final Optional<T> actual, final String entityName) { final String errorMessage = MessageFormat.format("Expected DittoHeaders not to have a {0} but it had <%s>", entityName); Assertions.assertThat(actual) .overridingErrorMessage(errorMessage, actual.orElse(null)) .isEmpty(); return myself; }
@Nonnull public CompilationAssert hasGeneratedSourceFile(@Nonnull String fqcn) { isNotNull(); final String qualifiedName = Stream.of(fqcn.split("\\.")).collect(joining("/", "", ".java")); final Optional<JavaFileObject> actual = this.actual.generatedSourceFile(qualifiedName); assertThat(actual) .overridingErrorMessage("Generated source file <%s> was not found", fqcn) .isNotEmpty(); return this; }
public ThingModifyCommandResponseAssert withEntity(final JsonValue expectedEntity) { isNotNull(); final Optional<JsonValue> actualEntity = actual.getEntity(); Assertions.assertThat(actualEntity) .overridingErrorMessage("Expected ThingModifyCommandResponse to have entity\n<%s> but it had\n<%s>", expectedEntity, actualEntity.orElse(null)) .contains(expectedEntity); return myself; }
public S hasTimestamp(final Instant expectedTimestamp) { isNotNull(); @SuppressWarnings("unchecked") final Optional<Instant> actualTimestamp = actual.getTimestamp(); Assertions.assertThat(actualTimestamp) .overridingErrorMessage("Expected Event to have timestamp\n<%s> but it had\n<%s>", expectedTimestamp, actualTimestamp.orElse(null)) .contains(expectedTimestamp); return myself; }
public ThingModifyCommandResponseAssert withoutEntity() { isNotNull(); final Optional<JsonValue> actualEntity = actual.getEntity(); Assertions.assertThat(actualEntity) .overridingErrorMessage("Expected ThingModifyCommandResponse not to have an entity but it had\n<%s>", actualEntity.orElse(null)) .isEmpty(); return myself; }
public ThingAssert hasNoAttributes() { isNotNull(); final Optional<Attributes> attributesOptional = actual.getAttributes(); assertThat(attributesOptional) // .overridingErrorMessage("Expected Thing not to have any attributes but it had <%s>", attributesOptional.orElse(null)) // .isEmpty(); return this; }
public ThingAssert hasNoFeatures() { isNotNull(); final Optional<Features> featuresOptional = actual.getFeatures(); assertThat(featuresOptional) // .overridingErrorMessage("Expected Thing not to have any features but it had <%s>", featuresOptional.orElse(null)) // .isEmpty(); return this; }
public ThingAssert hasModified(final Instant expectedmodified) { isNotNull(); final Optional<Instant> modifiedOptional = actual.getModified(); assertThat(modifiedOptional) // .overridingErrorMessage("Expected Thing modified to be \n<%s> but it was \n<%s>", expectedmodified, modifiedOptional.orElse(null)) // .contains(expectedmodified); return this; }
public S hasEntity(final JsonValue expectedEntity, final JsonSchemaVersion schemaVersion) { isNotNull(); final Optional<JsonValue> actualEntity = actual.getEntity(schemaVersion); Assertions.assertThat(actualEntity) .overridingErrorMessage("Expected Event to have entity\n<%s> for schema version <%s> but it had\n<%s>", expectedEntity, schemaVersion, actualEntity.orElse(null)) .contains(expectedEntity); return myself; }
public ThingAssert hasRevision(final ThingRevision expectedRevision) { isNotNull(); final Optional<ThingRevision> revisionOptional = actual.getRevision(); assertThat(revisionOptional) // .overridingErrorMessage("Expected Thing revision to be \n<%s> but it was \n<%s>", expectedRevision, revisionOptional.orElse(null)) // .contains(expectedRevision); return this; }
public S hasNoEntity() { isNotNull(); final Optional<JsonValue> actualEntity = actual.getEntity(); Assertions.assertThat(actualEntity) .overridingErrorMessage("Expected Event to have no entity but it had\n<%s>", actualEntity.orElse(null)) .isEmpty(); return myself; }
public ThingAssert hasFeatures(final Features expectedFeatures) { isNotNull(); assertThat(actual.getFeatures()) // .overridingErrorMessage("Expected Thing Features to be <%s> but it did not", expectedFeatures) // .contains(expectedFeatures); return this; }
public ThingAssert hasAttributes(final Attributes expectedAttributes) { isNotNull(); assertThat(actual.getAttributes()) // .overridingErrorMessage("Expected Thing Attributes to be <%s> but it did not", expectedAttributes) // .contains(expectedAttributes); return this; }
/** */ public ThingAssert isModified() { isNotNull(); final Optional<Instant> actualModified = actual.getModified(); assertThat(actualModified) .overridingErrorMessage("Expected Thing to be modified but it was not") .isPresent(); return this; }
public DittoHeadersAssert hasCorrelationId() { isNotNull(); final Optional<String> actualCorrelationId = actual.getCorrelationId(); Assertions.assertThat(actualCorrelationId) .overridingErrorMessage("Expected DittoHeaders to have a correlation-id but it had not") .isPresent(); return myself; }
public S withEntity(final JsonValue expectedEntity) { isNotNull(); final Optional<JsonValue> actualEntity = actual.getEntity(); if (null != expectedEntity) { Assertions.assertThat(actualEntity) .overridingErrorMessage("Expected Command to have entity\n<%s> but it had\n<%s>", expectedEntity, actualEntity.orElse(null)) .contains(expectedEntity); return myself; } return withoutEntity(); }
public PolicyAssert hasSubjectFor(final Label label, final SubjectId subjectId) { isNotNull(); hasLabel(label); final PolicyEntry policyEntry = actual.getEntryFor(label).get(); assertThat(policyEntry.getSubjects().getSubject(subjectId)).isPresent() // .overridingErrorMessage( "Expected Label <%s> to contain Subject for SubjectId \n<%s> " + "but did not: \n<%s>", label, subjectId, policyEntry.getSubjects()); return this; }
public PolicyAssert doesNotHaveSubjectFor(final Label label, final SubjectId subjectId) { isNotNull(); hasLabel(label); final PolicyEntry policyEntry = actual.getEntryFor(label).get(); assertThat(policyEntry.getSubjects().getSubject(subjectId)).isEmpty() // .overridingErrorMessage( "Expected Label <%s> to NOT contain Subject for SubjectId \n<%s> " + "but it did: \n<%s>", label, subjectId, policyEntry.getSubjects()); return this; }
public PolicyAssert hasResourceFor(final Label label, final ResourceKey resourceKey) { isNotNull(); hasLabel(label); final PolicyEntry policyEntry = actual.getEntryFor(label).get(); assertThat(policyEntry.getResources().getResource(resourceKey)).isPresent() // .overridingErrorMessage( "Expected Label <%s> to contain Resource for path \n<%s> " + "but did not: \n<%s>", label, resourceKey, policyEntry.getResources()); return this; }