RetrievePolicyResponse extends AbstractCommandResponse<RetrievePolicyResponse> implements PolicyQueryCommandResponse<RetrievePolicyResponse> { @Deprecated public static RetrievePolicyResponse of(final String policyId, final Policy policy, final DittoHeaders dittoHeaders) { return of(PolicyId.of(policyId), policy, dittoHeaders); } private  RetrievePolicyResponse(final PolicyId policyId,
            final HttpStatusCode statusCode,
            final JsonObject policy,
            final DittoHeaders dittoHeaders); @Deprecated static RetrievePolicyResponse of(final String policyId, final Policy policy,
            final DittoHeaders dittoHeaders); static RetrievePolicyResponse of(final PolicyId policyId, final Policy policy,
            final DittoHeaders dittoHeaders); @Deprecated static RetrievePolicyResponse of(final String policyId, final JsonObject policy,
            final DittoHeaders dittoHeaders); static RetrievePolicyResponse of(final PolicyId policyId, final JsonObject policy,
            final DittoHeaders dittoHeaders); static RetrievePolicyResponse fromJson(final String jsonString, final DittoHeaders dittoHeaders); static RetrievePolicyResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders); @Override PolicyId getEntityId(); Policy getPolicy(); @Override JsonValue getEntity(final JsonSchemaVersion schemaVersion); @Override RetrievePolicyResponse setEntity(final JsonValue entity); @Override RetrievePolicyResponse setDittoHeaders(final DittoHeaders dittoHeaders); @Override JsonPointer getResourcePath(); @Override boolean equals(@Nullable final Object o); @Override int hashCode(); @Override String toString(); static final String TYPE; }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullPolicy() { RetrievePolicyResponse.of(TestConstants.Policy.POLICY_ID, (Policy) null, EMPTY_DITTO_HEADERS); }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullJsonObject() { RetrievePolicyResponse.of(TestConstants.Policy.POLICY_ID, (JsonObject) null, EMPTY_DITTO_HEADERS); }
@Test public void toJsonReturnsExpected() { final RetrievePolicyResponse underTest = RetrievePolicyResponse.of(TestConstants.Policy.POLICY_ID, TestConstants.Policy.POLICY, EMPTY_DITTO_HEADERS); final JsonObject actualJson = underTest.toJson(FieldType.regularOrSpecial()); assertThat(actualJson).isEqualTo(KNOWN_JSON); }
@Test public void parsePolicyQueryCommandResponse() { final RetrievePolicyResponse commandResponse = RetrievePolicyResponse.of(TestConstants.Policy.POLICY_ID, TestConstants.Policy.POLICY, TestConstants.DITTO_HEADERS); final JsonObject jsonObject = commandResponse.toJson(FieldType.regularOrSpecial()); final CommandResponse parsedCommandResponse = GlobalCommandResponseRegistry.getInstance().parse(jsonObject, TestConstants.DITTO_HEADERS); assertThat(parsedCommandResponse).isEqualTo(commandResponse); }