public void testStartActivityC() { LogUtil.info(getClass().getName(), ">>> testStartActivityC"); String currentActivityDef = "B"; String desiredActivityDef = "C"; // get process instance Map runningActivities = workflowManager.getActivityInstanceByProcessIdAndStatus(processId, null); String activityId = String.valueOf(runningActivities.get(currentActivityDef)); WorkflowActivity wa = workflowManager.getActivityById(activityId); String processInstanceId = wa.getProcessId(); // abort running activities and start activity C boolean started = workflowManager.activityStart(processInstanceId, desiredActivityDef, true); // check running activities runningActivities = workflowManager.getActivityInstanceByProcessIdAndStatus(processId, null); String abortedActivity = (String) runningActivities.get(currentActivityDef); String runningActivity = (String) runningActivities.get(desiredActivityDef); LogUtil.info( getClass().getName(), "Running activities: " + runningActivities + "; Result: " + started); Assert.assertTrue(abortedActivity == null && runningActivity != null); }
public void testAssignment() { LogUtil.info(getClass().getName(), ">>> testAssignment"); Map activityInstance = workflowManager.getActivityInstanceByProcessIdAndStatus(processId, true); String activityId = String.valueOf(activityInstance.get("A")); WorkflowActivity wa = workflowManager.getActivityById(activityId); String processInstanceId = wa.getProcessId(); WorkflowAssignment ass = workflowManager.getAssignmentByProcess(processInstanceId); WorkflowAssignment ass2 = workflowManager.getAssignment(activityId); Assert.assertTrue( ass != null && ass2 != null && ass.getActivityId().equals(ass2.getActivityId())); }
public void testCopyProcess() { LogUtil.info(getClass().getName(), ">>> testCopyProcess"); boolean valid = false; // start and get instance id of the 1st process String packageVersion = workflowManager.getCurrentPackageVersion(packageId); WorkflowProcessResult result = workflowManager.processStart(packageId + "#" + packageVersion + "#" + processId); String processInstanceId = result.getProcess().getInstanceId(); LogUtil.info( getClass().getName(), "------------- process one id : " + processInstanceId + " -------------"); // abort running activities and start activity B String firstActivityDef = "A"; String desiredActivityDef = "B"; boolean started = workflowManager.activityStart(processInstanceId, desiredActivityDef, true); if (started) { // start 2nd process from the 1st process instance id WorkflowProcessResult nextResult = workflowManager.processCopyFromInstanceId( processInstanceId, packageId + "#" + packageVersion + "#" + processId, true); WorkflowProcess processStarted = nextResult.getProcess(); if (processStarted != null) { // check for the aborted and running activities String newProcessId = processStarted.getInstanceId(); Collection<WorkflowActivity> activityList = workflowManager.getActivityList(newProcessId, 0, 1000, null, null); for (WorkflowActivity act : activityList) { if (act.getState().startsWith("open")) { if (firstActivityDef.equals(act.getActivityDefId())) { valid = false; break; } if (desiredActivityDef.equals(act.getActivityDefId())) { valid = true; } } } LogUtil.info( getClass().getName(), "------------- new process id : " + newProcessId + " ------------- " + valid); // cleanup WorkflowProcessLink link = workflowManager.getWorkflowProcessLink(newProcessId); workflowManager.internalDeleteWorkflowProcessLink(link); } } Assert.assertTrue(valid); }