org.camunda.bpm.engine.runtime.CaseInstance Java Examples

The following examples show how to use org.camunda.bpm.engine.runtime.CaseInstance. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MilestoneTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/milestone/MilestoneTest.testWithoutEntryCriterias.cmmn"})
public void testWithoutEntryCriterias() {
  // given

  // when
  String caseInstanceId = caseService
      .withCaseDefinitionByKey("case")
      .create()
      .getId();

  // then
  CaseInstance caseInstance = caseService
      .createCaseInstanceQuery()
      .caseInstanceId(caseInstanceId)
      .singleResult();

  assertTrue(caseInstance.isCompleted());

  Object occurVariable = caseService.getVariable(caseInstanceId, "occur");
  assertNotNull(occurVariable);
  assertTrue((Boolean) occurVariable);
}
 
Example #2
Source File: AutoCompleteTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testCasePlanModel() {
  // given
  // a deployed process

  // when
  String caseInstanceId = createCaseInstanceByKey(CASE_DEFINITION_KEY).getId();

  // then
  CaseInstance caseInstance = caseService
      .createCaseInstanceQuery()
      .caseInstanceId(caseInstanceId)
      .singleResult();

  assertNotNull(caseInstance);
  assertTrue(caseInstance.isCompleted());

  // humanTask1 and humanTask2 are not available
  CaseExecutionQuery query = caseService.createCaseExecutionQuery();
  assertNull(query.activityId("PI_HumanTask_1").singleResult());
  assertNull(query.activityId("PI_HumanTask_2").singleResult());
}
 
Example #3
Source File: CaseCallActivityTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {
    "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testOutputAll.bpmn20.xml",
    "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn"
  })
public void testCallCaseOutputAllVariablesTypedToProcess(){
  startProcessInstanceByKey("process");
  CaseInstance caseInstance = queryOneTaskCaseInstance();
  String variableName = "foo";
  String variableName2 = "null";
  TypedValue variableValue = Variables.stringValue("bar");
  TypedValue variableValue2 = Variables.integerValue(null);
  caseService.withCaseExecution(caseInstance.getId())
    .setVariable(variableName, variableValue)
    .setVariable(variableName2, variableValue2)
    .execute();
  complete(caseInstance.getId());

  Task task = taskService.createTaskQuery().singleResult();
  TypedValue value = runtimeService.getVariableTyped(task.getProcessInstanceId(), variableName);
  assertThat(value, is(variableValue));
  value = runtimeService.getVariableTyped(task.getProcessInstanceId(), variableName2);
  assertThat(value, is(variableValue2));
}
 
Example #4
Source File: DmnDecisionTaskTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {
    "org/camunda/bpm/engine/test/cmmn/decisiontask/DmnDecisionTaskTest.testCallDecisionByDeployment.cmmn",
    DECISION_OKAY_DMN
  })
public void testCallDecisionByDeployment() {
  // given
  String deploymentId = repositoryService.createDeployment()
      .addClasspathResource(DECISION_NOT_OKAY_DMN)
      .deploy()
      .getId();

  CaseInstance caseInstance = createCaseInstanceByKey(CASE_KEY);

  // then
  assertNull(queryCaseExecutionByActivityId(DECISION_TASK));
  assertEquals("okay", getDecisionResult(caseInstance));

  repositoryService.deleteDeployment(deploymentId, true);
}
 
Example #5
Source File: CaseServiceCaseTaskTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources={
    "org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCaseWithManualActivation.cmmn"
    })
public void testReenableAnEnabledCaseTask() {
  // given
  createCaseInstance(DEFINITION_KEY);
  String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK_KEY).getId();

  CaseInstance subCaseInstance = queryCaseInstanceByKey(DEFINITION_KEY_2);
  assertNull(subCaseInstance);

  try {
    // when
    caseService
      .withCaseExecution(caseTaskId)
      .reenable();
    fail("It should not be possible to re-enable an enabled case task.");
  } catch (NotAllowedException e) {
  }
}
 
