use of org.activiti.engine.delegate.event.ActivitiActivityCancelledEvent in project Activiti by Activiti.
the class ActivityEventsTest method testActivitySignalBoundaryEventsOnUserTask.
@Deployment
public void testActivitySignalBoundaryEventsOnUserTask() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("signalOnUserTask");
assertNotNull(processInstance);
Execution executionWithSignal = runtimeService.createExecutionQuery().activityId("userTask").singleResult();
assertNotNull(executionWithSignal);
runtimeService.signalEventReceived("signalName");
assertEquals(1, listener.getEventsReceived().size());
// Next, an signal-event is expected, as a result of the message
assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiActivityCancelledEvent);
ActivitiActivityCancelledEvent signalEvent = (ActivitiActivityCancelledEvent) listener.getEventsReceived().get(0);
assertEquals(ActivitiEventType.ACTIVITY_CANCELLED, signalEvent.getType());
assertEquals("userTask", signalEvent.getActivityId());
assertEquals(executionWithSignal.getId(), signalEvent.getExecutionId());
assertEquals(executionWithSignal.getProcessInstanceId(), signalEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), signalEvent.getProcessDefinitionId());
assertNotNull(signalEvent.getCause());
assertTrue(signalEvent.getCause() instanceof SignalEventSubscriptionEntity);
SignalEventSubscriptionEntity cause = (SignalEventSubscriptionEntity) signalEvent.getCause();
assertEquals("signalName", cause.getEventName());
}
use of org.activiti.engine.delegate.event.ActivitiActivityCancelledEvent in project Activiti by Activiti.
the class ActivityEventsTest method testActivityMessageBoundaryEventsOnSubProcess.
/**
* Test events related to message events, called from the API.
*/
@Deployment
public void testActivityMessageBoundaryEventsOnSubProcess() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("messageOnSubProcess");
assertNotNull(processInstance);
Execution executionWithMessage = runtimeService.createExecutionQuery().activityId("cloudformtask1").singleResult();
assertNotNull(executionWithMessage);
runtimeService.messageEventReceived("message_1", executionWithMessage.getId());
assertEquals(2, listener.getEventsReceived().size());
// First, a message-event is expected
assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiMessageEvent);
ActivitiMessageEvent messageEvent = (ActivitiMessageEvent) listener.getEventsReceived().get(0);
assertEquals(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED, messageEvent.getType());
assertEquals("boundaryMessageEventCatching", messageEvent.getActivityId());
assertEquals(executionWithMessage.getId(), messageEvent.getExecutionId());
assertEquals(executionWithMessage.getProcessInstanceId(), messageEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), messageEvent.getProcessDefinitionId());
assertEquals("message_1", messageEvent.getMessageName());
assertNull(messageEvent.getMessageData());
// Next, an signal-event is expected, as a result of the message
assertTrue(listener.getEventsReceived().get(1) instanceof ActivitiActivityCancelledEvent);
ActivitiActivityCancelledEvent signalEvent = (ActivitiActivityCancelledEvent) listener.getEventsReceived().get(1);
assertEquals(ActivitiEventType.ACTIVITY_CANCELLED, signalEvent.getType());
assertEquals("cloudformtask1", signalEvent.getActivityId());
assertEquals(executionWithMessage.getId(), signalEvent.getExecutionId());
assertEquals(executionWithMessage.getProcessInstanceId(), signalEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), signalEvent.getProcessDefinitionId());
assertNotNull(signalEvent.getCause());
assertTrue(signalEvent.getCause() instanceof MessageEventSubscriptionEntity);
MessageEventSubscriptionEntity cause = (MessageEventSubscriptionEntity) signalEvent.getCause();
assertEquals("message_1", cause.getEventName());
assertDatabaseEventPresent(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED);
}
use of org.activiti.engine.delegate.event.ActivitiActivityCancelledEvent 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.ActivitiActivityCancelledEvent 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);
}
Aggregations