@Deployment( resources = { "org/activiti/examples/bpmn/event/timer/BoundaryTimerEventTest.testInterruptingTimerDuration.bpmn" }) @Test public void testInterruptingTimerDuration() { // Start process instance RuntimeService runtimeService = activitiRule.getRuntimeService(); ProcessInstance pi = runtimeService.startProcessInstanceByKey("escalationExample"); // There should be one task, with a timer : first line support TaskService taskService = activitiRule.getTaskService(); Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult(); assertEquals("First line support", task.getName()); // Manually execute the job ManagementService managementService = activitiRule.getManagementService(); Job timer = managementService.createJobQuery().singleResult(); managementService.executeJob(timer.getId()); // The timer has fired, and the second task (secondlinesupport) now exists task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult(); assertEquals("Second line support", task.getName()); }
private String startAndComplete() { RuntimeService runtimeService = activitiRule.getRuntimeService(); Map<String, Object> variableMap = new HashMap<String, Object>(); variableMap.put("isbn", "123456"); String processInstanceID = runtimeService.startProcessInstanceByKey("bookorder", variableMap).getId(); TaskService taskService = activitiRule.getTaskService(); Task task = taskService.createTaskQuery().taskCandidateGroup("sales").singleResult(); variableMap = new HashMap<String, Object>(); variableMap.put("extraInfo", "Extra information"); variableMap.put("isbn", "654321"); taskService.complete(task.getId(), variableMap); return processInstanceID; }
@Test public void startProcess() throws Exception { RepositoryService repositoryService = activitiRule.getRepositoryService(); TaskService taskService = activitiRule.getTaskService(); repositoryService .createDeployment() .addInputStream("process1.bpmn20.xml", new FileInputStream(filename)) .deploy(); RuntimeService runtimeService = activitiRule.getRuntimeService(); Map<String, Object> variableMap = new HashMap<String, Object>(); variableMap.put("name", "Activiti"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("MyProcess", variableMap); assertNotNull(processInstance.getId()); System.out.println( "id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId()); assertNotNull(taskService.createTaskQuery().taskAssignee("fg").singleResult()); }