Example #6
Source File: ShipmentCaseModelTest.java    From Showcase with Apache License 2.0 6 votes vote down vote up
@After
public void cleanup() {

    processEngine().close();

    Collection<CaseInstance> caseExecutionCollection = processEngine()
            .getCaseService()
            .createCaseInstanceQuery()
            .active()
            .list();

    for (CaseInstance caseInstance:caseExecutionCollection) {
        processEngine().getCaseService().terminateCaseExecution(caseInstance.getId());
        processEngine().getCaseService().closeCaseInstance(caseInstance.getId());
    }

    shipmentRepository.deleteAll();
    customerRepository.deleteAll();
    invoiceRepository.deleteAll();
}
 
Example #7
Source File: ShipmentTaskBoundaryServiceImpl.java    From Showcase with Apache License 2.0 6 votes vote down vote up
@Override
public List<EnabledTaskDS> findAllEnabledTasksForShipment(String trackingId) {
    Collection<CaseExecution> caseExecutions = caseService.createCaseExecutionQuery().enabled().list();
    List<EnabledTaskDS> enabledShipmentTasks = new ArrayList<>();

    for (CaseExecution caseExecution : caseExecutions) {

        CaseInstance caseInstance = caseService.createCaseInstanceQuery().caseInstanceId(caseExecution.getCaseInstanceId()).active().singleResult();

        if (caseInstance.getBusinessKey().equals(trackingId)) {
            EnabledTaskDS enabledTaskDS = new EnabledTaskDS(caseExecution.getActivityDescription(), caseExecution.getActivityId(),
                    caseExecution.getActivityName(), caseExecution.getActivityType(), trackingId);
            enabledShipmentTasks.add(enabledTaskDS);
        }
    }
    return enabledShipmentTasks;
}
 
Example #8
Source File: RequiredRuleTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = "org/camunda/bpm/engine/test/cmmn/required/RequiredRuleTest.testVariableBasedRule.cmmn")
public void testRequiredRuleEvaluatesToTrue() {
  CaseInstance caseInstance =
      caseService.createCaseInstanceByKey("case", Collections.<String, Object>singletonMap("required", true));

  CaseExecution taskExecution = caseService
      .createCaseExecutionQuery()
      .activityId("PI_HumanTask_1")
      .singleResult();
  assertNotNull(taskExecution);
  assertTrue(taskExecution.isRequired());

  try {
    caseService.completeCaseExecution(caseInstance.getId());
    fail("completing the containing stage should not be allowed");
  } catch (NotAllowedException e) {
    // happy path
  }
}
 
Example #9
Source File: DmnDecisionTaskTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {
    "org/camunda/bpm/engine/test/cmmn/decisiontask/DmnDecisionTaskTest.testCallDecisionByVersion.cmmn",
    DECISION_OKAY_DMN
  })
public void testCallDecisionByVersion() {
  // given
  String deploymentId = repositoryService.createDeployment()
      .addClasspathResource(DECISION_NOT_OKAY_DMN)
      .deploy()
      .getId();

  CaseInstance caseInstance = createCaseInstanceByKey(CASE_KEY);

  // then
  assertNull(queryCaseExecutionByActivityId(DECISION_TASK));
  assertEquals("not okay", getDecisionResult(caseInstance));

  repositoryService.deleteDeployment(deploymentId, true);
}
 
