use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.
the class ConditionalStartEventTest method testDeploymentCreatesSubscriptions.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/conditional/ConditionalStartEventTest.testSingleConditionalStartEvent.bpmn20.xml")
public void testDeploymentCreatesSubscriptions() {
// given a deployed process
String processDefinitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey(CONDITIONAL_EVENT_PROCESS).singleResult().getId();
// when
List<EventSubscription> eventSubscriptions = runtimeService.createEventSubscriptionQuery().list();
// then
assertEquals(1, eventSubscriptions.size());
EventSubscriptionEntity conditionalEventSubscription = (EventSubscriptionEntity) eventSubscriptions.get(0);
assertEquals(EventType.CONDITONAL.name(), conditionalEventSubscription.getEventType());
assertEquals(processDefinitionId, conditionalEventSubscription.getConfiguration());
assertNull(conditionalEventSubscription.getEventName());
assertNull(conditionalEventSubscription.getExecutionId());
assertNull(conditionalEventSubscription.getProcessInstanceId());
}
use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.
the class MessageStartEventTest method testUpdateProcessVersionCancelsSubscriptions.
public void testUpdateProcessVersionCancelsSubscriptions() {
String deploymentId = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/bpmn/event/message/MessageStartEventTest.testSingleMessageStartEvent.bpmn20.xml").deploy().getId();
List<EventSubscription> eventSubscriptions = runtimeService.createEventSubscriptionQuery().list();
List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().list();
assertEquals(1, eventSubscriptions.size());
assertEquals(1, processDefinitions.size());
String newDeploymentId = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/bpmn/event/message/MessageStartEventTest.testSingleMessageStartEvent.bpmn20.xml").deploy().getId();
List<EventSubscription> newEventSubscriptions = runtimeService.createEventSubscriptionQuery().list();
List<ProcessDefinition> newProcessDefinitions = repositoryService.createProcessDefinitionQuery().list();
assertEquals(1, newEventSubscriptions.size());
assertEquals(2, newProcessDefinitions.size());
for (ProcessDefinition processDefinition : newProcessDefinitions) {
if (processDefinition.getVersion() == 1) {
for (EventSubscription subscription : newEventSubscriptions) {
EventSubscriptionEntity subscriptionEntity = (EventSubscriptionEntity) subscription;
assertFalse(subscriptionEntity.getConfiguration().equals(processDefinition.getId()));
}
} else {
for (EventSubscription subscription : newEventSubscriptions) {
EventSubscriptionEntity subscriptionEntity = (EventSubscriptionEntity) subscription;
assertTrue(subscriptionEntity.getConfiguration().equals(processDefinition.getId()));
}
}
}
assertFalse(eventSubscriptions.equals(newEventSubscriptions));
repositoryService.deleteDeployment(deploymentId);
repositoryService.deleteDeployment(newDeploymentId);
}
use of org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity in project camunda-bpm-platform by camunda.
the class EventSubscriptionDeclaration method createSubscriptionForExecution.
/**
* Creates and inserts a subscription entity depending on the message type of this declaration.
*/
public EventSubscriptionEntity createSubscriptionForExecution(ExecutionEntity execution) {
EventSubscriptionEntity eventSubscriptionEntity = new EventSubscriptionEntity(execution, eventType);
String eventName = resolveExpressionOfEventName(execution);
eventSubscriptionEntity.setEventName(eventName);
if (activityId != null) {
ActivityImpl activity = execution.getProcessDefinition().findActivity(activityId);
eventSubscriptionEntity.setActivity(activity);
}
eventSubscriptionEntity.insert();
LegacyBehavior.removeLegacySubscriptionOnParent(execution, eventSubscriptionEntity);
return eventSubscriptionEntity;
}
Aggregations