policyTO.getSpecification().setUserJavaRule(TestSyncRule.class.getName());
policyService.update(policyTO.getId(), policyTO);
// -----------------------------
SyncTaskTO task = new SyncTaskTO();
task.setName("Test Sync Rule");
task.setResource(RESOURCE_NAME_WS2);
task.setFullReconciliation(true);
task.setPerformCreate(true);
task.setPerformDelete(true);
task.setPerformUpdate(true);
Response response = taskService.create(task);
SyncTaskTO actual = getObject(response.getLocation(), TaskService.class, SyncTaskTO.class);
assertNotNull(actual);
UserTO userTO = UserTestITCase.getUniqueSampleTO("s258_1@apache.org");
userTO.getResources().clear();
userTO.getResources().add(RESOURCE_NAME_WS2);
createUser(userTO);
userTO = UserTestITCase.getUniqueSampleTO("s258_2@apache.org");
userTO.getResources().clear();
userTO.getResources().add(RESOURCE_NAME_WS2);
userTO = createUser(userTO);
// change email in order to unmatch the second user
UserMod userMod = new UserMod();
userMod.setId(userTO.getId());
userMod.getAttrsToRemove().add("email");
userMod.getAttrsToUpdate().add(attributeMod("email", "s258@apache.org"));
userService.update(userMod.getId(), userMod);
execSyncTask(actual.getId(), 50, false);
SyncTaskTO executed = taskService.read(actual.getId());
assertEquals(1, executed.getExecutions().size());
// asser for just one match
assertTrue(executed.getExecutions().get(0).getMessage().substring(0, 55) + "...",
executed.getExecutions().get(0).getMessage().contains("[updated/failures]: 1/0"));
}