Example #10
Source File: SentryScenario.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@DescribesScenario("newSentryInstance")
public static ScenarioSetup newSentryInstance() {
  return new ScenarioSetup() {
    public void execute(ProcessEngine engine, String scenarioName) {
      CaseService caseService = engine.getCaseService();
      CaseInstance caseInstance = caseService.createCaseInstanceByKey("case", scenarioName);
      String caseInstanceId = caseInstance.getId();
      
      CaseExecutionQuery query = caseService.createCaseExecutionQuery().caseInstanceId(caseInstanceId);

      String firstHumanTaskId = query.activityId("PI_HumanTask_1").singleResult().getId();
      caseService.manuallyStartCaseExecution(firstHumanTaskId);
      caseService.completeCaseExecution(firstHumanTaskId);

      String secondHumanTaskId = query.activityId("PI_HumanTask_2").singleResult().getId();
      caseService.manuallyStartCaseExecution(secondHumanTaskId);
      caseService.completeCaseExecution(secondHumanTaskId);
    }
  };
}
 
Example #11
Source File: CaseInstanceFakeTest.java    From camunda-bpm-mockito with Apache License 2.0 6 votes vote down vote up
@Test
public void prepare_with_service_mock() {
  CaseService caseService = mock(CaseService.class);
  String uuid = UUID.randomUUID().toString();
  String businessKey = "12";

  AtomicReference<CaseInstanceFake> reference = CaseInstanceFake.prepareMock(caseService, uuid);

  assertThat(reference.get()).isNull();

  CaseInstance instance = caseService.createCaseInstanceByKey("case", businessKey, Variables.putValue("foo", "bar"));
  assertThat(reference.get()).isNotNull();
  assertThat(instance.getCaseInstanceId()).isEqualTo(uuid);

  assertThat(caseService.getVariable(uuid, "foo")).isEqualTo("bar");

  caseService.setVariable(uuid, "hello", 456);
  assertThat(caseService.getVariable(uuid, "hello")).isEqualTo(456);

  assertThat(caseService.createCaseInstanceQuery().singleResult()).isEqualTo(reference.get());
}
 
Example #12
Source File: TenantIdProviderTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void setNullTenantIdForCaseInstance() {

  String tenantId = null;
  StaticTenantIdTestProvider tenantIdProvider = new StaticTenantIdTestProvider(tenantId);
  TestTenantIdProvider.delegate = tenantIdProvider;

  testRule.deploy(CMMN_FILE_WITH_MANUAL_ACTIVATION);

  // if a case instance is created
  engineRule.getCaseService().withCaseDefinitionByKey(CASE_DEFINITION_KEY).create();

  // then the tenant id provider can set the tenant id to null
  CaseInstance caseInstance = engineRule.getCaseService().createCaseInstanceQuery().singleResult();
  assertThat(caseInstance.getTenantId(), is(nullValue()));
}
 
Example #13
Source File: TenantIdProviderTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void setsTenantIdForCaseInstance() {

  String tenantId = TENANT_ID;
  StaticTenantIdTestProvider tenantIdProvider = new StaticTenantIdTestProvider(tenantId);
  TestTenantIdProvider.delegate = tenantIdProvider;

  testRule.deploy(CMMN_FILE_WITH_MANUAL_ACTIVATION);

  // if a case instance is created
  engineRule.getCaseService().withCaseDefinitionByKey(CASE_DEFINITION_KEY).create();

  // then the tenant id provider can set the tenant id to a value
  CaseInstance caseInstance = engineRule.getCaseService().createCaseInstanceQuery().singleResult();
  assertThat(caseInstance.getTenantId(), is(tenantId));
}
 
Example #14
Source File: TaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn")
public void testQueryResultOrderingByCaseInstanceVariables() {
  // given three tasks with String case instance variables
  CaseInstance instance1 = caseService.createCaseInstanceByKey("oneTaskCase",
      Collections.<String, Object>singletonMap("var", "cValue"));
  CaseInstance instance2 = caseService.createCaseInstanceByKey("oneTaskCase",
      Collections.<String, Object>singletonMap("var", "aValue"));
  CaseInstance instance3 = caseService.createCaseInstanceByKey("oneTaskCase",
      Collections.<String, Object>singletonMap("var", "bValue"));

  // when I make a task query with ascending variable ordering by tasks variables
  List<Task> tasks = taskService.createTaskQuery()
    .caseDefinitionKey("oneTaskCase")
    .orderByCaseInstanceVariable("var", ValueType.STRING)
    .asc()
    .list();

  // then the tasks are ordered correctly by their local variables
  assertEquals(3, tasks.size());
  assertEquals(instance2.getId(), tasks.get(0).getCaseInstanceId());
  assertEquals(instance3.getId(), tasks.get(1).getCaseInstanceId());
  assertEquals(instance1.getId(), tasks.get(2).getCaseInstanceId());
}
 
