Search in sources :

Example 16 with HistoricVariableInstanceQuery

use of org.camunda.bpm.engine.history.HistoricVariableInstanceQuery 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 17 with HistoricVariableInstanceQuery

use of org.camunda.bpm.engine.history.HistoricVariableInstanceQuery 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 18 with HistoricVariableInstanceQuery

use of org.camunda.bpm.engine.history.HistoricVariableInstanceQuery 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 19 with HistoricVariableInstanceQuery

use of org.camunda.bpm.engine.history.HistoricVariableInstanceQuery 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)

Example 20 with HistoricVariableInstanceQuery

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

the class HistoricVariableInstanceScopeTest method testSetVariableOnTaskInsideParallelBranch.

@Deployment(resources = { "org/camunda/bpm/engine/test/history/HistoricVariableInstanceScopeTest.testSetVariableLocalOnTaskInsideParallelBranch.bpmn" })
public void testSetVariableOnTaskInsideParallelBranch() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("process");
    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

HistoricVariableInstanceQuery (org.camunda.bpm.engine.history.HistoricVariableInstanceQuery)48 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)21 Deployment (org.camunda.bpm.engine.test.Deployment)21 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)18 Task (org.camunda.bpm.engine.task.Task)8 Test (org.junit.Test)5 HashMap (java.util.HashMap)4 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)3 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)3 ArrayList (java.util.ArrayList)2 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)2 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)2 HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HistoricVariableInstanceQueryImpl (org.camunda.bpm.engine.impl.HistoricVariableInstanceQueryImpl)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 HistoricVariableInstanceDto (org.camunda.bpm.engine.rest.dto.history.HistoricVariableInstanceDto)1 Job (org.camunda.bpm.engine.runtime.Job)1 SerializableVariable (org.camunda.bpm.engine.test.history.SerializableVariable)1