use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class MultiTenancyStartProcessInstanceByConditionCmdTenantCheckTest method testEvaluateConditionByProcessDefinitionIdWithAuthenticatedTenants.
@Test
public void testEvaluateConditionByProcessDefinitionIdWithAuthenticatedTenants() {
// given
testRule.deployForTenant(TENANT_ONE, PROCESS);
ensureEventSubscriptions(1);
ProcessDefinition processDefinition = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("conditionStart").singleResult();
engineRule.getIdentityService().setAuthentication("user", null, Arrays.asList(TENANT_ONE));
// when
List<ProcessInstance> instances = engineRule.getRuntimeService().createConditionEvaluation().setVariable("foo", "bar").tenantId(TENANT_ONE).processDefinitionId(processDefinition.getId()).evaluateStartConditions();
// then
assertNotNull(instances);
assertEquals(1, instances.size());
assertEquals(TENANT_ONE, instances.get(0).getTenantId());
engineRule.getIdentityService().clearAuthentication();
ProcessInstanceQuery processInstanceQuery = engineRule.getRuntimeService().createProcessInstanceQuery();
assertEquals(1, processInstanceQuery.tenantIdIn(TENANT_ONE).count());
EventSubscription eventSubscription = engineRule.getRuntimeService().createEventSubscriptionQuery().singleResult();
assertEquals(EventType.CONDITONAL.name(), eventSubscription.getEventType());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class ConditionalStartEventTest method testStartInstanceWithMultipleConditions.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/conditional/ConditionalStartEventTest.testMultipleCondition.bpmn20.xml")
public void testStartInstanceWithMultipleConditions() {
// given a deployed process with three conditional start events
List<EventSubscription> eventSubscriptions = runtimeService.createEventSubscriptionQuery().list();
assertEquals(3, eventSubscriptions.size());
for (EventSubscription eventSubscription : eventSubscriptions) {
assertEquals(EventType.CONDITONAL.name(), eventSubscription.getEventType());
}
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("foo", 1);
variableMap.put("bar", true);
// when
List<ProcessInstance> resultInstances = runtimeService.createConditionEvaluation().setVariables(variableMap).evaluateStartConditions();
// then
assertEquals(2, resultInstances.size());
List<ProcessInstance> instances = runtimeService.createProcessInstanceQuery().processDefinitionKey(MULTIPLE_CONDITIONS).list();
assertEquals(2, instances.size());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class ConditionalStartEventTest method testUpdateProcessVersionCancelsSubscriptions.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/conditional/ConditionalStartEventTest.testSingleConditionalStartEvent.bpmn20.xml")
public void testUpdateProcessVersionCancelsSubscriptions() {
// given a deployed process
List<EventSubscription> eventSubscriptions = runtimeService.createEventSubscriptionQuery().list();
List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().list();
assertEquals(1, eventSubscriptions.size());
assertEquals(1, processDefinitions.size());
// when
testRule.deploy("org/camunda/bpm/engine/test/bpmn/event/conditional/ConditionalStartEventTest.testSingleConditionalStartEvent.bpmn20.xml");
// then
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));
}
use of org.camunda.bpm.engine.runtime.EventSubscription 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.runtime.EventSubscription 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);
}
Aggregations