use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class CompetingJoinTest method testCompetingJoins.
@Deployment
public void testCompetingJoins() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("CompetingJoinsProcess");
Execution execution1 = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId("wait1").singleResult();
Execution execution2 = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId("wait2").singleResult();
log.debug("test thread starts thread one");
SignalThread threadOne = new SignalThread(execution1.getId());
threadOne.startAndWaitUntilControlIsReturned();
log.debug("test thread continues to start thread two");
SignalThread threadTwo = new SignalThread(execution2.getId());
threadTwo.startAndWaitUntilControlIsReturned();
log.debug("test thread notifies thread 1");
threadOne.proceedAndWaitTillDone();
assertNull(threadOne.exception);
log.debug("test thread notifies thread 2");
threadTwo.proceedAndWaitTillDone();
assertNotNull(threadTwo.exception);
assertTextPresent("was updated by another transaction concurrently", threadTwo.exception.getMessage());
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class ExecutionQueryEscapeClauseTest method testQueryLikeByQueryVariableValue.
@Test
public void testQueryLikeByQueryVariableValue() {
Execution execution = runtimeService.createExecutionQuery().variableValueLike("var1", "%\\%%").singleResult();
assertNotNull(execution);
assertEquals(processInstance1.getId(), execution.getId());
execution = runtimeService.createExecutionQuery().variableValueLike("var1", "%\\_%").singleResult();
assertNotNull(execution);
assertEquals(processInstance2.getId(), execution.getId());
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class ActivityEventsTest method testActivityMessageBoundaryEventsOnUserTask.
/**
* Test events related to message events, called from the API.
*/
@Deployment
public void testActivityMessageBoundaryEventsOnUserTask() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("messageOnUserTaskProcess");
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.runtime.Execution in project Activiti by Activiti.
the class ActivityEventsTest method testActivitySignalEventsWithinProcess.
/**
* Test to verify if signals coming from an intermediate throw-event trigger
* the right events to be dispatched.
*/
@Deployment
public void testActivitySignalEventsWithinProcess() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("signalProcess");
assertNotNull(processInstance);
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(task);
Execution executionWithSignalEvent = runtimeService.createExecutionQuery().activityId("shipOrder").singleResult();
taskService.complete(task.getId());
assertEquals(1L, listener.getEventsReceived().size());
assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiSignalEvent);
ActivitiSignalEvent signalEvent = (ActivitiSignalEvent) listener.getEventsReceived().get(0);
assertEquals(ActivitiEventType.ACTIVITY_SIGNALED, signalEvent.getType());
assertEquals("shipOrder", signalEvent.getActivityId());
assertEquals(executionWithSignalEvent.getId(), signalEvent.getExecutionId());
assertEquals(executionWithSignalEvent.getProcessInstanceId(), signalEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), signalEvent.getProcessDefinitionId());
assertEquals("alert", signalEvent.getSignalName());
assertNull(signalEvent.getSignalData());
}
use of org.activiti.engine.runtime.Execution in project Activiti by Activiti.
the class ActivityEventsTest method testActivitySignalEvents.
/**
* Test events related to signalling
*/
@Deployment
public void testActivitySignalEvents() throws Exception {
// Two paths are active in the process, one receive-task and one
// intermediate catching signal-event
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("signalProcess");
assertNotNull(processInstance);
// Check regular signal through API
Execution executionWithSignal = runtimeService.createExecutionQuery().activityId("receivePayment").singleResult();
assertNotNull(executionWithSignal);
runtimeService.signal(executionWithSignal.getId());
assertEquals(1, listener.getEventsReceived().size());
assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiSignalEvent);
ActivitiSignalEvent signalEvent = (ActivitiSignalEvent) listener.getEventsReceived().get(0);
assertEquals(ActivitiEventType.ACTIVITY_SIGNALED, signalEvent.getType());
assertEquals("receivePayment", signalEvent.getActivityId());
assertEquals(executionWithSignal.getId(), signalEvent.getExecutionId());
assertEquals(executionWithSignal.getProcessInstanceId(), signalEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), signalEvent.getProcessDefinitionId());
assertNull(signalEvent.getSignalName());
assertNull(signalEvent.getSignalData());
listener.clearEventsReceived();
// Check signal using event, and pass in additional payload
Execution executionWithSignalEvent = runtimeService.createExecutionQuery().activityId("shipOrder").singleResult();
runtimeService.signalEventReceived("alert", executionWithSignalEvent.getId(), Collections.singletonMap("test", (Object) "test"));
assertEquals(1, listener.getEventsReceived().size());
assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiSignalEvent);
signalEvent = (ActivitiSignalEvent) listener.getEventsReceived().get(0);
assertEquals(ActivitiEventType.ACTIVITY_SIGNALED, signalEvent.getType());
assertEquals("shipOrder", signalEvent.getActivityId());
assertEquals(executionWithSignalEvent.getId(), signalEvent.getExecutionId());
assertEquals(executionWithSignalEvent.getProcessInstanceId(), signalEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), signalEvent.getProcessDefinitionId());
assertEquals("alert", signalEvent.getSignalName());
assertNotNull(signalEvent.getSignalData());
listener.clearEventsReceived();
assertDatabaseEventPresent(ActivitiEventType.ACTIVITY_SIGNALED);
}
Aggregations