// -> has left the transaction using the "normal" sequence flow
List<String> activeActivityIds = runtimeService.getActiveActivityIds(processInstance.getId());
assertTrue(activeActivityIds.contains("afterSuccess"));
// there is a compensate event subscription for the transaction under the process instance
EventSubscriptionEntity eventSubscriptionEntity = createEventSubscriptionQuery().eventType("compensate").activityId("tx").executionId(processInstance.getId()).singleResult();
// there is an event-scope execution associated with the event-subscription:
assertNotNull(eventSubscriptionEntity.getConfiguration());
Execution eventScopeExecution = runtimeService.createExecutionQuery().executionId(eventSubscriptionEntity.getConfiguration()).singleResult();
assertNotNull(eventScopeExecution);
// we still have compensate event subscriptions for the compensation handlers, only now they are part of the event scope
assertEquals(5,createEventSubscriptionQuery().eventType("compensate").activityId("undoBookHotel").executionId(eventScopeExecution.getId()).count());
assertEquals(1,createEventSubscriptionQuery().eventType("compensate").activityId("undoBookFlight").executionId(eventScopeExecution.getId()).count());