use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class InvocationContextTest method testInvokeProcessApplicationWithContextOnMessageReceived.
@Test
@OperateOnDeployment("app")
public void testInvokeProcessApplicationWithContextOnMessageReceived() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("messageProcess");
ProcessApplicationWithInvocationContext.clearInvocationContext();
EventSubscription messageSubscription = runtimeService.createEventSubscriptionQuery().eventType("message").processInstanceId(processInstance.getId()).singleResult();
assertThat(messageSubscription, is(notNullValue()));
runtimeService.messageEventReceived(messageSubscription.getEventName(), messageSubscription.getExecutionId());
InvocationContext invocationContext = ProcessApplicationWithInvocationContext.getInvocationContext();
assertThat(invocationContext, is(notNullValue()));
assertThat(invocationContext.getExecution(), is(notNullValue()));
assertThat(invocationContext.getExecution().getId(), is(messageSubscription.getExecutionId()));
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class InterruptingEventSubProcessTest method testCancelEventSubscriptionsWhenReceivingAMessage.
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/subprocess/InterruptingEventSubProcessTest.testCancelEventSubscriptions.bpmn")
public void testCancelEventSubscriptionsWhenReceivingAMessage() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("process");
TaskQuery taskQuery = taskService.createTaskQuery();
EventSubscriptionQuery eventSubscriptionQuery = runtimeService.createEventSubscriptionQuery();
Task task = taskQuery.singleResult();
assertNotNull(task);
assertEquals("taskBeforeInterruptingEventSuprocess", task.getTaskDefinitionKey());
List<EventSubscription> eventSubscriptions = eventSubscriptionQuery.list();
assertEquals(2, eventSubscriptions.size());
runtimeService.messageEventReceived("newMessage", pi.getId());
task = taskQuery.singleResult();
assertNotNull(task);
assertEquals("taskAfterMessageStartEvent", task.getTaskDefinitionKey());
assertEquals(0, eventSubscriptionQuery.count());
try {
runtimeService.signalEventReceived("newSignal", pi.getId());
fail("A ProcessEngineException was expected.");
} catch (ProcessEngineException e) {
// expected exception;
}
taskService.complete(task.getId());
assertProcessEnded(pi.getId());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class SignalEventDeploymentTest method testUpdateEventSubscriptionOnDeployment.
public void testUpdateEventSubscriptionOnDeployment() {
deploymentId = repositoryService.createDeployment().addClasspathResource(SIGNAL_START_EVENT_PROCESS).deploy().getId();
EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().eventType("signal").singleResult();
assertNotNull(eventSubscription);
assertEquals("alert", eventSubscription.getEventName());
// deploy a new version of the process with different signal name
String newDeploymentId = repositoryService.createDeployment().addClasspathResource(SIGNAL_START_EVENT_PROCESS_NEW_VERSION).deploy().getId();
ProcessDefinition newProcessDefinition = repositoryService.createProcessDefinitionQuery().latestVersion().singleResult();
assertEquals(2, newProcessDefinition.getVersion());
List<EventSubscription> newEventSubscriptions = runtimeService.createEventSubscriptionQuery().eventType("signal").list();
// only one event subscription for the new version of the process definition
assertEquals(1, newEventSubscriptions.size());
EventSubscriptionEntity newEventSubscription = (EventSubscriptionEntity) newEventSubscriptions.iterator().next();
assertEquals(newProcessDefinition.getId(), newEventSubscription.getConfiguration());
assertEquals("abort", newEventSubscription.getEventName());
// clean db
repositoryService.deleteDeployment(newDeploymentId);
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class SignalEventDeploymentTest method testCreateEventSubscriptionOnDeployment.
public void testCreateEventSubscriptionOnDeployment() {
deploymentId = repositoryService.createDeployment().addClasspathResource(SIGNAL_START_EVENT_PROCESS).deploy().getId();
EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().singleResult();
assertNotNull(eventSubscription);
assertEquals(EventType.SIGNAL.name(), eventSubscription.getEventType());
assertEquals("alert", eventSubscription.getEventName());
assertEquals("start", eventSubscription.getActivityId());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class SignalEventReceivedBuilderTest method testSendSignalWithExecutionId.
public void testSendSignalWithExecutionId() {
deployment(signalCatchProcess("signalCatch"), signalCatchProcess("signalCatch2"));
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("signalCatch");
runtimeService.startProcessInstanceByKey("signalCatch2");
EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().processInstanceId(processInstance.getId()).singleResult();
String executionId = eventSubscription.getExecutionId();
runtimeService.createSignalEvent("signal").executionId(executionId).send();
assertThat(taskService.createTaskQuery().count(), is(1L));
}
Aggregations