Example #15
Source File: BulkHistoryDeleteTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCleanupHistoryCaseInstanceVariables() {
  // given
  // create case instances
  List<String> caseInstanceIds = new ArrayList<String>();
  int instanceCount = 10;
  for (int i = 0; i < instanceCount; i++) {
    VariableMap variables = Variables.createVariables();
    CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase", variables.putValue("name" + i, "theValue"));
    caseInstanceIds.add(caseInstance.getId());
    terminateAndCloseCaseInstance(caseInstance.getId(), variables);
  }
  // assume
  List<HistoricVariableInstance> variablesInstances = historyService.createHistoricVariableInstanceQuery().list();
  assertEquals(instanceCount, variablesInstances.size());

  // when
  historyService.deleteHistoricCaseInstancesBulk(caseInstanceIds);

  // then
  variablesInstances = historyService.createHistoricVariableInstanceQuery().list();
  assertEquals(0, variablesInstances.size());
}
 
Example #16
Source File: SentryScenario.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@DescribesScenario("triggerStageEntryCriterion")
public static ScenarioSetup completeStage() {
  return new ScenarioSetup() {
    public void execute(ProcessEngine engine, String scenarioName) {
      CaseService caseService = engine.getCaseService();
      CaseInstance caseInstance = caseService.createCaseInstanceByKey("case", scenarioName);
      String caseInstanceId = caseInstance.getId();
      
      CaseExecutionQuery query = caseService.createCaseExecutionQuery().caseInstanceId(caseInstanceId);

      String firstHumanTaskId = query.activityId("PI_HumanTask_1").singleResult().getId();
      caseService.manuallyStartCaseExecution(firstHumanTaskId);
      caseService.completeCaseExecution(firstHumanTaskId);

      String secondHumanTaskId = query.activityId("PI_HumanTask_2").singleResult().getId();
      caseService.manuallyStartCaseExecution(secondHumanTaskId);
    }
  };
}
 
Example #17
Source File: CaseServiceCaseTaskTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskAndOneHumanTaskCaseWithManualActivation.cmmn"})
public void testDisableAnEnabledCaseTask() {
  // given
  createCaseInstance(DEFINITION_KEY);
  String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK_KEY).getId();

  CaseInstance subCaseInstance = queryCaseInstanceByKey(DEFINITION_KEY_2);
  assertNull(subCaseInstance);

  // when
  caseService
    .withCaseExecution(caseTaskId)
    .disable();

  // then
  CaseExecution caseTask = queryCaseExecutionByActivityId(CASE_TASK_KEY);
  assertTrue(caseTask.isDisabled());
}
 
Example #18
Source File: BulkHistoryDeleteTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCleanupHistoryCaseInstanceTaskAttachmentByteArray() {
  // given
  // create case instance
  CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase");

  Task task = taskService.createTaskQuery().singleResult();
  String taskId = task.getId();
  taskService.createAttachment("foo", taskId, null, "something", null, new ByteArrayInputStream("someContent".getBytes()));

  // assume
  List<Attachment> attachments = taskService.getTaskAttachments(taskId);
  assertEquals(1, attachments.size());
  String contentId = findAttachmentContentId(attachments);
  terminateAndCloseCaseInstance(caseInstance.getId(), null);

  // when
  historyService.deleteHistoricCaseInstancesBulk(Arrays.asList(caseInstance.getId()));

  // then
  attachments = taskService.getTaskAttachments(taskId);
  assertEquals(0, attachments.size());
  verifyByteArraysWereRemoved(contentId);
}
 
