SubjectCreated extends AbstractPolicyEvent<SubjectCreated> implements PolicyEvent<SubjectCreated> { @Deprecated public static SubjectCreated of(final String policyId, final Label label, final Subject subject, final long revision, final DittoHeaders dittoHeaders) { return of(PolicyId.of(policyId), label, subject, revision, dittoHeaders); } private  SubjectCreated(final PolicyId policyId,
            final Label label,
            final Subject subject,
            final long revision,
            @Nullable final Instant timestamp,
            final DittoHeaders dittoHeaders); @Deprecated static SubjectCreated of(final String policyId,
            final Label label,
            final Subject subject,
            final long revision,
            final DittoHeaders dittoHeaders); static SubjectCreated of(final PolicyId policyId,
            final Label label,
            final Subject subject,
            final long revision,
            final DittoHeaders dittoHeaders); @Deprecated static SubjectCreated of(final String policyId,
            final Label label,
            final Subject subject,
            final long revision,
            @Nullable final Instant timestamp,
            final DittoHeaders dittoHeaders); static SubjectCreated of(final PolicyId policyId,
            final Label label,
            final Subject subject,
            final long revision,
            @Nullable final Instant timestamp,
            final DittoHeaders dittoHeaders); static SubjectCreated fromJson(final String jsonString, final DittoHeaders dittoHeaders); static SubjectCreated fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders); Label getLabel(); Subject getSubject(); @Override Optional<JsonValue> getEntity(final JsonSchemaVersion schemaVersion); @Override JsonPointer getResourcePath(); @Override SubjectCreated setRevision(final long revision); @Override SubjectCreated setDittoHeaders(final DittoHeaders dittoHeaders); @SuppressWarnings("squid:S109") @Override int hashCode(); @SuppressWarnings("squid:MethodCyclomaticComplexity") @Override boolean equals(@Nullable final Object o); @Override String toString(); static final String NAME; static final String TYPE; }
@Test(expected = PolicyIdInvalidException.class) public void tryToCreateInstanceWithNullPolicyIdString() { SubjectCreated.of((String) null, TestConstants.Policy.LABEL, TestConstants.Policy.SUBJECT, TestConstants.Policy.REVISION_NUMBER, TestConstants.EMPTY_DITTO_HEADERS); }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullPolicyId() { SubjectCreated.of((PolicyId) null, TestConstants.Policy.LABEL, TestConstants.Policy.SUBJECT, TestConstants.Policy.REVISION_NUMBER, TestConstants.EMPTY_DITTO_HEADERS); }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullLabel() { SubjectCreated.of(TestConstants.Policy.POLICY_ID, null, TestConstants.Policy.SUBJECT, TestConstants.Policy.REVISION_NUMBER, TestConstants.EMPTY_DITTO_HEADERS); }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullSubject() { SubjectCreated.of(TestConstants.Policy.POLICY_ID, TestConstants.Policy.LABEL, null, TestConstants.Policy.REVISION_NUMBER, TestConstants.EMPTY_DITTO_HEADERS); }
@Test public void toJsonReturnsExpected() { final SubjectCreated underTest = SubjectCreated.of(TestConstants.Policy.POLICY_ID, TestConstants.Policy.LABEL, TestConstants.Policy.SUBJECT, TestConstants.Policy.REVISION_NUMBER, TestConstants.TIMESTAMP, TestConstants.EMPTY_DITTO_HEADERS); final JsonObject actualJson = underTest.toJson(FieldType.regularOrSpecial()); assertThat(actualJson).isEqualTo(KNOWN_JSON); }