assertEquals(1, userTO.getMemberships().size());
assertEquals(9, userTO.getMemberships().get(0).getRoleId());
assertEquals("createApproval", userTO.getStatus());
// 2. request if there is any pending task for user just created
WorkflowFormTO form = restTemplate.getForObject(BASE_URL + "user/workflow/form/{userId}", WorkflowFormTO.class,
userTO.getId());
assertNotNull(form);
assertNotNull(form.getTaskId());
assertNull(form.getOwner());
// 3. claim task from user1, not in role 7 (designated for
// approval in workflow definition): fail
PreemptiveAuthHttpRequestFactory requestFactory = ((PreemptiveAuthHttpRequestFactory) restTemplate.
getRequestFactory());
((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
requestFactory.getAuthScope(), new UsernamePasswordCredentials("user1", "password"));
SyncopeClientException sce = null;
try {
restTemplate.getForObject(BASE_URL + "user/workflow/form/claim/{taskId}", WorkflowFormTO.class, form.
getTaskId());
} catch (SyncopeClientCompositeErrorException scce) {
sce = scce.getException(SyncopeClientExceptionType.Workflow);
}
assertNotNull(sce);
// 4. claim task from user4, in to role 7
((DefaultHttpClient) requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
requestFactory.getAuthScope(), new UsernamePasswordCredentials("user4", "password"));
form = restTemplate.getForObject(BASE_URL + "user/workflow/form/claim/{taskId}", WorkflowFormTO.class, form.
getTaskId());
assertNotNull(form);
assertNotNull(form.getTaskId());
assertNotNull(form.getOwner());
// 5. reject user
Map<String, WorkflowFormPropertyTO> props = form.getPropertyMap();
props.get("approve").setValue(Boolean.FALSE.toString());
props.get("rejectReason").setValue("I don't like him.");
form.setProperties(props.values());
userTO = restTemplate.postForObject(BASE_URL + "user/workflow/form/submit", form, UserTO.class);
assertNotNull(userTO);
assertEquals("rejected", userTO.getStatus());
// reset admin credentials for restTemplate