assertEquals("createApproval", userTO.getStatus());
assertEquals(Collections.singleton(RESOURCE_NAME_TESTDB), userTO.getResources());
assertTrue(userTO.getPropagationStatusTOs().isEmpty());
JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
Exception exception = null;
try {
jdbcTemplate.queryForObject("SELECT id FROM test WHERE id=?",
new String[] {userTO.getUsername()}, Integer.class);
} catch (EmptyResultDataAccessException e) {
exception = e;
}
assertNotNull(exception);
// 2. request if there is any pending form for user just created
List<WorkflowFormTO> forms = userWorkflowService.getForms();
assertNotNull(forms);
assertEquals(1, forms.size());
WorkflowFormTO form = userWorkflowService.getFormForUser(userTO.getId());
assertNotNull(form);
assertNotNull(form.getTaskId());
assertNull(form.getOwner());
// 4. claim task (from admin)
form = userWorkflowService.claimForm(form.getTaskId());
assertNotNull(form);
assertNotNull(form.getTaskId());
assertNotNull(form.getOwner());
// 5. approve user (and verify that propagation occurred)
Map<String, WorkflowFormPropertyTO> props = form.getPropertyMap();
props.get("approve").setValue(Boolean.TRUE.toString());
form.setProperties(props.values());
userTO = userWorkflowService.submitForm(form);
assertNotNull(userTO);
assertEquals("active", userTO.getStatus());
assertEquals(Collections.singleton(RESOURCE_NAME_TESTDB), userTO.getResources());
exception = null;
try {
final String username = jdbcTemplate.queryForObject("SELECT id FROM test WHERE id=?", String.class,
userTO.getUsername());
assertEquals(userTO.getUsername(), username);
} catch (EmptyResultDataAccessException e) {
exception = e;
}