for (PropagationTaskTO task : tasks) {
if (task.getId() > maxId) {
maxId = task.getId();
}
}
PropagationTaskTO taskTO =
restTemplate.getForObject(BASE_URL + "task/read/{taskId}", PropagationTaskTO.class, maxId);
assertNotNull(taskTO);
int maxTaskExecutions = taskTO.getExecutions().size();
UserTO userTO = getSampleTO("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
AttributeTO nullValueAttrTO = new AttributeTO();
nullValueAttrTO.setSchema("subscriptionDate");
nullValueAttrTO.setValues(null);
membershipTO.addAttribute(nullValueAttrTO);
// add an attribute with a non-existing schema: must be ignored
AttributeTO attrWithInvalidSchemaTO = new AttributeTO();
attrWithInvalidSchemaTO.setSchema("invalid schema");
attrWithInvalidSchemaTO.addValue("a value");
userTO.addAttribute(attrWithInvalidSchemaTO);
// add an attribute with null value: must be ignored
nullValueAttrTO = new AttributeTO();
nullValueAttrTO.setSchema("activationDate");
nullValueAttrTO.addValue(null);
userTO.addAttribute(nullValueAttrTO);
// 1. create user
UserTO newUserTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
assertNotNull(newUserTO);
assertFalse(newUserTO.getAttributes().contains(attrWithInvalidSchemaTO));
// check for changePwdDate
assertNotNull(newUserTO.getCreationDate());
// 2. check for virtual attribute value
newUserTO = restTemplate.getForObject(BASE_URL + "user/read/{userId}.json", UserTO.class, 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 = Arrays.asList(restTemplate.getForObject(BASE_URL + "task/propagation/list", PropagationTaskTO[].class));
assertNotNull(tasks);
assertFalse(tasks.isEmpty());
// get max task id
long newMaxId = Long.MIN_VALUE;
for (PropagationTaskTO task : tasks) {
if (task.getId() > newMaxId) {
newMaxId = task.getId();
}
}
// 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 = restTemplate.getForObject(BASE_URL + "task/read/{taskId}", PropagationTaskTO.class, newMaxId);
assertNotNull(taskTO);
assertEquals(maxTaskExecutions, taskTO.getExecutions().size());
// 3. verify password
Boolean verify = restTemplate.
getForObject(BASE_URL + "user/verifyPassword/{username}.json?password=password123",
Boolean.class, newUserTO.getUsername());