ModifyPolicyEntry extends AbstractCommand<ModifyPolicyEntry> implements PolicyModifyCommand<ModifyPolicyEntry> { @Deprecated public static ModifyPolicyEntry of(final String policyId, final PolicyEntry policyEntry, final DittoHeaders dittoHeaders) { return of(PolicyId.of(policyId), policyEntry, dittoHeaders); } private  ModifyPolicyEntry(final PolicyId policyId, final PolicyEntry policyEntry, final DittoHeaders dittoHeaders); @Deprecated static ModifyPolicyEntry of(final String policyId, final PolicyEntry policyEntry,
            final DittoHeaders dittoHeaders); static ModifyPolicyEntry of(final PolicyId policyId, final PolicyEntry policyEntry,
            final DittoHeaders dittoHeaders); static ModifyPolicyEntry fromJson(final String jsonString, final DittoHeaders dittoHeaders); static ModifyPolicyEntry fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders); PolicyEntry getPolicyEntry(); @Override PolicyId getEntityId(); @Override Optional<JsonValue> getEntity(final JsonSchemaVersion schemaVersion); @Override JsonPointer getResourcePath(); @Override Category getCategory(); @Override ModifyPolicyEntry 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() { ModifyPolicyEntry.of((PolicyId) null, TestConstants.Policy.POLICY_ENTRY, TestConstants.EMPTY_DITTO_HEADERS); }
@Test(expected = PolicyIdInvalidException.class) public void tryToCreateInstanceWithNullPolicyIdString() { ModifyPolicyEntry.of((String) null, TestConstants.Policy.POLICY_ENTRY, TestConstants.EMPTY_DITTO_HEADERS); }
@Test public void tryToCreateInstanceWithInvalidPolicyId() { assertThatExceptionOfType(PolicyIdInvalidException.class) .isThrownBy(() -> ModifyPolicyEntry.of("undefined", TestConstants.Policy.POLICY_ENTRY, TestConstants.EMPTY_DITTO_HEADERS)); }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullPolicyEntry() { ModifyPolicyEntry.of(TestConstants.Policy.POLICY_ID, null, TestConstants.EMPTY_DITTO_HEADERS); }
@Test public void toJsonReturnsExpected() { final ModifyPolicyEntry underTest = ModifyPolicyEntry.of( TestConstants.Policy.POLICY_ID, TestConstants.Policy.POLICY_ENTRY, TestConstants.EMPTY_DITTO_HEADERS); final JsonObject actualJson = underTest.toJson(FieldType.regularOrSpecial()); assertThat(actualJson).isEqualTo(KNOWN_JSON); }