Java Code Examples for org.camunda.bpm.engine.runtime.CaseExecutionQuery#singleResult()
The following examples show how to use
org.camunda.bpm.engine.runtime.CaseExecutionQuery#singleResult() .
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: CaseServiceStageTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskAndOneStageWithManualActivationCase.cmmn"}) public void testDisableAnEnabledStage() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // an active case instance and the containing // human task is enabled caseService .withCaseDefinition(caseDefinitionId) .create(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); String caseExecutionId = caseExecutionQuery .activityId("PI_Stage_1") .singleResult() .getId(); // when caseService .withCaseExecution(caseExecutionId) .disable(); // then CaseExecution caseExecution = caseExecutionQuery.singleResult(); // the human task is disabled assertTrue(caseExecution.isDisabled()); assertFalse(caseExecution.isActive()); assertFalse(caseExecution.isEnabled()); }
Example 2
Source File: CaseServiceStageTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneStageCase.cmmn"}) public void testStartAutomated() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // an active case instance caseService .withCaseDefinition(caseDefinitionId) .create(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); // an enabled child case execution of // the case instance String caseExecutionId = caseExecutionQuery .activityId("PI_Stage_1") .singleResult() .getId(); // then // the child case execution is active... CaseExecution caseExecution = caseExecutionQuery.singleResult(); assertTrue(caseExecution.isActive()); // ... and not enabled assertFalse(caseExecution.isEnabled()); // there exists two new case execution: verifyTasksState(caseExecutionQuery); }
Example 3
Source File: CaseExecutionQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/cmmn/required/RequiredRuleTest.testVariableBasedRule.cmmn") public void testQueryByRequired() { caseService.createCaseInstanceByKey("case", Collections.<String, Object>singletonMap("required", true)); CaseExecutionQuery query = caseService .createCaseExecutionQuery() .required(); verifyQueryResults(query, 1); CaseExecution execution = query.singleResult(); assertNotNull(execution); assertTrue(execution.isRequired()); }
Example 4
Source File: CaseServiceHumanTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn"}) public void testReenableAnDisabledHumanTask() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // an active case instance caseService .withCaseDefinition(caseDefinitionId) .create(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); String caseExecutionId = caseExecutionQuery .activityId("PI_HumanTask_1") .singleResult() .getId(); // the human task is disabled caseService .withCaseExecution(caseExecutionId) .disable(); // when caseService .withCaseExecution(caseExecutionId) .reenable(); // then CaseExecution caseExecution = caseExecutionQuery.singleResult(); // the human task is disabled assertFalse(caseExecution.isDisabled()); assertFalse(caseExecution.isActive()); assertTrue(caseExecution.isEnabled()); }
Example 5
Source File: CaseServiceHumanTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn"}) public void testDisableAnEnabledHumanTask() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // an active case instance and the containing // human task is enabled caseService .withCaseDefinition(caseDefinitionId) .create(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); String caseExecutionId = caseExecutionQuery .activityId("PI_HumanTask_1") .singleResult() .getId(); // when caseService .withCaseExecution(caseExecutionId) .disable(); // then CaseExecution caseExecution = caseExecutionQuery.singleResult(); // the human task is disabled assertTrue(caseExecution.isDisabled()); assertFalse(caseExecution.isActive()); assertFalse(caseExecution.isEnabled()); }
Example 6
Source File: CaseServiceHumanTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"}) public void testManualStartNonFluent() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // an active case instance caseService .withCaseDefinition(caseDefinitionId) .create(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); // an enabled child case execution of // the case instance String caseExecutionId = caseExecutionQuery .activityId("PI_HumanTask_1") .singleResult() .getId(); // then // the child case execution is active... CaseExecution caseExecution = caseExecutionQuery.singleResult(); assertTrue(caseExecution.isActive()); // ... and not enabled assertFalse(caseExecution.isEnabled()); // there exists a task Task task = taskService .createTaskQuery() .caseExecutionId(caseExecutionId) .singleResult(); assertNotNull(task); }
Example 7
Source File: CaseServiceHumanTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn"}) public void testDisableNonFluent() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // an active case instance and the containing // human task is enabled caseService .withCaseDefinition(caseDefinitionId) .create(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); String caseExecutionId = caseExecutionQuery .activityId("PI_HumanTask_1") .singleResult() .getId(); // when caseService.disableCaseExecution(caseExecutionId); // then CaseExecution caseExecution = caseExecutionQuery.singleResult(); // the human task is disabled assertTrue(caseExecution.isDisabled()); assertFalse(caseExecution.isActive()); assertFalse(caseExecution.isEnabled()); }
Example 8
Source File: CaseServiceStageTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneStageCaseWithManualActivation.cmmn"}) public void testManualWithVariables() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // an active case instance String caseInstanceId = caseService .withCaseDefinition(caseDefinitionId) .create() .getId(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); // an enabled child case execution of // the case instance String caseExecutionId = caseExecutionQuery .activityId("PI_Stage_1") .singleResult() .getId(); // variables Map<String, Object> variables = new HashMap<String, Object>(); variables.put("aVariableName", "abc"); variables.put("anotherVariableName", 999); // when // activate child case execution caseService .withCaseExecution(caseExecutionId) .setVariables(variables) .manualStart(); // then // the child case execution is active... CaseExecution caseExecution = caseExecutionQuery.singleResult(); assertTrue(caseExecution.isActive()); // ... and not enabled assertFalse(caseExecution.isEnabled()); // (1) one case case execution representing "PI_HumanTask_1" verifyTasksState(caseExecutionQuery); // the case instance has two variables: // - aVariableName // - anotherVariableName List<VariableInstance> result = runtimeService .createVariableInstanceQuery() .list(); verifyVariables(caseInstanceId, caseInstanceId, result); }
Example 9
Source File: CaseExecutionQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
private void verifySingleResultFails(CaseExecutionQuery query) { try { query.singleResult(); fail(); } catch (ProcessEngineException e) {} }
Example 10
Source File: CaseServiceStageTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneStageCaseWithManualActivation.cmmn"}) public void testManualStartWithVariable() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // an active case instance String caseInstanceId = caseService .withCaseDefinition(caseDefinitionId) .create() .getId(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); // an enabled child case execution of // the case instance String caseExecutionId = caseExecutionQuery .activityId("PI_Stage_1") .singleResult() .getId(); // when // activate child case execution caseService .withCaseExecution(caseExecutionId) .setVariable("aVariableName", "abc") .setVariable("anotherVariableName", 999) .manualStart(); // then // the child case execution is active... CaseExecution caseExecution = caseExecutionQuery.singleResult(); assertTrue(caseExecution.isActive()); // ... and not enabled assertFalse(caseExecution.isEnabled()); // (1) one case case execution representing "PI_HumanTask_1" verifyTasksState(caseExecutionQuery); // the case instance has two variables: // - aVariableName // - anotherVariableName List<VariableInstance> result = runtimeService .createVariableInstanceQuery() .list(); verifyVariables(caseInstanceId, caseInstanceId, result); }
Example 11
Source File: CaseServiceHumanTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn"}) public void testReenableNonFluentWithVariables() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // an active case instance String caseInstanceId = caseService .withCaseDefinition(caseDefinitionId) .create().getId(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); String caseExecutionId = caseExecutionQuery .activityId("PI_HumanTask_1") .singleResult() .getId(); // the human task is disabled caseService .withCaseExecution(caseExecutionId) .disable(); // when Map<String, Object> variables = new HashMap<String, Object>(); variables.put("aVariable", "aValue"); caseService.reenableCaseExecution(caseExecutionId, variables); // then CaseExecution caseExecution = caseExecutionQuery.singleResult(); // the human task is disabled assertFalse(caseExecution.isDisabled()); assertFalse(caseExecution.isActive()); assertTrue(caseExecution.isEnabled()); // there is a variable set on the case instance VariableInstance variable = runtimeService.createVariableInstanceQuery().singleResult(); assertNotNull(variable); assertEquals(caseInstanceId, variable.getCaseExecutionId()); assertEquals(caseInstanceId, variable.getCaseInstanceId()); assertEquals("aVariable", variable.getName()); assertEquals("aValue", variable.getValue()); }
Example 12
Source File: CaseServiceStageTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneStageCaseWithManualActivation.cmmn"}) public void testManualStartWithLocalVariable() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // an active case instance String caseInstanceId = caseService .withCaseDefinition(caseDefinitionId) .create() .getId(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); // an enabled child case execution of // the case instance String caseExecutionId = caseExecutionQuery .activityId("PI_Stage_1") .singleResult() .getId(); // when // activate child case execution caseService .withCaseExecution(caseExecutionId) .setVariableLocal("aVariableName", "abc") .setVariableLocal("anotherVariableName", 999) .manualStart(); // then // the child case execution is active... CaseExecution caseExecution = caseExecutionQuery.singleResult(); assertTrue(caseExecution.isActive()); // ... and not enabled assertFalse(caseExecution.isEnabled()); // (1) one case case execution representing "PI_HumanTask_1" verifyTasksState(caseExecutionQuery); // the case instance has two variables: // - aVariableName // - anotherVariableName List<VariableInstance> result = runtimeService .createVariableInstanceQuery() .list(); verifyVariables(caseInstanceId, caseExecutionId, result); }
Example 13
Source File: CaseServiceHumanTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn"}) public void testManualStartWithVariablesNonFluent() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // an active case instance String caseInstanceId = caseService .withCaseDefinition(caseDefinitionId) .create().getId(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); // an enabled child case execution of // the case instance String caseExecutionId = caseExecutionQuery .activityId("PI_HumanTask_1") .singleResult() .getId(); // when // activate child case execution Map<String, Object> variables = new HashMap<String, Object>(); variables.put("aVariable", "aValue"); caseService.manuallyStartCaseExecution(caseExecutionId, variables); // then // the child case execution is active... CaseExecution caseExecution = caseExecutionQuery.singleResult(); assertTrue(caseExecution.isActive()); // ... and not enabled assertFalse(caseExecution.isEnabled()); // there exists a task Task task = taskService .createTaskQuery() .caseExecutionId(caseExecutionId) .singleResult(); assertNotNull(task); // there is a variable set on the case instance VariableInstance variable = runtimeService.createVariableInstanceQuery().singleResult(); assertNotNull(variable); assertEquals(caseInstanceId, variable.getCaseExecutionId()); assertEquals(caseInstanceId, variable.getCaseInstanceId()); assertEquals("aVariable", variable.getName()); assertEquals("aValue", variable.getValue()); }
Example 14
Source File: CaseServiceHumanTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn"}) public void testManualStartWithLocalVariables() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // an active case instance String caseInstanceId = caseService .withCaseDefinition(caseDefinitionId) .create() .getId(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); // an enabled child case execution of // the case instance String caseExecutionId = caseExecutionQuery .activityId("PI_HumanTask_1") .singleResult() .getId(); // variables Map<String, Object> variables = new HashMap<String, Object>(); variables.put("aVariableName", "abc"); variables.put("anotherVariableName", 999); // when // activate child case execution caseService .withCaseExecution(caseExecutionId) .setVariablesLocal(variables) .manualStart(); // then // the child case execution is active... CaseExecution caseExecution = caseExecutionQuery.singleResult(); assertTrue(caseExecution.isActive()); // ... and not enabled assertFalse(caseExecution.isEnabled()); // there exists a task Task task = taskService .createTaskQuery() .caseExecutionId(caseExecutionId) .singleResult(); assertNotNull(task); // the case instance has two variables: // - aVariableName // - anotherVariableName List<VariableInstance> result = runtimeService .createVariableInstanceQuery() .list(); assertFalse(result.isEmpty()); assertEquals(2, result.size()); for (VariableInstance variable : result) { assertEquals(caseExecutionId, variable.getCaseExecutionId()); assertEquals(caseInstanceId, variable.getCaseInstanceId()); if (variable.getName().equals("aVariableName")) { assertEquals("aVariableName", variable.getName()); assertEquals("abc", variable.getValue()); } else if (variable.getName().equals("anotherVariableName")) { assertEquals("anotherVariableName", variable.getName()); assertEquals(999, variable.getValue()); } else { fail("Unexpected variable: " + variable.getName()); } } }
Example 15
Source File: CaseServiceStageTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneStageCaseWithManualActivation.cmmn"}) public void testManualStartWithLocalVariables() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // an active case instance String caseInstanceId = caseService .withCaseDefinition(caseDefinitionId) .create() .getId(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); // an enabled child case execution of // the case instance String caseExecutionId = caseExecutionQuery .activityId("PI_Stage_1") .singleResult() .getId(); // variables Map<String, Object> variables = new HashMap<String, Object>(); variables.put("aVariableName", "abc"); variables.put("anotherVariableName", 999); // when // activate child case execution caseService .withCaseExecution(caseExecutionId) .setVariablesLocal(variables) .manualStart(); // then // the child case execution is active... CaseExecution caseExecution = caseExecutionQuery.singleResult(); assertTrue(caseExecution.isActive()); // ... and not enabled assertFalse(caseExecution.isEnabled()); // (1) one case case execution representing "PI_HumanTask_1" verifyTasksState(caseExecutionQuery); // the case instance has two variables: // - aVariableName // - anotherVariableName List<VariableInstance> result = runtimeService .createVariableInstanceQuery() .list(); verifyVariables(caseInstanceId, caseExecutionId, result); }
Example 16
Source File: CaseServiceHumanTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"}) public void testStartWithVariables() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // variables Map<String, Object> variables = new HashMap<String, Object>(); variables.put("aVariableName", "abc"); variables.put("anotherVariableName", 999); // an active case instance String caseInstanceId = caseService .withCaseDefinition(caseDefinitionId) .setVariables(variables) .create() .getId(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); // an enabled child case execution of // the case instance String caseExecutionId = caseExecutionQuery .activityId("PI_HumanTask_1") .singleResult() .getId(); // then // the child case execution is active... CaseExecution caseExecution = caseExecutionQuery.singleResult(); assertTrue(caseExecution.isActive()); // ... and not enabled assertFalse(caseExecution.isEnabled()); // there exists a task Task task = taskService .createTaskQuery() .caseExecutionId(caseExecutionId) .singleResult(); assertNotNull(task); // the case instance has two variables: // - aVariableName // - anotherVariableName List<VariableInstance> result = runtimeService .createVariableInstanceQuery() .list(); assertFalse(result.isEmpty()); assertEquals(2, result.size()); for (VariableInstance variable : result) { assertEquals(caseInstanceId, variable.getCaseExecutionId()); assertEquals(caseInstanceId, variable.getCaseInstanceId()); if (variable.getName().equals("aVariableName")) { assertEquals("aVariableName", variable.getName()); assertEquals("abc", variable.getValue()); } else if (variable.getName().equals("anotherVariableName")) { assertEquals("anotherVariableName", variable.getName()); assertEquals(999, variable.getValue()); } else { fail("Unexpected variable: " + variable.getName()); } } }
Example 17
Source File: CaseServiceHumanTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"}) public void testStartWithVariable() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); VariableMap variableMap = Variables.createVariables().putValue("aVariableName", "abc").putValue("anotherVariableName", 999); // an active case instance String caseInstanceId = caseService .withCaseDefinition(caseDefinitionId) .setVariables(variableMap) .create() .getId(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); // an enabled child case execution of // the case instance String caseExecutionId = caseExecutionQuery .activityId("PI_HumanTask_1") .singleResult() .getId(); // when // activate child case execution // then // the child case execution is active... CaseExecution caseExecution = caseExecutionQuery.singleResult(); assertTrue(caseExecution.isActive()); // ... and not enabled assertFalse(caseExecution.isEnabled()); // there exists a task Task task = taskService .createTaskQuery() .caseExecutionId(caseExecutionId) .singleResult(); assertNotNull(task); // the case instance has two variables: // - aVariableName // - anotherVariableName List<VariableInstance> result = runtimeService .createVariableInstanceQuery() .list(); assertFalse(result.isEmpty()); assertEquals(2, result.size()); for (VariableInstance variable : result) { assertEquals(caseInstanceId, variable.getCaseExecutionId()); assertEquals(caseInstanceId, variable.getCaseInstanceId()); if (variable.getName().equals("aVariableName")) { assertEquals("aVariableName", variable.getName()); assertEquals("abc", variable.getValue()); } else if (variable.getName().equals("anotherVariableName")) { assertEquals("anotherVariableName", variable.getName()); assertEquals(999, variable.getValue()); } else { fail("Unexpected variable: " + variable.getName()); } } }
Example 18
Source File: CaseServiceHumanTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"}) public void testStart() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // an active case instance caseService .withCaseDefinition(caseDefinitionId) .create(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); // an enabled child case execution of // the case instance String caseExecutionId = caseExecutionQuery .activityId("PI_HumanTask_1") .singleResult() .getId(); // when // activate child case execution // then // the child case execution is active... CaseExecution caseExecution = caseExecutionQuery.singleResult(); assertTrue(caseExecution.isActive()); // ... and not enabled assertFalse(caseExecution.isEnabled()); // there exists a task Task task = taskService .createTaskQuery() .caseExecutionId(caseExecutionId) .singleResult(); assertNotNull(task); }
Example 19
Source File: CaseServiceHumanTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn"}) public void testManualStartWithVariables() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // an active case instance String caseInstanceId = caseService .withCaseDefinition(caseDefinitionId) .create() .getId(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); // an enabled child case execution of // the case instance String caseExecutionId = caseExecutionQuery .activityId("PI_HumanTask_1") .singleResult() .getId(); // variables Map<String, Object> variables = new HashMap<String, Object>(); variables.put("aVariableName", "abc"); variables.put("anotherVariableName", 999); // when // activate child case execution caseService .withCaseExecution(caseExecutionId) .setVariables(variables) .manualStart(); // then // the child case execution is active... CaseExecution caseExecution = caseExecutionQuery.singleResult(); assertTrue(caseExecution.isActive()); // ... and not enabled assertFalse(caseExecution.isEnabled()); // there exists a task Task task = taskService .createTaskQuery() .caseExecutionId(caseExecutionId) .singleResult(); assertNotNull(task); // the case instance has two variables: // - aVariableName // - anotherVariableName List<VariableInstance> result = runtimeService .createVariableInstanceQuery() .list(); assertFalse(result.isEmpty()); assertEquals(2, result.size()); for (VariableInstance variable : result) { assertEquals(caseInstanceId, variable.getCaseExecutionId()); assertEquals(caseInstanceId, variable.getCaseInstanceId()); if (variable.getName().equals("aVariableName")) { assertEquals("aVariableName", variable.getName()); assertEquals("abc", variable.getValue()); } else if (variable.getName().equals("anotherVariableName")) { assertEquals("anotherVariableName", variable.getName()); assertEquals(999, variable.getValue()); } else { fail("Unexpected variable: " + variable.getName()); } } }
Example 20
Source File: CaseServiceHumanTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn"}) public void testManualStartWithVariable() { // given: // a deployed case definition String caseDefinitionId = repositoryService .createCaseDefinitionQuery() .singleResult() .getId(); // an active case instance String caseInstanceId = caseService .withCaseDefinition(caseDefinitionId) .create() .getId(); CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery(); // an enabled child case execution of // the case instance String caseExecutionId = caseExecutionQuery .activityId("PI_HumanTask_1") .singleResult() .getId(); // when // activate child case execution caseService .withCaseExecution(caseExecutionId) .setVariable("aVariableName", "abc") .setVariable("anotherVariableName", 999) .manualStart(); // then // the child case execution is active... CaseExecution caseExecution = caseExecutionQuery.singleResult(); assertTrue(caseExecution.isActive()); // ... and not enabled assertFalse(caseExecution.isEnabled()); // there exists a task Task task = taskService .createTaskQuery() .caseExecutionId(caseExecutionId) .singleResult(); assertNotNull(task); // the case instance has two variables: // - aVariableName // - anotherVariableName List<VariableInstance> result = runtimeService .createVariableInstanceQuery() .list(); assertFalse(result.isEmpty()); assertEquals(2, result.size()); for (VariableInstance variable : result) { assertEquals(caseInstanceId, variable.getCaseExecutionId()); assertEquals(caseInstanceId, variable.getCaseInstanceId()); if (variable.getName().equals("aVariableName")) { assertEquals("aVariableName", variable.getName()); assertEquals("abc", variable.getValue()); } else if (variable.getName().equals("anotherVariableName")) { assertEquals("anotherVariableName", variable.getName()); assertEquals(999, variable.getValue()); } else { fail("Unexpected variable: " + variable.getName()); } } }