PropagationTaskTO taskTO = taskService.read(TaskType.PROPAGATION, maxId);
assertNotNull(taskTO);
int maxTaskExecutions = taskTO.getExecutions().size();
UserTO userTO = getUniqueSampleTO("a.b@c.com");
// add a membership
MembershipTO membershipTO = new MembershipTO();
membershipTO.setRoleId(8L);
userTO.addMembership(membershipTO);
// add an attribute with no values: must be ignored
membershipTO.addAttribute(attributeTO("subscriptionDate", null));
// add an attribute with a non-existing schema: must be ignored
AttributeTO attrWithInvalidSchemaTO = attributeTO("invalid schema", "a value");
userTO.addAttribute(attrWithInvalidSchemaTO);
// add an attribute with null value: must be ignored
userTO.addAttribute(attributeTO("activationDate", null));
// 1. create user
UserTO newUserTO = createUser(userTO);
assertNotNull(newUserTO);
assertFalse(newUserTO.getAttributes().contains(attrWithInvalidSchemaTO));
// check for changePwdDate
assertNotNull(newUserTO.getCreationDate());
// 2. check for virtual attribute value
newUserTO = userService.read(newUserTO.getId());
assertNotNull(newUserTO);
assertNotNull(newUserTO.getVirtualAttributeMap());
assertNotNull(newUserTO.getVirtualAttributeMap().get("virtualdata").getValues());
assertFalse(newUserTO.getVirtualAttributeMap().get("virtualdata").getValues().isEmpty());
assertEquals("virtualvalue", newUserTO.getVirtualAttributeMap().get("virtualdata").getValues().get(0));
// get the new task list
tasks = (List<PropagationTaskTO>) taskService.list(TaskType.PROPAGATION);
assertNotNull(tasks);
assertFalse(tasks.isEmpty());
long newMaxId = getMaxTaskId(tasks);
// default configuration for ws-target-resource2:
// only failed executions have to be registered
// --> no more tasks/executions should be added
assertEquals(newMaxId, maxId);
// get last task
taskTO = taskService.read(TaskType.PROPAGATION, newMaxId);
assertNotNull(taskTO);
assertEquals(maxTaskExecutions, taskTO.getExecutions().size());
// 3. verify password
UserService userService1 = super.setupCredentials(userService, UserService.class, newUserTO.getUsername(),
"password123");
try {
UserTO user = userService1.readSelf();
assertNotNull(user);
} catch (AccessControlException e) {
fail("Credentials should be valid and not cause AccessControlException");
}