use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class BoundaryErrorEventTest method testCatchErrorOnSubprocessThrownByInterruptingEventSubprocess.
@Deployment
public void testCatchErrorOnSubprocessThrownByInterruptingEventSubprocess() {
runtimeService.startProcessInstanceByKey("testProcess");
EventSubscription messageSubscription = runtimeService.createEventSubscriptionQuery().singleResult();
runtimeService.messageEventReceived("message", messageSubscription.getExecutionId());
// should successfully have reached the task following the boundary event
Execution taskExecution = runtimeService.createExecutionQuery().activityId("afterBoundaryTask").singleResult();
assertNotNull(taskExecution);
Task task = taskService.createTaskQuery().executionId(taskExecution.getId()).singleResult();
assertNotNull(task);
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationEventTest method testStartBeforeMessageStartEvent.
@Deployment(resources = MESSAGE_START_EVENT_PROCESS)
public void testStartBeforeMessageStartEvent() {
runtimeService.correlateMessage("startMessage");
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertNotNull(processInstance);
EventSubscription startEventSubscription = runtimeService.createEventSubscriptionQuery().singleResult();
assertNotNull(startEventSubscription);
String processInstanceId = processInstance.getId();
// when I start before the message start event
runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("theStart").execute();
// then there are two instances of "task"
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("task").activity("task").done());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task").concurrent().noScope().up().child("task").concurrent().noScope().done());
// and there is only the message start event subscription
EventSubscription subscription = runtimeService.createEventSubscriptionQuery().singleResult();
assertNotNull(subscription);
assertEquals(startEventSubscription.getId(), subscription.getId());
completeTasksInOrder("task", "task");
assertProcessEnded(processInstanceId);
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class EventSubscriptionQueryTest method testQueryByEventSubscriptionId.
public void testQueryByEventSubscriptionId() {
createExampleEventSubscriptions();
List<EventSubscription> list = runtimeService.createEventSubscriptionQuery().eventName("messageName2").list();
assertEquals(1, list.size());
EventSubscription eventSubscription = list.get(0);
EventSubscriptionQuery query = runtimeService.createEventSubscriptionQuery().eventSubscriptionId(eventSubscription.getId());
assertEquals(1, query.count());
assertEquals(1, query.list().size());
assertNotNull(query.singleResult());
try {
runtimeService.createEventSubscriptionQuery().eventSubscriptionId(null).list();
fail("Expected ProcessEngineException");
} catch (ProcessEngineException e) {
}
cleanDb();
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class EventSubscriptionQueryTest method testMultipleEventSubscriptions.
@Deployment
public void testMultipleEventSubscriptions() {
String message = "cancelation-requested";
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
assertTrue(areJobsAvailable());
long eventSubscriptionCount = runtimeService.createEventSubscriptionQuery().count();
assertEquals(2, eventSubscriptionCount);
EventSubscription messageEvent = runtimeService.createEventSubscriptionQuery().eventType("message").singleResult();
assertEquals(message, messageEvent.getEventName());
EventSubscription compensationEvent = runtimeService.createEventSubscriptionQuery().eventType("compensate").singleResult();
assertNull(compensationEvent.getEventName());
runtimeService.createMessageCorrelation(message).processInstanceId(processInstance.getId()).correlate();
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class BatchMigrationTest method testUpdateEventTrigger.
@Test
public void testUpdateEventTrigger() {
// given
String newMessageName = "newMessage";
ProcessDefinition sourceProcessDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_RECEIVE_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = migrationRule.deployAndGetDefinition(modify(ProcessModels.ONE_RECEIVE_TASK_PROCESS).renameMessage("Message", newMessageName));
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().updateEventTriggers().build();
Batch batch = runtimeService.newMigration(migrationPlan).processInstanceIds(Collections.singletonList(processInstance.getId())).executeAsync();
helper.executeSeedJob(batch);
// when
helper.executeJobs(batch);
// then the message event subscription's event name was changed
EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().singleResult();
assertEquals(newMessageName, eventSubscription.getEventName());
}
Aggregations