Search in sources :

Example 6 with BulkOperation

use of io.jans.scim.model.scim2.bulk.BulkOperation in project jans by JanssenProject.

the class UsersBulkTest method bulkWithObject.

@Test(dependsOnMethods = "bulkJson1")
public void bulkWithObject() {
    logger.info("Sending a bulk with one DELETE...");
    BulkOperation op = new BulkOperation();
    op.setMethod("DELETE");
    op.setPath("/Users/" + id);
    BulkRequest breq = new BulkRequest();
    breq.setOperations(Collections.singletonList(op));
    Response response = client.processBulkOperations(breq);
    assertEquals(response.getStatus(), Status.OK.getStatusCode());
    BulkResponse bres = response.readEntity(BulkResponse.class);
    List<BulkOperation> ops = bres.getOperations();
    assertEquals(ops.size(), 1);
    // Verify resource was deleted
    assertEquals(Status.NO_CONTENT.getStatusCode(), Integer.parseInt(ops.get(0).getStatus()));
}
Also used : Response(javax.ws.rs.core.Response) BulkResponse(io.jans.scim.model.scim2.bulk.BulkResponse) BulkOperation(io.jans.scim.model.scim2.bulk.BulkOperation) BulkRequest(io.jans.scim.model.scim2.bulk.BulkRequest) BulkResponse(io.jans.scim.model.scim2.bulk.BulkResponse) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test)

Example 7 with BulkOperation

use of io.jans.scim.model.scim2.bulk.BulkOperation in project jans by JanssenProject.

the class UsersBulkTest method bulkJson2.

@Parameters("users_bulk2")
@Test(dependsOnMethods = "bulkWithObject")
public void bulkJson2(String json) throws Exception {
    logger.info("Sending a bulk with POSTs and DELETEs operations...");
    Response response = client.processBulkOperations(json);
    assertEquals(response.getStatus(), Status.OK.getStatusCode());
    BulkResponse br = response.readEntity(BulkResponse.class);
    List<BulkOperation> ops = br.getOperations();
    // Check that the attempt to update non-existing user returned 404
    BulkOperation failed = ops.remove(ops.size() - 1);
    assertEquals(Integer.parseInt(failed.getStatus()), Status.NOT_FOUND.getStatusCode());
    assertSuccessfulOps(ops);
}
Also used : Response(javax.ws.rs.core.Response) BulkResponse(io.jans.scim.model.scim2.bulk.BulkResponse) BulkOperation(io.jans.scim.model.scim2.bulk.BulkOperation) BulkResponse(io.jans.scim.model.scim2.bulk.BulkResponse) Parameters(org.testng.annotations.Parameters) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test)

Example 8 with BulkOperation

use of io.jans.scim.model.scim2.bulk.BulkOperation in project jans by JanssenProject.

the class UsersBulkTest method assertSuccessfulOps.

private void assertSuccessfulOps(List<BulkOperation> ops) {
    for (BulkOperation operation : ops) {
        // Verify sucessful operations
        int code = Integer.parseInt(operation.getStatus());
        assertTrue(Family.familyOf(code).equals(Family.SUCCESSFUL));
    }
}
Also used : BulkOperation(io.jans.scim.model.scim2.bulk.BulkOperation)

Example 9 with BulkOperation

use of io.jans.scim.model.scim2.bulk.BulkOperation in project jans by JanssenProject.

the class GroupsBulkTest method assertSuccessfulOps.

private void assertSuccessfulOps(List<BulkOperation> ops) {
    for (BulkOperation operation : ops) {
        // Verify sucessful operations
        int code = Integer.parseInt(operation.getStatus());
        assertTrue(Family.familyOf(code).equals(Family.SUCCESSFUL));
    }
}
Also used : BulkOperation(io.jans.scim.model.scim2.bulk.BulkOperation)

Example 10 with BulkOperation

use of io.jans.scim.model.scim2.bulk.BulkOperation in project jans by JanssenProject.

the class GroupsBulkTest method bulkObject.

@Test(dependsOnMethods = "bulkJson")
public void bulkObject() {
    logger.info("Sending a bulk with a patch to insert admin user into group");
    // Creates a patch request consisting of adding the admin user to the group created
    PatchOperation po = new PatchOperation();
    po.setOperation("add");
    po.setPath("members.value");
    po.setValue(getAdminId());
    PatchRequest pr = new PatchRequest();
    pr.setOperations(Collections.singletonList(po));
    // Creates the bulk operation associated to the patch request
    BulkOperation bop = new BulkOperation();
    bop.setMethod("PATCH");
    bop.setPath("/Groups/" + groupId);
    bop.setData(mapper.convertValue(pr, new TypeReference<Map<String, Object>>() {
    }));
    BulkRequest breq = new BulkRequest();
    breq.setOperations(Collections.singletonList(bop));
    // Send bulk and check success of processing
    Response response = client.processBulkOperations(breq);
    assertEquals(response.getStatus(), Status.OK.getStatusCode());
    BulkResponse bres = response.readEntity(BulkResponse.class);
    assertSuccessfulOps(bres.getOperations());
}
Also used : Response(javax.ws.rs.core.Response) ListResponse(io.jans.scim.model.scim2.ListResponse) BulkResponse(io.jans.scim.model.scim2.bulk.BulkResponse) BulkOperation(io.jans.scim.model.scim2.bulk.BulkOperation) BulkRequest(io.jans.scim.model.scim2.bulk.BulkRequest) PatchOperation(io.jans.scim.model.scim2.patch.PatchOperation) BulkResponse(io.jans.scim.model.scim2.bulk.BulkResponse) TypeReference(com.fasterxml.jackson.core.type.TypeReference) PatchRequest(io.jans.scim.model.scim2.patch.PatchRequest) Test(org.testng.annotations.Test) BaseTest(io.jans.scim2.client.BaseTest)

Aggregations

BulkOperation (io.jans.scim.model.scim2.bulk.BulkOperation)10 Response (javax.ws.rs.core.Response)10 BulkResponse (io.jans.scim.model.scim2.bulk.BulkResponse)8 Test (org.testng.annotations.Test)6 Parameters (org.testng.annotations.Parameters)4 ListResponse (io.jans.scim.model.scim2.ListResponse)3 BulkRequest (io.jans.scim.model.scim2.bulk.BulkRequest)3 BaseTest (io.jans.scim2.client.BaseTest)3 UserBaseTest (io.jans.scim2.client.UserBaseTest)3 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2 PatchOperation (io.jans.scim.model.scim2.patch.PatchOperation)2 PatchRequest (io.jans.scim.model.scim2.patch.PatchRequest)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Consumes (javax.ws.rs.Consumes)2 DefaultValue (javax.ws.rs.DefaultValue)2 HeaderParam (javax.ws.rs.HeaderParam)2 Produces (javax.ws.rs.Produces)2 BulkOperation (org.gluu.oxtrust.model.scim2.bulk.BulkOperation)2 BulkResponse (org.gluu.oxtrust.model.scim2.bulk.BulkResponse)2