use of org.forgerock.json.resource.ResourceResponse in project OpenAM by OpenRock.
the class AuditFilterTest method shouldReturnNullForReadSuccess.
@Test
public void shouldReturnNullForReadSuccess() {
ReadRequest readRequest = mock(ReadRequest.class);
ResourceResponse resourceResponse = mock(ResourceResponse.class);
JsonValue filterResponse = auditFilter.getReadSuccessDetail(readRequest, resourceResponse);
assertThat(filterResponse).isEqualTo(null);
}
use of org.forgerock.json.resource.ResourceResponse in project OpenAM by OpenRock.
the class AuditFilterTest method shouldReturnNullForPatchSuccess.
@Test
public void shouldReturnNullForPatchSuccess() {
PatchRequest patchRequest = mock(PatchRequest.class);
ResourceResponse resourceResponse = mock(ResourceResponse.class);
JsonValue filterResponse = auditFilter.getPatchSuccessDetail(patchRequest, resourceResponse);
assertThat(filterResponse).isEqualTo(null);
}
use of org.forgerock.json.resource.ResourceResponse in project OpenAM by OpenRock.
the class KbaResource method readInstance.
@Override
public Promise<ResourceResponse, ResourceException> readInstance(Context context, ReadRequest readRequest) {
String realm = RealmContext.getRealm(context);
JsonValue kbaJson = configHandler.getConfig(realm, KbaBuilder.class);
ResourceResponse response = Responses.newResourceResponse("1", "1.0", kbaJson);
return Promises.newResultPromise(response);
}
use of org.forgerock.json.resource.ResourceResponse in project OpenAM by OpenRock.
the class RequesterTest method shouldExecuteUpdateOperation.
@Test
public void shouldExecuteUpdateOperation() throws ResourceException {
// *** GIVEN ***
String location = "location";
String resourceId = "resourceId";
JsonValue payload = JsonValueBuilder.jsonValue().build();
JsonValue expectedResult = JsonValueBuilder.toJsonValue("{ \"lemon\" : \"custard\" } ");
// Set up mocks
Promise<ResourceResponse, ResourceException> mockResponse = mock(Promise.class);
ResourceResponse mockResourceResponse = mock(ResourceResponse.class);
// Stub mocks
given(mockRealmRouterProvider.get()).willReturn(mockRouter);
given(mockRouter.handleUpdate(any(Context.class), any(UpdateRequest.class))).willReturn(mockResponse);
given(mockResponse.getOrThrowUninterruptibly()).willReturn(mockResourceResponse);
given(mockResourceResponse.getContent()).willReturn(expectedResult);
// *** WHEN ***
JsonValue actualResult = requester.update(location, resourceId, payload, mockServerContext);
// *** THEN ***
verify(mockRealmRouterProvider, times(1)).get();
verifyNoMoreInteractions(mockRealmRouterProvider);
verify(mockRouter, times(1)).handleUpdate(any(Context.class), any(UpdateRequest.class));
verifyNoMoreInteractions(mockRouter);
verify(mockResponse, times(1)).getOrThrowUninterruptibly();
verifyNoMoreInteractions(mockResponse);
verify(mockResourceResponse, times(1)).getContent();
verifyNoMoreInteractions(mockResourceResponse);
assertThat(actualResult).isEqualTo(expectedResult);
}
use of org.forgerock.json.resource.ResourceResponse in project OpenAM by OpenRock.
the class RequesterTest method shouldExecuteCreateRequest.
@Test
public void shouldExecuteCreateRequest() throws ResourceException {
// *** GIVEN ***
String location = "location";
String resourceId = "resourceId";
JsonValue payload = JsonValueBuilder.jsonValue().build();
JsonValue expectedResult = JsonValueBuilder.toJsonValue("{ \"lemon\" : \"custard\" } ");
// Create mocks
Promise<ResourceResponse, ResourceException> mockResponse = mock(Promise.class);
ResourceResponse mockResourceResponse = mock(ResourceResponse.class);
;
// Stub mocks
given(mockRealmRouterProvider.get()).willReturn(mockRouter);
given(mockRouter.handleCreate(any(Context.class), any(CreateRequest.class))).willReturn(mockResponse);
given(mockResponse.getOrThrowUninterruptibly()).willReturn(mockResourceResponse);
given(mockResourceResponse.getContent()).willReturn(expectedResult);
// *** WHEN ***
JsonValue actualResult = requester.create(location, resourceId, payload, mockServerContext);
// *** THEN ***
verify(mockRealmRouterProvider, times(1)).get();
verifyNoMoreInteractions(mockRealmRouterProvider);
verify(mockRouter, times(1)).handleCreate(any(Context.class), any(CreateRequest.class));
verifyNoMoreInteractions(mockRouter);
verify(mockResponse, times(1)).getOrThrowUninterruptibly();
verifyNoMoreInteractions(mockResponse);
verify(mockResourceResponse, times(1)).getContent();
verifyNoMoreInteractions(mockResourceResponse);
assertThat(actualResult).isEqualTo(expectedResult);
}
Aggregations