Java Code Examples for org.camunda.bpm.engine.runtime.EventSubscription#getId()

The following examples show how to use org.camunda.bpm.engine.runtime.EventSubscription#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReceiveTaskTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiSequentialReceiveTask.bpmn20.xml")
public void testSupportsLegacySignalingOnSequentialMultiReceiveTask() {

  // given: a process instance waiting in the first receive tasks
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");

  // expect: there is a message event subscription for the first task
  List<EventSubscription> subscriptionList = getEventSubscriptionList();
  assertEquals(1, subscriptionList.size());
  EventSubscription subscription = subscriptionList.get(0);
  String firstSubscriptionId = subscription.getId();

  // then: we can signal the waiting receive task
  runtimeService.signal(getExecutionId(processInstance.getId(), "waitState"));

  // expect: there is a new subscription created for the second receive task instance
  subscriptionList = getEventSubscriptionList();
  assertEquals(1, subscriptionList.size());
  subscription = subscriptionList.get(0);
  assertFalse(firstSubscriptionId.equals(subscription.getId()));

  // then: we can signal the second waiting receive task
  runtimeService.signal(getExecutionId(processInstance.getId(), "waitState"));

  // expect: no event subscription left
  assertEquals(0, getEventSubscriptionList().size());

  // expect: one user task is created
  Task task = taskService.createTaskQuery().singleResult();
  taskService.complete(task.getId());

  // expect: this ends the process instance
  assertProcessEnded(processInstance.getId());
}
 
Example 2
Source File: ReceiveTaskTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiSequentialReceiveTask.bpmn20.xml")
public void testSupportsMessageEventReceivedOnSequentialMultiReceiveTask() {

  // given: a process instance waiting in the first receive tasks
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");

  // expect: there is a message event subscription for the first task
  List<EventSubscription> subscriptionList = getEventSubscriptionList();
  assertEquals(1, subscriptionList.size());
  EventSubscription subscription = subscriptionList.get(0);
  String firstSubscriptionId = subscription.getId();

  // then: we can trigger the event subscription
  runtimeService.messageEventReceived(subscription.getEventName(), subscription.getExecutionId());

  // expect: there is a new subscription created for the second receive task instance
  subscriptionList = getEventSubscriptionList();
  assertEquals(1, subscriptionList.size());
  subscription = subscriptionList.get(0);
  assertFalse(firstSubscriptionId.equals(subscription.getId()));

  // then: we can trigger the second event subscription
  runtimeService.messageEventReceived(subscription.getEventName(), subscription.getExecutionId());

  // expect: no event subscription left
  assertEquals(0, getEventSubscriptionList().size());

  // expect: one user task is created
  Task task = taskService.createTaskQuery().singleResult();
  taskService.complete(task.getId());

  // expect: this ends the process instance
  assertProcessEnded(processInstance.getId());
}
 
Example 3
Source File: ReceiveTaskTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiSequentialReceiveTask.bpmn20.xml")
public void testSupportsCorrelateMessageOnSequentialMultiReceiveTask() {

  // given: a process instance waiting in the first receive tasks
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");

  // expect: there is a message event subscription for the first task
  List<EventSubscription> subscriptionList = getEventSubscriptionList();
  assertEquals(1, subscriptionList.size());
  EventSubscription subscription = subscriptionList.get(0);
  String firstSubscriptionId = subscription.getId();

  // then: we can trigger the event subscription
  runtimeService.correlateMessage(subscription.getEventName());

  // expect: there is a new subscription created for the second receive task instance
  subscriptionList = getEventSubscriptionList();
  assertEquals(1, subscriptionList.size());
  subscription = subscriptionList.get(0);
  assertFalse(firstSubscriptionId.equals(subscription.getId()));

  // then: we can trigger the second event subscription
  runtimeService.correlateMessage(subscription.getEventName());

  // expect: no event subscription left
  assertEquals(0, getEventSubscriptionList().size());

  // expect: one user task is created
  Task task = taskService.createTaskQuery().singleResult();
  taskService.complete(task.getId());

  // expect: this ends the process instance
  assertProcessEnded(processInstance.getId());
}
 
Example 4
Source File: EventSubscriptionDto.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static EventSubscriptionDto fromEventSubscription(EventSubscription eventSubscription) {
  EventSubscriptionDto dto = new EventSubscriptionDto();
  dto.id = eventSubscription.getId();
  dto.eventType = eventSubscription.getEventType();
  dto.eventName = eventSubscription.getEventName();
  dto.executionId = eventSubscription.getExecutionId();
  dto.processInstanceId = eventSubscription.getProcessInstanceId();
  dto.activityId = eventSubscription.getActivityId();
  dto.createdDate = eventSubscription.getCreated();
  dto.tenantId = eventSubscription.getTenantId();

  return dto;
}