using a boundaryTimer which the timeDuration set to ‘PT5S’, i think the process will going to ‘nextTask’ after 5 seconds.
<startEvent id="startevent1" name="Start"></startEvent>
<endEvent id="endevent1" name="End"></endEvent>
<userTask id="firstTask" name="firstTask" activiti:dueDate="${finishTime}"></userTask>
<sequenceFlow id="flow3" sourceRef="startevent1" targetRef="firstTask"></sequenceFlow>
<userTask id="nextTask" name="nextTask" activiti:assignee="zn1"></userTask>
<sequenceFlow id="flow6" sourceRef="nextTask" targetRef="endevent1"></sequenceFlow>
<boundaryEvent id="boundarytimer1" name="Timer" attachedToRef="firstTask" cancelActivity="true">
<timerEventDefinition>
<timeDuration>PT5S</timeDuration>
</timerEventDefinition>
</boundaryEvent>
<sequenceFlow id="flow7" sourceRef="boundarytimer1" targetRef="nextTask"></sequenceFlow>
<sequenceFlow id="flow8" sourceRef="firstTask" targetRef="endevent1"></sequenceFlow>
write the test code:
@Test
@Deployment(resources = { “processes/timerProcess.bpmn” })
public void testLoop() throws InterruptedException {
DateTime dt = new DateTime();
Map<String, Object> vars = new HashMap<>();
vars.put(“finishTime”, dt.plusSeconds(5).toDate()); //
ProcessInstance ins = runtimeService.startProcessInstanceByKey(“timerProcess”, “1”, vars);
List ids = runtimeService.getActiveActivityIds(ins.getId());
assertEquals(“firstTask,boundarytimer1”, String.join(“,”, ids));
Task t = taskService.createTaskQuery().processInstanceId(ins.getId()).singleResult();
System.out.println(t.getName());
assertEquals(t.getName(), "firstTask");
Thread.sleep(6000l); // sleeping 6 seconds
t = taskService.createTaskQuery().processInstanceId(ins.getId()).singleResult();
assertEquals(t.getName(), "nextTask"); // here will be failed, the real value is 'firstTask'
}
the test going failed, any help will be appreciated.