RetrieveSubject extends AbstractCommand<RetrieveSubject> implements PolicyQueryCommand<RetrieveSubject> { @Deprecated public static RetrieveSubject of(final String policyId, final Label label, final SubjectId subjectId, final DittoHeaders dittoHeaders) { return of(PolicyId.of(policyId), label, subjectId, dittoHeaders); } private  RetrieveSubject(final PolicyId policyId,
            final Label label,
            final SubjectId subjectId,
            final DittoHeaders dittoHeaders); @Deprecated static RetrieveSubject of(final String policyId,
            final Label label,
            final SubjectId subjectId,
            final DittoHeaders dittoHeaders); static RetrieveSubject of(final PolicyId policyId,
            final Label label,
            final SubjectId subjectId,
            final DittoHeaders dittoHeaders); static RetrieveSubject fromJson(final String jsonString, final DittoHeaders dittoHeaders); static RetrieveSubject fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders); Label getLabel(); SubjectId getSubjectId(); @Override PolicyId getEntityId(); @Override JsonPointer getResourcePath(); @Override RetrieveSubject setDittoHeaders(final DittoHeaders dittoHeaders); @SuppressWarnings({"squid:MethodCyclomaticComplexity", "squid:S1067", "OverlyComplexMethod"}) @Override boolean equals(@Nullable final Object obj); @SuppressWarnings("squid:S109") @Override int hashCode(); @Override String toString(); static final String NAME; static final String TYPE; }
@Test public void tryToCreateInstanceWithNullPolicyId() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> RetrieveSubject.of((PolicyId) null, TestConstants.Policy.LABEL, TestConstants.Policy.SUBJECT_ID, EMPTY_DITTO_HEADERS)); }
@Test public void tryToCreateInstanceWithNullPolicyIdString() { assertThatExceptionOfType(PolicyIdInvalidException.class) .isThrownBy(() -> RetrieveSubject.of((String) null, TestConstants.Policy.LABEL, TestConstants.Policy.SUBJECT_ID, EMPTY_DITTO_HEADERS)); }
@Test public void tryToCreateInstanceWithInvalidPolicyId() { assertThatExceptionOfType(PolicyIdInvalidException.class) .isThrownBy(() -> RetrieveSubject.of("undefined", TestConstants.Policy.LABEL, TestConstants.Policy.SUBJECT_ID, EMPTY_DITTO_HEADERS)); }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullLabel() { RetrieveSubject.of(TestConstants.Policy.POLICY_ID, null, TestConstants.Policy.SUBJECT_ID, EMPTY_DITTO_HEADERS); }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullSubjectId() { RetrieveSubject.of(TestConstants.Policy.POLICY_ID, TestConstants.Policy.LABEL, null, EMPTY_DITTO_HEADERS); }
@Test public void toJsonReturnsExpected() { final RetrieveSubject underTest = RetrieveSubject.of(TestConstants.Policy.POLICY_ID, TestConstants.Policy.LABEL, TestConstants.Policy.SUBJECT_ID, EMPTY_DITTO_HEADERS); final JsonObject actualJson = underTest.toJson(FieldType.regularOrSpecial()); assertThat(actualJson).isEqualTo(KNOWN_JSON); }