Search in sources :

Example 6 with Connection

use of org.forgerock.json.resource.Connection 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
}
Also used : Resources.newInternalConnection(org.forgerock.json.resource.Resources.newInternalConnection) Connection(org.forgerock.json.resource.Connection) ArrayList(java.util.ArrayList) JsonValue(org.forgerock.json.JsonValue) DeleteRequest(org.forgerock.json.resource.DeleteRequest) Test(org.testng.annotations.Test)

Example 7 with Connection

use of org.forgerock.json.resource.Connection in project OpenAM by OpenRock.

the class ElevatedConnectionFactoryWrapper method getConnection.

@Override
public Connection getConnection() throws ResourceException {
    Connection connection = connectionFactory.getConnection();
    SSOToken ssoToken = ssoTokenPrivilegedAction.run();
    return new ElevatedConnection(connection, ssoToken);
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Connection(org.forgerock.json.resource.Connection)

Aggregations

Connection (org.forgerock.json.resource.Connection)7 Resources.newInternalConnection (org.forgerock.json.resource.Resources.newInternalConnection)5 Test (org.testng.annotations.Test)4 ArrayList (java.util.ArrayList)3 JsonValue (org.forgerock.json.JsonValue)3 RootContext (org.forgerock.services.context.RootContext)3 SSOToken (com.iplanet.sso.SSOToken)2 CreateRequest (org.forgerock.json.resource.CreateRequest)2 DeleteRequest (org.forgerock.json.resource.DeleteRequest)2 Requests.newCreateRequest (org.forgerock.json.resource.Requests.newCreateRequest)2 SSOTokenID (com.iplanet.sso.SSOTokenID)1 SSOPrincipal (com.iplanet.sso.providers.dpro.SSOPrincipal)1 Date (java.util.Date)1 List (java.util.List)1 QueryRequest (org.forgerock.json.resource.QueryRequest)1 QueryResourceHandler (org.forgerock.json.resource.QueryResourceHandler)1 ReadRequest (org.forgerock.json.resource.ReadRequest)1 ServiceUnavailableException (org.forgerock.json.resource.ServiceUnavailableException)1 Context (org.forgerock.services.context.Context)1 SecurityContext (org.forgerock.services.context.SecurityContext)1