use of org.activiti.engine.delegate.event.ActivitiEvent in project Activiti by Activiti.
the class ActivityEventsTest method testActivityTimeOutEventInSubProcess.
@Deployment(resources = "org/activiti/engine/test/bpmn/event/timer/BoundaryTimerEventTest.testTimerOnNestingOfSubprocesses.bpmn20.xml")
public void testActivityTimeOutEventInSubProcess() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerOnNestedSubprocesses");
Job theJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(theJob);
// Force timer to fire
Calendar timeToFire = Calendar.getInstance();
timeToFire.add(Calendar.HOUR, 2);
timeToFire.add(Calendar.SECOND, 5);
processEngineConfiguration.getClock().setCurrentTime(timeToFire.getTime());
waitForJobExecutorToProcessAllJobs(2000, 200);
// Check timeout-events have been dispatched
assertEquals(3, listener.getEventsReceived().size());
List<String> eventIdList = new ArrayList<String>();
for (ActivitiEvent event : listener.getEventsReceived()) {
assertEquals(ActivitiEventType.ACTIVITY_CANCELLED, event.getType());
assertTrue("TIMER is the cause of the cancellation", ((ActivitiActivityCancelledEvent) event).getCause() instanceof TimerEntity);
eventIdList.add(((ActivitiActivityEventImpl) event).getActivityId());
}
assertTrue(eventIdList.indexOf("innerTask1") >= 0);
assertTrue(eventIdList.indexOf("innerTask2") >= 0);
assertTrue(eventIdList.indexOf("innerFork") >= 0);
}
use of org.activiti.engine.delegate.event.ActivitiEvent in project Activiti by Activiti.
the class ActivityEventsTest method testActivityErrorEvents.
/**
* Test events related to error-events
*/
@Deployment
public void testActivityErrorEvents() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("errorProcess");
assertNotNull(processInstance);
// Error-handling should have ended the process
ProcessInstance afterErrorInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertNull(afterErrorInstance);
ActivitiErrorEvent errorEvent = null;
for (ActivitiEvent event : listener.getEventsReceived()) {
if (event instanceof ActivitiErrorEvent) {
if (errorEvent == null) {
errorEvent = (ActivitiErrorEvent) event;
} else {
fail("Only one ActivityErrorEvent expected");
}
}
}
assertNotNull(errorEvent);
assertEquals(ActivitiEventType.ACTIVITY_ERROR_RECEIVED, errorEvent.getType());
assertEquals("catchError", errorEvent.getActivityId());
assertEquals("123", errorEvent.getErrorCode());
assertEquals(processInstance.getId(), errorEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), errorEvent.getProcessDefinitionId());
assertFalse(processInstance.getId().equals(errorEvent.getExecutionId()));
}
use of org.activiti.engine.delegate.event.ActivitiEvent in project Activiti by Activiti.
the class ActivityEventsTest method testActivityTimeOutEvent.
@Deployment(resources = "org/activiti/engine/test/api/event/JobEventsTest.testJobEntityEvents.bpmn20.xml")
public void testActivityTimeOutEvent() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testJobEvents");
Job theJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(theJob);
// Force timer to fire
Calendar tomorrow = Calendar.getInstance();
tomorrow.add(Calendar.DAY_OF_YEAR, 1);
processEngineConfiguration.getClock().setCurrentTime(tomorrow.getTime());
waitForJobExecutorToProcessAllJobs(2000, 100);
// Check timeout has been dispatched
assertEquals(1, listener.getEventsReceived().size());
ActivitiEvent activitiEvent = listener.getEventsReceived().get(0);
assertEquals("ACTIVITY_CANCELLED event expected", ActivitiEventType.ACTIVITY_CANCELLED, activitiEvent.getType());
ActivitiActivityCancelledEvent cancelledEvent = (ActivitiActivityCancelledEvent) activitiEvent;
assertTrue("TIMER is the cause of the cancellation", cancelledEvent.getCause() instanceof TimerEntity);
}
use of org.activiti.engine.delegate.event.ActivitiEvent in project Activiti by Activiti.
the class ActivityEventsTest method testActivityTimeOutEventInCallActivity.
@Deployment
public void testActivityTimeOutEventInCallActivity() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerOnCallActivity");
Job theJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(theJob);
// Force timer to fire
Calendar timeToFire = Calendar.getInstance();
timeToFire.add(Calendar.HOUR, 2);
timeToFire.add(Calendar.SECOND, 5);
processEngineConfiguration.getClock().setCurrentTime(timeToFire.getTime());
waitForJobExecutorToProcessAllJobs(20000, 500);
// Check timeout-events have been dispatched
assertEquals(4, listener.getEventsReceived().size());
List<String> eventIdList = new ArrayList<String>();
for (ActivitiEvent event : listener.getEventsReceived()) {
assertEquals(ActivitiEventType.ACTIVITY_CANCELLED, event.getType());
assertTrue("TIMER is the cause of the cancellation", ((ActivitiActivityCancelledEvent) event).getCause() instanceof TimerEntity);
eventIdList.add(((ActivitiActivityEventImpl) event).getActivityId());
}
assertTrue(eventIdList.indexOf("innerTask1") >= 0);
assertTrue(eventIdList.indexOf("innerTask2") >= 0);
assertTrue(eventIdList.indexOf("innerFork") >= 0);
assertTrue(eventIdList.indexOf("callActivity") >= 0);
}
use of org.activiti.engine.delegate.event.ActivitiEvent in project Activiti by Activiti.
the class SimpleSimulationRunTest method getTransformers.
private List<Function<ActivitiEvent, SimulationEvent>> getTransformers() {
List<Function<ActivitiEvent, SimulationEvent>> transformers = new ArrayList<Function<ActivitiEvent, SimulationEvent>>();
transformers.add(new DeploymentCreateTransformer(DEPLOYMENT_CREATED_EVENT_TYPE, DEPLOYMENT_RESOURCES_KEY));
transformers.add(new ProcessInstanceCreateTransformer(PROCESS_INSTANCE_START_EVENT_TYPE, PROCESS_DEFINITION_ID_KEY, BUSINESS_KEY, VARIABLES_KEY));
transformers.add(new UserTaskCompleteTransformer(USER_TASK_COMPLETED_EVENT_TYPE));
return transformers;
}
Aggregations