RetrievePolicy extends AbstractCommand<RetrievePolicy> implements PolicyQueryCommand<RetrievePolicy> { @Deprecated public static RetrievePolicy of(final String policyId, final DittoHeaders dittoHeaders) { return of(PolicyId.of(policyId), dittoHeaders); } private  RetrievePolicy(final PolicyId policyId, final DittoHeaders dittoHeaders); @Deprecated static RetrievePolicy of(final String policyId, final DittoHeaders dittoHeaders); static RetrievePolicy of(final PolicyId policyId, final DittoHeaders dittoHeaders); static RetrievePolicy fromJson(final String jsonString, final DittoHeaders dittoHeaders); static RetrievePolicy fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders); @Override PolicyId getEntityId(); @Override JsonPointer getResourcePath(); @Override RetrievePolicy 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(() -> RetrievePolicy.of((PolicyId) null, EMPTY_DITTO_HEADERS)) .withNoCause(); }
@Test public void tryToCreateInstanceWithNullPolicyIdString() { assertThatExceptionOfType(PolicyIdInvalidException.class) .isThrownBy(() -> RetrievePolicy.of((String) null, EMPTY_DITTO_HEADERS)); }
@Test public void tryToCreateInstanceWithInvalidPolicyId() { assertThatExceptionOfType(PolicyIdInvalidException.class) .isThrownBy(() -> RetrievePolicy.of("undefined", EMPTY_DITTO_HEADERS)); }
@Test public void toJsonReturnsExpected() { final RetrievePolicy underTest = RetrievePolicy.of( TestConstants.Policy.POLICY_ID, EMPTY_DITTO_HEADERS); final JsonObject actualJson = underTest.toJson(FieldType.regularOrSpecial()); assertThat(actualJson).isEqualTo(KNOWN_JSON); }
@Test public void parseRetrievePolicyCommand() { final GlobalCommandRegistry commandRegistry = GlobalCommandRegistry.getInstance(); final RetrievePolicy command = RetrievePolicy.of( TestConstants.Policy.POLICY_ID, TestConstants.DITTO_HEADERS); final JsonObject jsonObject = command.toJson(FieldType.regularOrSpecial()); final Command parsedCommand = commandRegistry.parse(jsonObject, TestConstants.DITTO_HEADERS); assertThat(parsedCommand).isEqualTo(command); }