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()));
}
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);
}
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));
}
}
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));
}
}
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());
}
Aggregations