// get runProcess start form
PackageActivityForm startForm = appService.viewStartProcessForm(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_PROCESS_DEF_ID, null, null);
assertTrue(TEST_FORM_ID.equals(startForm.getFormId()));
// start process
FormData data = new FormData();
data.addRequestParameterValues(AssignmentCompleteButton.DEFAULT_ID, new String[]{AssignmentCompleteButton.DEFAULT_ID});
WorkflowProcessResult result = appService.submitFormToStartProcess(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_PROCESS_DEF_ID, data, null, null, null);
processId = result.getProcess().getInstanceId();
Collection<WorkflowActivity> activityList = result.getActivities();
assertTrue(activityList != null && activityList.size() == 1);
// get first activity form
WorkflowActivity firstActivity = activityList.iterator().next();
String firstActivityId = firstActivity.getId();
PackageActivityForm firstForm = appService.viewAssignmentForm(TEST_APP_ID, TEST_APP_VERSION.toString(), firstActivityId, null, null);
assertTrue(TEST_FORM_ID_1.equals(firstForm.getFormId()));
// complete first task
FormData formResult = appService.completeAssignmentForm(TEST_APP_ID, TEST_APP_VERSION.toString(), firstActivityId, null, null);
assertTrue(formResult.getFormErrors().isEmpty());
// get assignments
WorkflowAssignment assignment = workflowManager.getAssignmentByProcess(processId);
String secondActivityId = assignment.getActivityId();
PackageActivityForm secondForm = appService.viewAssignmentForm(TEST_APP_ID, TEST_APP_VERSION.toString(), secondActivityId, null, null);
assertTrue(TEST_FORM_ID_2.equals(secondForm.getFormId()));
// complete second task
formResult = appService.completeAssignmentForm(TEST_APP_ID, TEST_APP_VERSION.toString(), secondActivityId, null, null);
assertTrue(formResult.getFormErrors().isEmpty());
// complete third task
assignment = workflowManager.getAssignmentByProcess(processId);
String thirdActivityId = assignment.getActivityId();
formResult = appService.completeAssignmentForm(TEST_APP_ID, TEST_APP_VERSION.toString(), thirdActivityId, null, null);
assertTrue(formResult.getFormErrors().isEmpty());
} finally {
// delete form data
formDataDao.delete(TEST_FORM_ID, TEST_FORM_ID, new String[]{processId});