Example #19
Source File: CustomHistoryLevelWithoutUserOperationLogTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources = {"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"})
public void testQueryDeleteVariableHistoryOperationOnCase() {
  // given
  CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase");
  caseService.setVariable(caseInstance.getId(), "myVariable", 1);
  caseService.setVariable(caseInstance.getId(), "myVariable", 2);
  caseService.setVariable(caseInstance.getId(), "myVariable", 3);
  HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().singleResult();

  // when
  historyService.deleteHistoricVariableInstance(variableInstance.getId());

  // then
  verifyVariableOperationAsserts(UserOperationLogEntry.OPERATION_TYPE_DELETE_HISTORY);
}
 
Example #20
Source File: CaseServiceCaseInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/emptyCasePlanModelCase.cmmn"})
public void testAutoCompletionOfEmptyCase() {
  // given:
  // a deployed case definition
  String caseDefinitionId = repositoryService
      .createCaseDefinitionQuery()
      .singleResult()
      .getId();

  // when
  caseService
     .withCaseDefinition(caseDefinitionId)
     .create();

  // then
  CaseInstance caseInstance = caseService
    .createCaseInstanceQuery()
    .completed()
    .singleResult();

  assertNotNull(caseInstance);
  assertTrue(caseInstance.isCompleted());
}
 
Example #21
Source File: CaseInstanceRestServiceImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public List<CaseInstanceDto> queryCaseInstances(CaseInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) {
  ProcessEngine engine = getProcessEngine();
  queryDto.setObjectMapper(getObjectMapper());
  CaseInstanceQuery query = queryDto.toQuery(engine);

  List<CaseInstance> matchingInstances;
  if (firstResult != null || maxResults != null) {
    matchingInstances = executePaginatedQuery(query, firstResult, maxResults);
  } else {
    matchingInstances = query.list();
  }

  List<CaseInstanceDto> instanceResults = new ArrayList<CaseInstanceDto>();
  for (CaseInstance instance : matchingInstances) {
    CaseInstanceDto resultInstance = CaseInstanceDto.fromCaseInstance(instance);
    instanceResults.add(resultInstance);
  }
  return instanceResults;
}
 
Example #22
Source File: TenantIdProviderTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void setsTenantId_SubCaseInstance() {

  String tenantId = TENANT_ID;
  SetValueOnSubCaseInstanceTenantIdProvider tenantIdProvider = new SetValueOnSubCaseInstanceTenantIdProvider(tenantId);
  TestTenantIdProvider.delegate = tenantIdProvider;

  testRule.deploy(CMMN_SUBPROCESS_FILE, CMMN_FILE);

  // if a case instance is created
  engineRule.getCaseService().withCaseDefinitionByKey(CASE_DEFINITION_KEY).create();

  // then the tenant id provider can set the tenant id to a value
  CaseInstance subCaseInstance = engineRule.getCaseService().createCaseInstanceQuery().caseDefinitionKey("oneTaskCase").singleResult();
  assertThat(subCaseInstance.getTenantId(), is(tenantId));

  // and the super case instance is not assigned a tenant id
  CaseInstance superCaseInstance = engineRule.getCaseService().createCaseInstanceQuery().caseDefinitionKey(CASE_DEFINITION_KEY).singleResult();
  assertThat(superCaseInstance.getTenantId(), is(nullValue()));
}
 
