Search in sources :

Example 46 with EventSubscription

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());
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 47 with EventSubscription

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());
}
Also used : EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) HashMap(java.util.HashMap) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 48 with EventSubscription

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));
}
Also used : EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 49 with EventSubscription

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());
}
Also used : EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 50 with EventSubscription

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);
}
Also used : EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)

Aggregations

EventSubscription (org.camunda.bpm.engine.runtime.EventSubscription)71 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)38 Deployment (org.camunda.bpm.engine.test.Deployment)38 Task (org.camunda.bpm.engine.task.Task)16 EventSubscriptionQuery (org.camunda.bpm.engine.runtime.EventSubscriptionQuery)13 Test (org.junit.Test)13 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)10 Execution (org.camunda.bpm.engine.runtime.Execution)8 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)6 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)5 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)4 HashMap (java.util.HashMap)3 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)2 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)2 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)2 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1