use of org.forgerock.json.resource.UpdateRequest in project OpenAM by OpenRock.
the class UmaPolicyResourceTest method shouldSuccessfullyUpdatePolicy.
@Test
@SuppressWarnings("unchecked")
public void shouldSuccessfullyUpdatePolicy() {
//Given
Context context = mock(Context.class);
UpdateRequest request = Requests.newUpdateRequest("/policies", json(object()));
UmaPolicy policy = mock(UmaPolicy.class);
JsonValue policyJson = json(object());
Promise<UmaPolicy, ResourceException> promise = Promises.newResultPromise(policy);
given(policy.getId()).willReturn("ID");
given(policy.getRevision()).willReturn("REVISION");
given(policy.asJson()).willReturn(policyJson);
given(policyService.updatePolicy(context, "RESOURCE_SET_UID", request.getContent())).willReturn(promise);
//When
Promise<ResourceResponse, ResourceException> result = policyResource.updateInstance(context, "RESOURCE_SET_UID", request);
//Then
assertThat(result).succeeded().withId().isEqualTo("ID");
assertThat(result).succeeded().withRevision().isEqualTo("REVISION");
assertThat(result).succeeded().withContent().isObject().isEqualTo(policyJson);
}
Aggregations