use of org.activiti.engine.event.EventLogEntry in project Activiti by Activiti.
the class EventOverviewPanel method getTransformers.
protected List<Function<EventLogEntry, SimulationEvent>> getTransformers() {
List<Function<EventLogEntry, SimulationEvent>> transformers = new ArrayList<Function<EventLogEntry, SimulationEvent>>();
transformers.add(new EventLogProcessInstanceCreateTransformer(PROCESS_INSTANCE_START_EVENT_TYPE, PROCESS_DEFINITION_ID_KEY, SIMULATION_BUSINESS_KEY, VARIABLES_KEY));
transformers.add(new EventLogUserTaskCompleteTransformer(USER_TASK_COMPLETED_EVENT_TYPE));
return transformers;
}
use of org.activiti.engine.event.EventLogEntry in project Activiti by Activiti.
the class ReplayEventLogTest method testProcessInstanceStartEvents.
@Test
public void testProcessInstanceStartEvents() throws Exception {
ProcessEngineImpl processEngine = initProcessEngine();
TaskService taskService = processEngine.getTaskService();
RuntimeService runtimeService = processEngine.getRuntimeService();
ManagementService managementService = processEngine.getManagementService();
HistoryService historyService = processEngine.getHistoryService();
// record events
Map<String, Object> variables = new HashMap<String, Object>();
variables.put(TEST_VARIABLE, TEST_VALUE);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(USERTASK_PROCESS, BUSINESS_KEY, variables);
Task task = taskService.createTaskQuery().taskDefinitionKey("userTask").singleResult();
TimeUnit.MILLISECONDS.sleep(50);
variables = new HashMap<String, Object>();
variables.put(TASK_TEST_VARIABLE, TASK_TEST_VALUE);
taskService.complete(task.getId(), variables);
// transform log events
List<EventLogEntry> eventLogEntries = managementService.getEventLogEntries(null, null);
EventLogTransformer transformer = new EventLogTransformer(getTransformers());
List<SimulationEvent> simulationEvents = transformer.transform(eventLogEntries);
SimpleEventCalendar eventCalendar = new SimpleEventCalendar(processEngine.getProcessEngineConfiguration().getClock(), new SimulationEventComparator());
eventCalendar.addEvents(simulationEvents);
// replay process instance run
final SimulationDebugger simRun = new ReplaySimulationRun(processEngine, eventCalendar, getReplayHandlers(processInstance.getId()));
simRun.init(new NoExecutionVariableScope());
// original process is finished - there should not be any running process instance/task
assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
simRun.step();
// replay process was started
ProcessInstance replayProcessInstance = runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).singleResult();
assertNotNull(replayProcessInstance);
assertTrue(replayProcessInstance.getId().equals(processInstance.getId()) == false);
assertEquals(TEST_VALUE, runtimeService.getVariable(replayProcessInstance.getId(), TEST_VARIABLE));
// there should be one task
assertEquals(1, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
simRun.step();
// userTask was completed - replay process was finished
assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(replayProcessInstance.getId()).variableName(TASK_TEST_VARIABLE).singleResult();
assertNotNull(variableInstance);
assertEquals(TASK_TEST_VALUE, variableInstance.getValue());
// close simulation
simRun.close();
processEngine.close();
ProcessEngines.destroy();
}
use of org.activiti.engine.event.EventLogEntry in project Activiti by Activiti.
the class DatabaseEventLoggerTest method testStandaloneTaskEvents.
public void testStandaloneTaskEvents() throws JsonParseException, JsonMappingException, IOException {
Task task = taskService.newTask();
task.setAssignee("kermit");
task.setTenantId("myTenant");
taskService.saveTask(task);
List<EventLogEntry> events = managementService.getEventLogEntries(null, null);
assertEquals(2, events.size());
assertEquals("TASK_CREATED", events.get(0).getType());
assertEquals("TASK_ASSIGNED", events.get(1).getType());
for (EventLogEntry eventLogEntry : events) {
Map<String, Object> data = objectMapper.readValue(eventLogEntry.getData(), new TypeReference<HashMap<String, Object>>() {
});
assertEquals("myTenant", data.get(Fields.TENANT_ID));
}
// Cleanup
taskService.deleteTask(task.getId(), true);
for (EventLogEntry eventLogEntry : managementService.getEventLogEntries(null, null)) {
managementService.deleteEventLogEntry(eventLogEntry.getLogNumber());
}
}
use of org.activiti.engine.event.EventLogEntry in project Activiti by Activiti.
the class ActivityEventsTest method assertDatabaseEventPresent.
protected void assertDatabaseEventPresent(ActivitiEventType eventType) {
String eventTypeString = eventType.name();
List<EventLogEntry> eventLogEntries = managementService.getEventLogEntries(0L, 100000L);
boolean found = false;
for (EventLogEntry entry : eventLogEntries) {
if (entry.getType().equals(eventTypeString)) {
found = true;
}
}
assertTrue(found);
}
use of org.activiti.engine.event.EventLogEntry in project Activiti by Activiti.
the class ActivityEventsTest method tearDown.
@Override
protected void tearDown() throws Exception {
if (listener != null) {
listener.clearEventsReceived();
processEngineConfiguration.getEventDispatcher().removeEventListener(listener);
}
// Remove entries
for (EventLogEntry eventLogEntry : managementService.getEventLogEntries(null, null)) {
managementService.deleteEventLogEntry(eventLogEntry.getLogNumber());
}
// Database event logger teardown
runtimeService.removeEventListener(databaseEventLogger);
super.tearDown();
}
Aggregations