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