ModifySubjects extends AbstractCommand<ModifySubjects> implements PolicyModifyCommand<ModifySubjects> { @Deprecated public static ModifySubjects of(final String policyId, final Label label, final Subjects subjects, final DittoHeaders dittoHeaders) { return of(PolicyId.of(policyId), label, subjects, dittoHeaders); } private  ModifySubjects(final PolicyId policyId,
            final Label label,
            final Subjects subjects,
            final DittoHeaders dittoHeaders); @Deprecated static ModifySubjects of(final String policyId,
            final Label label,
            final Subjects subjects,
            final DittoHeaders dittoHeaders); static ModifySubjects of(final PolicyId policyId,
            final Label label,
            final Subjects subjects,
            final DittoHeaders dittoHeaders); static ModifySubjects fromJson(final String jsonString, final DittoHeaders dittoHeaders); static ModifySubjects fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders); Label getLabel(); Subjects getSubjects(); @Override PolicyId getEntityId(); @Override Optional<JsonValue> getEntity(final JsonSchemaVersion schemaVersion); @Override JsonPointer getResourcePath(); @Override Category getCategory(); @Override ModifySubjects setDittoHeaders(final DittoHeaders dittoHeaders); @SuppressWarnings("squid:MethodCyclomaticComplexity") @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(expected = NullPointerException.class) public void tryToCreateInstanceWithNullPolicyId() { ModifySubjects.of((PolicyId) null, TestConstants.Policy.LABEL, TestConstants.Policy.SUBJECTS, TestConstants.EMPTY_DITTO_HEADERS); }
@Test(expected = PolicyIdInvalidException.class) public void tryToCreateInstanceWithNullPolicyIdString() { ModifySubjects.of((String) null, TestConstants.Policy.LABEL, TestConstants.Policy.SUBJECTS, TestConstants.EMPTY_DITTO_HEADERS); }
@Test public void tryToCreateInstanceWithInvalidPolicyId() { assertThatExceptionOfType(PolicyIdInvalidException.class) .isThrownBy(() -> ModifySubjects.of("undefined", TestConstants.Policy.LABEL, TestConstants.Policy.SUBJECTS, TestConstants.EMPTY_DITTO_HEADERS)); }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullLabel() { ModifySubjects.of(TestConstants.Policy.POLICY_ID, null, TestConstants.Policy.SUBJECTS, TestConstants.EMPTY_DITTO_HEADERS); }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullSubjects() { ModifySubjects.of(TestConstants.Policy.POLICY_ID, TestConstants.Policy.LABEL, null, TestConstants.EMPTY_DITTO_HEADERS); }
@Test public void toJsonReturnsExpected() { final ModifySubjects underTest = ModifySubjects.of(TestConstants.Policy.POLICY_ID, TestConstants.Policy.LABEL, TestConstants.Policy.SUBJECTS, TestConstants.EMPTY_DITTO_HEADERS); final JsonObject actualJson = underTest.toJson(FieldType.regularOrSpecial()); assertThat(actualJson).isEqualTo(KNOWN_JSON); }