Example #23
Source File: CaseServiceCaseInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"})
public void testCreateByIdWithBusinessKeyNonFluent() {
  // given a deployed case definition
  String caseDefinitionId = repositoryService
      .createCaseDefinitionQuery()
      .singleResult()
      .getId();

  // when
  CaseInstance caseInstance = caseService.createCaseInstanceById(caseDefinitionId, "aBusinessKey");

  // then
  assertNotNull(caseInstance);

  // check properties
  assertEquals("aBusinessKey", caseInstance.getBusinessKey());
  assertEquals(caseDefinitionId, caseInstance.getCaseDefinitionId());
  assertEquals(caseInstance.getId(), caseInstance.getCaseInstanceId());
  assertTrue(caseInstance.isActive());
  assertFalse(caseInstance.isEnabled());

  // get persisted case instance
  CaseInstance instance = caseService
    .createCaseInstanceQuery()
    .singleResult();

  // should have the same properties
  assertEquals(caseInstance.getId(), instance.getId());
  assertEquals(caseInstance.getBusinessKey(), instance.getBusinessKey());
  assertEquals(caseInstance.getCaseDefinitionId(), instance.getCaseDefinitionId());
  assertEquals(caseInstance.getCaseInstanceId(), instance.getCaseInstanceId());
  assertEquals(caseInstance.isActive(), instance.isActive());
  assertEquals(caseInstance.isEnabled(), instance.isEnabled());
}
 
Example #24
Source File: MultiTenancyDecisionTaskTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testEvaluateDecisionWithDeploymentBinding() {
  deploymentForTenant(TENANT_ONE, CMMN_DEPLOYMENT, DMN_FILE);
  deploymentForTenant(TENANT_TWO, CMMN_DEPLOYMENT, DMN_FILE_VERSION_TWO);

  CaseInstance caseInstanceOne = createCaseInstance(CASE_DEFINITION_KEY, TENANT_ONE);
  CaseInstance caseInstanceTwo = createCaseInstance(CASE_DEFINITION_KEY, TENANT_TWO);

  assertThat((String)caseService.getVariable(caseInstanceOne.getId(), "decisionVar"), is(RESULT_OF_VERSION_ONE));
  assertThat((String)caseService.getVariable(caseInstanceTwo.getId(), "decisionVar"), is(RESULT_OF_VERSION_TWO));
}
 
Example #25
Source File: CaseTaskTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * assert on variable defined during manual start - change process definition
 */
@Deployment(resources = {
    "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testInputAllLocal.cmmn",
    "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"
  })
public void testInputAllLocal() {
  // given
  createCaseInstanceByKey(ONE_CASE_TASK_CASE).getId();
  String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId();

  // when
  caseService
    .withCaseExecution(caseTaskId)
    .setVariable("aVariable", "abc")
    .setVariableLocal("aLocalVariable", "def")
    .manualStart();

  // then only the local variable is mapped to the subCaseInstance
  CaseInstance subCaseInstance = queryOneTaskCaseInstance();

  List<VariableInstance> variables = runtimeService
      .createVariableInstanceQuery()
      .caseInstanceIdIn(subCaseInstance.getId())
      .list();

  assertEquals(1, variables.size());
  assertEquals("aLocalVariable", variables.get(0).getName());
}
 
Example #26
Source File: CaseServiceCaseInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"})
public void testCreateByKeyWithBusinessKey() {
  // given a deployed case definition
  String caseDefinitionId = repositoryService
    .createCaseDefinitionQuery()
    .singleResult()
    .getId();

  // when
  CaseInstance caseInstance = caseService
      .withCaseDefinitionByKey("oneTaskCase")
      .businessKey("aBusinessKey")
      .create();

  // then
  assertNotNull(caseInstance);

  // check properties
  assertEquals("aBusinessKey", caseInstance.getBusinessKey());
  assertEquals(caseDefinitionId, caseInstance.getCaseDefinitionId());
  assertEquals(caseInstance.getId(), caseInstance.getCaseInstanceId());
  assertTrue(caseInstance.isActive());
  assertFalse(caseInstance.isEnabled());

  // get persistend case instance
  CaseInstance instance = caseService
    .createCaseInstanceQuery()
    .singleResult();

  // should have the same properties
  assertEquals(caseInstance.getId(), instance.getId());
  assertEquals(caseInstance.getBusinessKey(), instance.getBusinessKey());
  assertEquals(caseInstance.getCaseDefinitionId(), instance.getCaseDefinitionId());
  assertEquals(caseInstance.getCaseInstanceId(), instance.getCaseInstanceId());
  assertEquals(caseInstance.isActive(), instance.isActive());
  assertEquals(caseInstance.isEnabled(), instance.isEnabled());

}
 
