use of org.activiti.engine.delegate.event.ActivitiEvent in project Activiti by Activiti.
the class AbstractPlaybackTest method getTransformers.
protected List<Function<ActivitiEvent, SimulationEvent>> getTransformers() {
List<Function<ActivitiEvent, SimulationEvent>> transformers = new ArrayList<Function<ActivitiEvent, SimulationEvent>>();
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;
}
use of org.activiti.engine.delegate.event.ActivitiEvent in project Activiti by Activiti.
the class ReplayRunTest method getTransformers.
private static List<Function<ActivitiEvent, SimulationEvent>> getTransformers() {
List<Function<ActivitiEvent, SimulationEvent>> transformers = new ArrayList<Function<ActivitiEvent, SimulationEvent>>();
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;
}
use of org.activiti.engine.delegate.event.ActivitiEvent in project Activiti by Activiti.
the class HistoricActivityEventsTest method testHistoricActivityEventDispatched.
/**
* Test added to assert the historic activity instance event
*/
@Deployment
public void testHistoricActivityEventDispatched() {
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("TestActivityEvents");
assertNotNull(processInstance);
for (int i = 0; i < 2; i++) {
taskService.complete(taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult().getId());
}
List<ActivitiEvent> events = listener.getEventsReceived();
// Process instance start
assertEquals(ActivitiEventType.HISTORIC_PROCESS_INSTANCE_CREATED, events.get(0).getType());
// main start
assertEquals(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, events.get(1).getType());
assertEquals("mainStart", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(1)).getEntity()).getActivityId()));
assertEquals(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_ENDED, events.get(2).getType());
assertEquals("mainStart", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(2)).getEntity()).getActivityId()));
assertNotNull("mainStart", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(2)).getEntity()).getEndTime()));
// Subprocess start
assertEquals(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, events.get(3).getType());
assertEquals("subProcess", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(3)).getEntity()).getActivityId()));
// subProcessStart
assertEquals(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, events.get(4).getType());
assertEquals("subProcessStart", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(4)).getEntity()).getActivityId()));
assertEquals(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_ENDED, events.get(5).getType());
assertEquals("subProcessStart", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(5)).getEntity()).getActivityId()));
assertNotNull("subProcessStart", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(5)).getEntity()).getEndTime()));
// Task a
assertEquals(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, events.get(6).getType());
assertEquals("a", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(6)).getEntity()).getActivityId()));
assertEquals(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_ENDED, events.get(7).getType());
assertEquals("a", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(7)).getEntity()).getActivityId()));
assertNotNull("a", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(7)).getEntity()).getEndTime()));
// Task b
assertEquals(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, events.get(8).getType());
assertEquals("b", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(8)).getEntity()).getActivityId()));
assertEquals(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_ENDED, events.get(9).getType());
assertEquals("b", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(9)).getEntity()).getActivityId()));
assertNotNull("b", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(9)).getEntity()).getEndTime()));
// subProcessEnd
assertEquals(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, events.get(10).getType());
assertEquals("subprocessEnd", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(10)).getEntity()).getActivityId()));
assertEquals(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_ENDED, events.get(11).getType());
assertEquals("subprocessEnd", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(11)).getEntity()).getActivityId()));
assertNotNull("subprocessEnd", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(11)).getEntity()).getEndTime()));
// subProcess end
assertEquals(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_ENDED, events.get(12).getType());
assertEquals("subProcess", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(12)).getEntity()).getActivityId()));
assertNotNull("subProcess", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(12)).getEntity()).getEndTime()));
// main end
assertEquals(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, events.get(13).getType());
assertEquals("mainEnd", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(13)).getEntity()).getActivityId()));
assertEquals(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_ENDED, events.get(14).getType());
assertEquals("mainEnd", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(14)).getEntity()).getActivityId()));
assertNotNull("mainEnd", (((HistoricActivityInstance) ((ActivitiEntityEvent) events.get(14)).getEntity()).getEndTime()));
// Process instance end
assertEquals(ActivitiEventType.HISTORIC_PROCESS_INSTANCE_ENDED, events.get(15).getType());
}
}
use of org.activiti.engine.delegate.event.ActivitiEvent in project Activiti by Activiti.
the class JobEventsTest method checkEventCount.
private void checkEventCount(int expectedCount, ActivitiEventType eventType) {
// count timer cancelled events
int timerCancelledCount = 0;
List<ActivitiEvent> eventsReceived = listener.getEventsReceived();
for (ActivitiEvent eventReceived : eventsReceived) {
if (eventType.equals(eventReceived.getType())) {
timerCancelledCount++;
}
}
assertEquals(eventType.name() + " event was expected " + expectedCount + " times.", expectedCount, timerCancelledCount);
}
use of org.activiti.engine.delegate.event.ActivitiEvent in project Activiti by Activiti.
the class JobEventsTest method testJobEntityEventsException.
/**
* Test create, update and delete events of jobs entities.
*/
@Deployment
public void testJobEntityEventsException() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testJobEvents");
Job theJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(theJob);
// Set retries to 1, to prevent multiple chains of events being thrown
managementService.setJobRetries(theJob.getId(), 1);
listener.clearEventsReceived();
// Force timer to fire
Calendar tomorrow = Calendar.getInstance();
tomorrow.add(Calendar.DAY_OF_YEAR, 1);
processEngineConfiguration.getClock().setCurrentTime(tomorrow.getTime());
try {
managementService.executeJob(theJob.getId());
fail("Expected exception");
} catch (Exception e) {
// exception expected
}
// Check delete-event has been dispatched
assertEquals(5, listener.getEventsReceived().size());
// First, the timer was fired
ActivitiEvent event = listener.getEventsReceived().get(0);
assertEquals(ActivitiEventType.TIMER_FIRED, event.getType());
checkEventContext(event, theJob, true);
// Second, the job-entity was deleted, as the job was executed
event = listener.getEventsReceived().get(1);
assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
checkEventContext(event, theJob, true);
// Next, a job failed event is dispatched
event = listener.getEventsReceived().get(2);
assertEquals(ActivitiEventType.JOB_EXECUTION_FAILURE, event.getType());
checkEventContext(event, theJob, true);
// Finally, an update-event is received and the job count is decremented
event = listener.getEventsReceived().get(3);
assertEquals(ActivitiEventType.ENTITY_UPDATED, event.getType());
checkEventContext(event, theJob, true);
event = listener.getEventsReceived().get(4);
assertEquals(ActivitiEventType.JOB_RETRIES_DECREMENTED, event.getType());
assertEquals(0, ((Job) ((ActivitiEntityEvent) event).getEntity()).getRetries());
checkEventContext(event, theJob, true);
}
Aggregations