RetrieveResourceResponse extends AbstractCommandResponse<RetrieveResourceResponse> implements PolicyQueryCommandResponse<RetrieveResourceResponse> { @Deprecated public static RetrieveResourceResponse of(final String policyId, final Label label, final Resource resource, final DittoHeaders dittoHeaders) { return of(PolicyId.of(policyId), label, resource, dittoHeaders); } private  RetrieveResourceResponse(final PolicyId policyId,
            final Label label,
            final ResourceKey resourceKey,
            final JsonObject resource,
            final HttpStatusCode statusCode,
            final DittoHeaders dittoHeaders); @Deprecated static RetrieveResourceResponse of(final String policyId,
            final Label label,
            final Resource resource,
            final DittoHeaders dittoHeaders); static RetrieveResourceResponse of(final PolicyId policyId,
            final Label label,
            final Resource resource,
            final DittoHeaders dittoHeaders); @Deprecated static RetrieveResourceResponse of(final String policyId,
            final Label label,
            final ResourceKey resourceKey,
            final JsonObject resource,
            final DittoHeaders dittoHeaders); static RetrieveResourceResponse of(final PolicyId policyId,
            final Label label,
            final ResourceKey resourceKey,
            final JsonObject resource,
            final DittoHeaders dittoHeaders); static RetrieveResourceResponse fromJson(final String jsonString, final DittoHeaders dittoHeaders); static RetrieveResourceResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders); @Override PolicyId getEntityId(); Label getLabel(); Resource getResource(); ResourceKey getResourceKey(); @Override JsonValue getEntity(final JsonSchemaVersion schemaVersion); @Override RetrieveResourceResponse setEntity(final JsonValue entity); @Override RetrieveResourceResponse 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 tryToCreateInstanceWithNullResource() { RetrieveResourceResponse.of(TestConstants.Policy.POLICY_ID, TestConstants.Policy.LABEL, null, EMPTY_DITTO_HEADERS); }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullJsonObject() { RetrieveResourceResponse.of(TestConstants.Policy.POLICY_ID, TestConstants.Policy.LABEL, ResourceKey .newInstance(TestConstants.Policy.RESOURCE_TYPE, "/foo"), null, EMPTY_DITTO_HEADERS); }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullPath() { RetrieveResourceResponse.of(TestConstants.Policy.POLICY_ID, TestConstants.Policy.LABEL, null, JsonFactory.newObjectBuilder().build(), EMPTY_DITTO_HEADERS); }
@Test public void toJsonReturnsExpected() { final RetrieveResourceResponse underTest = RetrieveResourceResponse.of(TestConstants.Policy.POLICY_ID, TestConstants.Policy.LABEL, TestConstants.Policy.RESOURCE, EMPTY_DITTO_HEADERS); final JsonObject actualJson = underTest.toJson(FieldType.regularOrSpecial()); assertThat(actualJson).isEqualTo(KNOWN_JSON); }