SudoRetrievePolicyResponse extends AbstractCommandResponse<SudoRetrievePolicyResponse> implements SudoCommandResponse<SudoRetrievePolicyResponse> { public static SudoRetrievePolicyResponse of(final PolicyId policyId, final Policy policy, final DittoHeaders dittoHeaders) { return new SudoRetrievePolicyResponse(policyId, HttpStatusCode.OK, checkNotNull(policy, "Policy") .toJson(dittoHeaders.getSchemaVersion().orElse(policy.getLatestSchemaVersion()), FieldType.regularOrSpecial()), dittoHeaders); } private  SudoRetrievePolicyResponse(final PolicyId policyId,
            final HttpStatusCode statusCode,
            final JsonObject policy,
            final DittoHeaders dittoHeaders); static SudoRetrievePolicyResponse of(final PolicyId policyId, final Policy policy,
            final DittoHeaders dittoHeaders); static SudoRetrievePolicyResponse of(final PolicyId policyId, final JsonObject policy,
            final DittoHeaders dittoHeaders); static SudoRetrievePolicyResponse fromJson(final String jsonString, final DittoHeaders dittoHeaders); static SudoRetrievePolicyResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders); @Override PolicyId getEntityId(); Policy getPolicy(); @Override JsonValue getEntity(final JsonSchemaVersion schemaVersion); @Override SudoRetrievePolicyResponse setEntity(final JsonValue entity); @Override SudoRetrievePolicyResponse setDittoHeaders(final DittoHeaders dittoHeaders); @Override boolean equals(@Nullable final Object o); @Override int hashCode(); @Override String toString(); static final String TYPE; }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullPolicy() { SudoRetrievePolicyResponse.of(TestConstants.Policy.POLICY_ID, (Policy) null, EMPTY_DITTO_HEADERS); }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullJsonObject() { SudoRetrievePolicyResponse.of(TestConstants.Policy.POLICY_ID, (JsonObject) null, EMPTY_DITTO_HEADERS); }
@Test public void toJsonReturnsExpected() { final SudoRetrievePolicyResponse underTest = SudoRetrievePolicyResponse.of(TestConstants.Policy.POLICY_ID, TestConstants.Policy.POLICY, EMPTY_DITTO_HEADERS); final JsonObject actualJson = underTest.toJson(FieldType.REGULAR.or(FieldType.SPECIAL)); assertThat(actualJson).isEqualTo(KNOWN_JSON); }