Java Code Examples for org.camunda.bpm.engine.history.HistoricVariableInstanceQuery#singleResult()

The following examples show how to use org.camunda.bpm.engine.history.HistoricVariableInstanceQuery#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: HistoricVariableInstanceScopeTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 2
Source File: HistoricVariableInstanceScopeTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources={"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void testSetVariableLocalOnUserTask() {
  ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess");

  Task task = taskService.createTaskQuery().singleResult();
  assertNotNull(task);

  taskService.setVariableLocal(task.getId(), "testVar", "testValue");
  ExecutionEntity taskExecution = (ExecutionEntity) runtimeService.createExecutionQuery()
      .executionId(task.getExecutionId())
      .singleResult();
  assertNotNull(taskExecution);

  HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
  assertEquals(1, query.count());

  HistoricVariableInstance variable = query.singleResult();
  assertNotNull(variable);

  // the variable is in the task scope
  assertEquals(taskExecution.getActivityInstanceId(), variable.getActivityInstanceId());

  taskService.complete(task.getId());
  assertProcessEnded(pi.getId());
}
 
Example 3
Source File: HistoricVariableInstanceScopeTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 4
Source File: HistoricVariableInstanceScopeTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testSetVariableLocalOnServiceTaskInsideSubProcess() {
  ProcessInstance pi = runtimeService.startProcessInstanceByKey("process");

  HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
  assertEquals(1, query.count());

  String activityInstanceId = historyService.createHistoricActivityInstanceQuery()
      .activityId("SubProcess_1")
      .singleResult()
      .getId();

  HistoricVariableInstance variable = query.singleResult();
  // the variable is in the sub process scope
  assertEquals(activityInstanceId, variable.getActivityInstanceId());

  assertProcessEnded(pi.getId());
}
 
Example 5
Source File: HistoricVariableInstanceScopeTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testSetVariableLocalOnTaskInsideParallelBranch() {
  ProcessInstance pi = runtimeService.startProcessInstanceByKey("process");

  Task task = taskService.createTaskQuery().singleResult();
  assertNotNull(task);

  taskService.setVariableLocal(task.getId(), "testVar", "testValue");
  ExecutionEntity taskExecution = (ExecutionEntity) runtimeService.createExecutionQuery()
      .executionId(task.getExecutionId())
      .singleResult();
  assertNotNull(taskExecution);

  HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
  assertEquals(1, query.count());

  HistoricVariableInstance variable = query.singleResult();
  // the variable is in the user task scope
  assertEquals(taskExecution.getActivityInstanceId(), variable.getActivityInstanceId());

  taskService.complete(task.getId());

  assertProcessEnded(pi.getId());
}
 
Example 6
Source File: HistoricVariableInstanceScopeTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 7
Source File: HistoricVariableInstanceScopeTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testSetVariableLocalOnServiceTaskInsideParallelBranch() {
  ProcessInstance pi = runtimeService.startProcessInstanceByKey("process");

  HistoricActivityInstance serviceTask = historyService.createHistoricActivityInstanceQuery()
      .activityId("serviceTask1")
      .singleResult();
  assertNotNull(serviceTask);

  HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
  assertEquals(1, query.count());

  HistoricVariableInstance variable = query.singleResult();
  // the variable is in the service task scope
  assertEquals(serviceTask.getId(), variable.getActivityInstanceId());

  assertProcessEnded(pi.getId());
}
 
Example 8
Source File: HistoricVariableInstanceScopeTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example 9
Source File: HistoricVariableInstanceScopeTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment
public void testSetVariableOnServiceTaskInsideParallelBranch() {
  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());
}