Search in sources :

Example 61 with Task

use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.

the class FilterTaskQueryTest method testExtendingTaskQueryListWithCandidateGroups.

public void testExtendingTaskQueryListWithCandidateGroups() {
    TaskQuery query = taskService.createTaskQuery();
    List<String> candidateGroups = new ArrayList<String>();
    candidateGroups.add("accounting");
    query.taskCandidateGroupIn(candidateGroups);
    saveQuery(query);
    List<Task> tasks = filterService.list(filter.getId());
    assertEquals(1, tasks.size());
    tasks = filterService.list(filter.getId(), query);
    assertEquals(1, tasks.size());
    TaskQuery extendingQuery = taskService.createTaskQuery();
    extendingQuery.orderByTaskCreateTime().asc();
    tasks = filterService.list(filter.getId(), extendingQuery);
    assertEquals(1, tasks.size());
}
Also used : Task(org.camunda.bpm.engine.task.Task) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ArrayList(java.util.ArrayList)

Example 62 with Task

use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.

the class CaseServiceHumanTaskTest method testCompleteWithRemoveVariableLocal.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn" })
public void testCompleteWithRemoveVariableLocal() {
    // given:
    // a deployed case definition
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    // an active case instance
    caseService.withCaseDefinition(caseDefinitionId).create();
    String caseExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    caseService.withCaseExecution(caseExecutionId).setVariableLocal("aVariableName", "abc").setVariableLocal("anotherVariableName", 999).manualStart();
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
    // when
    caseService.withCaseExecution(caseExecutionId).removeVariableLocal("aVariableName").removeVariableLocal("anotherVariableName").complete();
    // then
    // the task has been completed and has been deleted
    task = taskService.createTaskQuery().singleResult();
    assertNull(task);
    // the corresponding case execution has been also
    // deleted and completed
    CaseExecution caseExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
    assertNull(caseExecution);
    // the case instance is still active
    CaseInstance caseInstance = caseService.createCaseInstanceQuery().active().singleResult();
    assertNotNull(caseInstance);
    assertTrue(caseInstance.isActive());
    List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list();
    assertTrue(result.isEmpty());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) Task(org.camunda.bpm.engine.task.Task) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 63 with Task

use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.

the class CaseServiceHumanTaskTest method testManualStartWithLocalVariable.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.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_HumanTask_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());
    // 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());
        }
    }
}
Also used : Task(org.camunda.bpm.engine.task.Task) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 64 with Task

use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.

the class CaseServiceHumanTaskTest method testCompleteWithVariablesNonFluent.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn" })
public void testCompleteWithVariablesNonFluent() {
    // given:
    // a deployed case definition
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    // an active case instance
    String caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().getId();
    String caseExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    caseService.withCaseExecution(caseExecutionId).manualStart();
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
    // when
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("aVariable", "aValue");
    caseService.completeCaseExecution(caseExecutionId, variables);
    // then
    // the task has been completed and has been deleted
    assertNull(taskService.createTaskQuery().singleResult());
    // the corresponding case execution has been also
    // deleted and completed
    CaseExecution caseExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
    assertNull(caseExecution);
    // 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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) HashMap(java.util.HashMap) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 65 with Task

use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.

the class CaseServiceHumanTaskTest method testCompleteWithSetVariableLocal.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn" })
public void testCompleteWithSetVariableLocal() {
    // given:
    // a deployed case definition
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    // an active case instance
    caseService.withCaseDefinition(caseDefinitionId).create();
    String caseExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    caseService.withCaseExecution(caseExecutionId).manualStart();
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
    // when
    caseService.withCaseExecution(caseExecutionId).setVariableLocal("aVariableName", "abc").setVariableLocal("anotherVariableName", 999).complete();
    // then
    // the task has been completed and has been deleted
    task = taskService.createTaskQuery().singleResult();
    assertNull(task);
    // the corresponding case execution has been also
    // deleted and completed
    CaseExecution caseExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
    assertNull(caseExecution);
    // the case instance is still active
    CaseInstance caseInstance = caseService.createCaseInstanceQuery().active().singleResult();
    assertNotNull(caseInstance);
    assertTrue(caseInstance.isActive());
    // the variables has been set and due to the completion
    // also removed in one command
    List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list();
    assertTrue(result.isEmpty());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) Task(org.camunda.bpm.engine.task.Task) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

Task (org.camunda.bpm.engine.task.Task)1654 Deployment (org.camunda.bpm.engine.test.Deployment)788 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)660 Test (org.junit.Test)648 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)230 ScenarioUnderTest (org.camunda.bpm.qa.upgrade.ScenarioUnderTest)190 HashMap (java.util.HashMap)140 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)139 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)108 Execution (org.camunda.bpm.engine.runtime.Execution)99 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)98 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)87 Job (org.camunda.bpm.engine.runtime.Job)71 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)67 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)52 DescribesScenario (org.camunda.bpm.qa.upgrade.DescribesScenario)46 ScenarioSetup (org.camunda.bpm.qa.upgrade.ScenarioSetup)46 Times (org.camunda.bpm.qa.upgrade.Times)46 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)45 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)45