Search in sources :

Example 31 with HistoricVariableInstance

use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.

the class TaskListenerTest method testScriptResourceListener.

@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/tasklistener/TaskListenerTest.testScriptResourceListener.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/tasklistener/taskListener.groovy" })
public void testScriptResourceListener() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
    assertTrue((Boolean) runtimeService.getVariable(processInstance.getId(), "create"));
    taskService.setAssignee(task.getId(), "test");
    assertTrue((Boolean) runtimeService.getVariable(processInstance.getId(), "assignment"));
    taskService.complete(task.getId());
    assertTrue((Boolean) runtimeService.getVariable(processInstance.getId(), "complete"));
    task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
    runtimeService.deleteProcessInstance(processInstance.getId(), "test");
    if (processEngineConfiguration.getHistoryLevel().getId() >= HISTORYLEVEL_AUDIT) {
        HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().variableName("delete").singleResult();
        assertNotNull(variable);
        assertTrue((Boolean) variable.getValue());
    }
}
Also used : DelegateTask(org.camunda.bpm.engine.delegate.DelegateTask) Task(org.camunda.bpm.engine.task.Task) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 32 with HistoricVariableInstance

use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.

the class HistoricVariableInstanceScopeTest method testSetVariableOnServiceTaskInsideSubProcess.

@Deployment
public void testSetVariableOnServiceTaskInsideSubProcess() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("process");
    HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
    assertEquals(1, query.count());
    HistoricVariableInstance variable = query.singleResult();
    // the variable is in the process instance scope
    assertEquals(pi.getId(), variable.getActivityInstanceId());
    assertProcessEnded(pi.getId());
}
Also used : HistoricVariableInstanceQuery(org.camunda.bpm.engine.history.HistoricVariableInstanceQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 33 with HistoricVariableInstance

use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.

the class HistoricVariableInstanceScopeTest method testSetVariableOnProcessInstanceStart.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testSetVariableOnProcessInstanceStart() {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("testVar", "testValue");
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
    HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
    assertEquals(1, query.count());
    HistoricVariableInstance variable = query.singleResult();
    assertNotNull(variable);
    // the variable is in the process instance scope
    assertEquals(pi.getId(), variable.getActivityInstanceId());
    taskService.complete(taskService.createTaskQuery().singleResult().getId());
    assertProcessEnded(pi.getId());
}
Also used : HashMap(java.util.HashMap) HistoricVariableInstanceQuery(org.camunda.bpm.engine.history.HistoricVariableInstanceQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 34 with HistoricVariableInstance

use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.

the class HistoricVariableInstanceScopeTest method testSetVariableOnProcessIntanceStartAndSetVariableLocalOnUserTask.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testSetVariableOnProcessIntanceStartAndSetVariableLocalOnUserTask() {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("testVar", "testValue");
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
    taskService.setVariableLocal(task.getId(), "testVar", "anotherTestValue");
    ExecutionEntity taskExecution = (ExecutionEntity) runtimeService.createExecutionQuery().singleResult();
    assertNotNull(taskExecution);
    HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
    assertEquals(2, query.count());
    List<HistoricVariableInstance> result = query.list();
    HistoricVariableInstance firstVar = result.get(0);
    assertEquals("testVar", firstVar.getVariableName());
    assertEquals("testValue", firstVar.getValue());
    // the variable is in the process instance scope
    assertEquals(pi.getId(), firstVar.getActivityInstanceId());
    HistoricVariableInstance secondVar = result.get(1);
    assertEquals("testVar", secondVar.getVariableName());
    assertEquals("anotherTestValue", secondVar.getValue());
    // the variable is in the task scope
    assertEquals(taskExecution.getActivityInstanceId(), secondVar.getActivityInstanceId());
    taskService.complete(task.getId());
    assertProcessEnded(pi.getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) HashMap(java.util.HashMap) HistoricVariableInstanceQuery(org.camunda.bpm.engine.history.HistoricVariableInstanceQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 35 with HistoricVariableInstance

use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.

the class HistoricVariableInstanceScopeTest method testSetVariableOnUserTaskInsideSubProcess.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneSubProcess.bpmn20.xml" })
public void testSetVariableOnUserTaskInsideSubProcess() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("startSimpleSubProcess");
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
    taskService.setVariable(task.getId(), "testVar", "testValue");
    HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
    assertEquals(1, query.count());
    HistoricVariableInstance variable = query.singleResult();
    // the variable is in the process instance scope
    assertEquals(pi.getId(), variable.getActivityInstanceId());
    taskService.complete(task.getId());
    assertProcessEnded(pi.getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricVariableInstanceQuery(org.camunda.bpm.engine.history.HistoricVariableInstanceQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)88 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)44 Test (org.junit.Test)42 Deployment (org.camunda.bpm.engine.test.Deployment)39 HistoricVariableInstanceQuery (org.camunda.bpm.engine.history.HistoricVariableInstanceQuery)18 Task (org.camunda.bpm.engine.task.Task)17 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)14 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)13 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)12 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)12 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)10 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)10 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)10 HashMap (java.util.HashMap)8 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)8 VariableMap (org.camunda.bpm.engine.variable.VariableMap)8 HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)7 Date (java.util.Date)6 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)6 MockHistoricVariableInstanceBuilder (org.camunda.bpm.engine.rest.helper.MockHistoricVariableInstanceBuilder)6