use of org.forgerock.json.resource.DeleteRequest in project OpenAM by OpenRock.
the class TrustedDevicesResourceTest method shouldNotDeleteTrustedDeviceWhenNotFound.
@Test(expectedExceptions = NotFoundException.class)
public void shouldNotDeleteTrustedDeviceWhenNotFound() throws ResourceException {
//Given
DeleteRequest request = Requests.newDeleteRequest("UUID_3");
Connection connection = newInternalConnection(newCollection(resource));
List<JsonValue> devices = new ArrayList<JsonValue>();
devices.add(json(object(field("uuid", "UUID_1"), field("name", "NAME_1"))));
devices.add(json(object(field("uuid", "UUID_2"), field("name", "NAME_2"))));
given(dao.getDeviceProfiles(anyString(), anyString())).willReturn(devices);
//When
connection.delete(ctx(), request);
//Then
//Expected NotFoundException
}
use of org.forgerock.json.resource.DeleteRequest in project OpenAM by OpenRock.
the class ApplicationsResourceTest method deleteInstanceShouldHandleFailedDeleteApplication.
@Test(expectedExceptions = NotFoundException.class)
public void deleteInstanceShouldHandleFailedDeleteApplication() throws EntitlementException, ResourceException {
//Given
SSOTokenContext subjectContext = mock(SSOTokenContext.class);
RealmContext realmContext = new RealmContext(subjectContext);
realmContext.setSubRealm("REALM", "REALM");
Context context = ClientContext.newInternalClientContext(realmContext);
String resourceId = "RESOURCE_ID";
DeleteRequest request = mock(DeleteRequest.class);
Subject subject = new Subject();
given(subjectContext.getCallerSubject()).willReturn(subject);
doThrow(EntitlementException.class).when(applicationManagerWrapper).deleteApplication(any(Subject.class), anyString(), eq(resourceId));
//When
Promise<ResourceResponse, ResourceException> result = applicationsResource.deleteInstance(context, resourceId, request);
//Then
result.getOrThrowUninterruptibly();
}
use of org.forgerock.json.resource.DeleteRequest in project OpenAM by OpenRock.
the class ApplicationV1FilterTest method forwardOnDelete.
/**
* Verify that delete requests are forwarded on.
*/
@Test
public void forwardOnDelete() {
// Given
DeleteRequest deleteRequest = mock(DeleteRequest.class);
// When
filter.filterDelete(context, deleteRequest, requestHandler);
// Then
verify(requestHandler).handleDelete(context, deleteRequest);
}
use of org.forgerock.json.resource.DeleteRequest in project OpenAM by OpenRock.
the class ApplicationsResourceTest method shouldReturnNotFoundDeleteInstance.
@Test(expectedExceptions = NotFoundException.class)
public void shouldReturnNotFoundDeleteInstance() throws EntitlementException, ResourceException {
//Given
SSOTokenContext subjectContext = mock(SSOTokenContext.class);
RealmContext realmContext = new RealmContext(subjectContext);
realmContext.setSubRealm("REALM", "REALM");
Context context = ClientContext.newInternalClientContext(realmContext);
String resourceId = "RESOURCE_ID";
DeleteRequest request = mock(DeleteRequest.class);
Subject subject = new Subject();
given(subjectContext.getCallerSubject()).willReturn(subject);
//When
Promise<ResourceResponse, ResourceException> result = applicationsResource.deleteInstance(context, resourceId, request);
//Then
verify(applicationManagerWrapper, never()).deleteApplication(subject, "REALM", resourceId);
result.getOrThrowUninterruptibly();
}
use of org.forgerock.json.resource.DeleteRequest in project OpenAM by OpenRock.
the class ApplicationsResourceTest method shouldDeleteInstance.
@Test
public void shouldDeleteInstance() throws EntitlementException, ResourceException {
//Given
SSOTokenContext subjectContext = mock(SSOTokenContext.class);
RealmContext realmContext = new RealmContext(subjectContext);
realmContext.setSubRealm("REALM", "REALM");
Context context = ClientContext.newInternalClientContext(realmContext);
String resourceId = "iPlanetAMWebAgentService";
DeleteRequest request = mock(DeleteRequest.class);
Subject subject = new Subject();
Application mockApplication = mock(Application.class);
given(subjectContext.getCallerSubject()).willReturn(subject);
given(applicationManagerWrapper.getApplication(any(Subject.class), anyString(), anyString())).willReturn(mockApplication);
//When
Promise<ResourceResponse, ResourceException> result = applicationsResource.deleteInstance(context, resourceId, request);
//Then
verify(applicationManagerWrapper).deleteApplication(subject, "/REALM", resourceId);
ResourceResponse resource = result.getOrThrowUninterruptibly();
assertEquals(resource.getId(), resourceId);
}
Aggregations