@Test
public void testSimpleSubProcess() {
RepositoryService repositoryService = activitiRule.getRepositoryService();
Deployment deployment = repositoryService.createDeployment()
.addClasspathResource("org/activiti/examples/bpmn/subprocess/SubProcessTest.fixSystemFailureProcess.bpmn20.xml")
.deploy();
// After staring the process, both tasks in the subprocess should be active
RuntimeService runtimeService = activitiRule.getRuntimeService();
ProcessInstance pi = runtimeService.startProcessInstanceByKey("fixSystemFailure");
TaskService taskService = activitiRule.getTaskService();
List<Task> tasks = taskService.createTaskQuery()
.processInstanceId(pi.getId())
.orderByTaskName()
.asc()
.list();
// Tasks are ordered by name (see query)
assertEquals(2, tasks.size());
Task investigateHardwareTask = tasks.get(0);
Task investigateSoftwareTask = tasks.get(1);
assertEquals("Investigate hardware", investigateHardwareTask.getName());
assertEquals("Investigate software", investigateSoftwareTask.getName());
// Completing both the tasks finishes the subprocess and enables the task after the subprocess
taskService.complete(investigateHardwareTask.getId());
taskService.complete(investigateSoftwareTask.getId());
Task writeReportTask = taskService
.createTaskQuery()
.processInstanceId(pi.getId())
.singleResult();
assertEquals("Write report", writeReportTask.getName());
// Clean up
repositoryService.deleteDeployment(deployment.getId(), true);
}