Example #27
Source File: MultiTenancyDecisionTaskTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testEvaluateDecisionWithLatestBindingSameVersion() {
  deploymentForTenant(TENANT_ONE, CMMN_LATEST, DMN_FILE);
  deploymentForTenant(TENANT_TWO, CMMN_LATEST, DMN_FILE_VERSION_TWO);

  CaseInstance caseInstanceOne = createCaseInstance(CASE_DEFINITION_KEY, TENANT_ONE);
  CaseInstance caseInstanceTwo = createCaseInstance(CASE_DEFINITION_KEY, TENANT_TWO);

  assertThat((String)caseService.getVariable(caseInstanceOne.getId(), "decisionVar"), is(RESULT_OF_VERSION_ONE));
  assertThat((String)caseService.getVariable(caseInstanceTwo.getId(), "decisionVar"), is(RESULT_OF_VERSION_TWO));
}
 
Example #28
Source File: MultiTenancyDecisionTaskTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testEvaluateDecisionWithLatestBindingDifferentVersions() {
  deploymentForTenant(TENANT_ONE, CMMN_LATEST, DMN_FILE);

  deploymentForTenant(TENANT_TWO, CMMN_LATEST, DMN_FILE);
  deploymentForTenant(TENANT_TWO, CMMN_LATEST, DMN_FILE_VERSION_TWO);

  CaseInstance caseInstanceOne = createCaseInstance(CASE_DEFINITION_KEY, TENANT_ONE);
  CaseInstance caseInstanceTwo = createCaseInstance(CASE_DEFINITION_KEY, TENANT_TWO);

  assertThat((String)caseService.getVariable(caseInstanceOne.getId(), "decisionVar"), is(RESULT_OF_VERSION_ONE));
  assertThat((String)caseService.getVariable(caseInstanceTwo.getId(), "decisionVar"), is(RESULT_OF_VERSION_TWO));
}
 
Example #29
Source File: MultiTenancyDecisionTaskTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testEvaluateDecisionRefWithoutTenantIdConstant() {
  deploymentForTenant(TENANT_ONE, CMMN_WITHOUT_TENANT);
  deployment(DMN_FILE);
  deploymentForTenant(TENANT_TWO, DMN_FILE_VERSION_TWO);

  CaseInstance caseInstance = createCaseInstance(CASE_DEFINITION_KEY);

  assertThat((String)caseService.getVariable(caseInstance.getId(), "decisionVar"), is(RESULT_OF_VERSION_ONE));
}
 
Example #30
Source File: MultiTenancyDecisionTaskTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testEvaluateDecisionWithVersionBinding() {
  deploymentForTenant(TENANT_ONE, CMMN_VERSION, DMN_FILE);
  deploymentForTenant(TENANT_ONE, DMN_FILE_VERSION_TWO);

  deploymentForTenant(TENANT_TWO, CMMN_VERSION, DMN_FILE_VERSION_TWO);
  deploymentForTenant(TENANT_TWO, DMN_FILE);

  CaseInstance caseInstanceOne = createCaseInstance(CASE_DEFINITION_KEY, TENANT_ONE);
  CaseInstance caseInstanceTwo = createCaseInstance(CASE_DEFINITION_KEY, TENANT_TWO);

  assertThat((String)caseService.getVariable(caseInstanceOne.getId(), "decisionVar"), is(RESULT_OF_VERSION_ONE));
  assertThat((String)caseService.getVariable(caseInstanceTwo.getId(), "decisionVar"), is(RESULT_OF_VERSION_TWO));
}