Friday, January 8, 2010

Unit tests for processes

I added a Helper class containing IPP query methods that are helpful for automated process testing. It provides methods to search for process and activity instances, complete activities, check the state of processes or activities...
For example:
import static ag.carnot.workflow.query.ProcessInstanceQuery.ROOT_PROCESS_INSTANCE_OID;

* Gets all process instances for ProcessOID of a process
* @param processId
* in model
* @param rootPoid
* root process instance oid
* @return all process instances matching process ID and root process OID

public static final List<ProcessInstance> findAllProcessInstancesForProcessIdAndRootPoid(
String processId, long rootPoid) {
ProcessInstanceQuery query = ProcessInstanceQuery.findForProcess(processId);
List<ProcessInstance> allProcessInstances = queryService.getAllProcessInstances(query);
return allProcessInstances;
I also added a sample test, which is at the moment only starting the Emergency Voting process and retrieves all started "Vote" subprocesses. To get the test running, you have to make sure, that the $JBOSS_HOME\client\jbossall-client.jar is on the classpath.
 public static void testEmergencyVoting() throws InterruptedException {
long votingProcessOID = startEmergencyVotingProcess();
//Wait for Subprocesses to be started
List<ProcessInstance> processInstances = ProcessHelper
.findAllProcessInstancesForProcessIdAndRootPoid(VOTING_PID, votingProcessOID);"Found "+ processInstances.size()+" Instances of Vote Subprocesses");
//TODO: real testcase to be implemented

-Larissa Werlein-

No comments:

Post a Comment