Search in sources :

Example 31 with HistoricDetail

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

the class BulkHistoryDeleteTest method testCleanupHistoryCaseInstanceTaskDetails.

@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCleanupHistoryCaseInstanceTaskDetails() {
    // given
    // create case instance
    CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase");
    Task task = taskService.createTaskQuery().singleResult();
    taskService.setVariable(task.getId(), "boo", new TestPojo("foo", 123.0));
    taskService.setVariable(task.getId(), "goo", 9);
    taskService.setVariable(task.getId(), "boo", new TestPojo("foo", 321.0));
    // assume
    List<HistoricDetail> detailsList = historyService.createHistoricDetailQuery().list();
    assertEquals(3, detailsList.size());
    terminateAndCloseCaseInstance(caseInstance.getId(), taskService.getVariables(task.getId()));
    // when
    historyService.deleteHistoricCaseInstancesBulk(Arrays.asList(caseInstance.getId()));
    // then
    detailsList = historyService.createHistoricDetailQuery().list();
    assertEquals(0, detailsList.size());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) Task(org.camunda.bpm.engine.task.Task) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) TestPojo(org.camunda.bpm.engine.test.dmn.businessruletask.TestPojo) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 32 with HistoricDetail

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

the class BulkHistoryDeleteTest method testCleanupHistoryCaseInstanceComplexVariable.

@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCleanupHistoryCaseInstanceComplexVariable() {
    // given
    // create case instances
    VariableMap variables = Variables.createVariables();
    CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase", variables.putValue("pojo", new TestPojo("okay", 13.37)));
    caseService.setVariable(caseInstance.getId(), "pojo", "theValue");
    // assume
    List<HistoricVariableInstance> variablesInstances = historyService.createHistoricVariableInstanceQuery().list();
    assertEquals(1, variablesInstances.size());
    List<HistoricDetail> detailsList = historyService.createHistoricDetailQuery().list();
    assertEquals(2, detailsList.size());
    terminateAndCloseCaseInstance(caseInstance.getId(), variables);
    // when
    historyService.deleteHistoricCaseInstancesBulk(Arrays.asList(caseInstance.getId()));
    // then
    variablesInstances = historyService.createHistoricVariableInstanceQuery().list();
    assertEquals(0, variablesInstances.size());
    detailsList = historyService.createHistoricDetailQuery().list();
    assertEquals(0, detailsList.size());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) VariableMap(org.camunda.bpm.engine.variable.VariableMap) TestPojo(org.camunda.bpm.engine.test.dmn.businessruletask.TestPojo) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 33 with HistoricDetail

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

the class ProcessInstanceModificationHistoryTest method testStartBeforeAsyncWithVariablesInHistory.

@Deployment(resources = EXCLUSIVE_GATEWAY_ASYNC_TASK_PROCESS)
public void testStartBeforeAsyncWithVariablesInHistory() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exclusiveGateway");
    runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("task2").setVariable("procInstVar", "procInstValue").setVariableLocal("localVar", "localValue").execute();
    ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstance.getId());
    HistoricVariableInstance procInstVariable = historyService.createHistoricVariableInstanceQuery().variableName("procInstVar").singleResult();
    assertNotNull(procInstVariable);
    assertEquals(updatedTree.getId(), procInstVariable.getActivityInstanceId());
    assertEquals("procInstVar", procInstVariable.getName());
    assertEquals("procInstValue", procInstVariable.getValue());
    HistoricDetail procInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(procInstVariable.getId()).singleResult();
    assertNotNull(procInstanceVarDetail);
    // when starting before/after an activity instance, the activity instance id of the
    // execution is null and so is the activity instance id of the historic detail
    assertNull(procInstanceVarDetail.getActivityInstanceId());
    HistoricVariableInstance localVariable = historyService.createHistoricVariableInstanceQuery().variableName("localVar").singleResult();
    assertNotNull(localVariable);
    // the following is null because localVariable is local on a concurrent execution
    // but the concurrent execution does not execute an activity at the time the variable is set
    assertNull(localVariable.getActivityInstanceId());
    assertEquals("localVar", localVariable.getName());
    assertEquals("localValue", localVariable.getValue());
    HistoricDetail localInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(localVariable.getId()).singleResult();
    assertNotNull(localInstanceVarDetail);
    assertNull(localInstanceVarDetail.getActivityInstanceId());
    // end process instance
    completeTasksInOrder("task1");
    Job job = managementService.createJobQuery().singleResult();
    managementService.executeJob(job.getId());
    completeTasksInOrder("task2");
    assertProcessEnded(processInstance.getId());
}
Also used : HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Job(org.camunda.bpm.engine.runtime.Job) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 34 with HistoricDetail

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

the class ProcessInstanceModificationHistoryTest method testStartBeforeWithVariablesInHistory.

@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testStartBeforeWithVariablesInHistory() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exclusiveGateway");
    runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("task2").setVariable("procInstVar", "procInstValue").setVariableLocal("localVar", "localValue").execute();
    ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstance.getId());
    HistoricVariableInstance procInstVariable = historyService.createHistoricVariableInstanceQuery().variableName("procInstVar").singleResult();
    assertNotNull(procInstVariable);
    assertEquals(updatedTree.getId(), procInstVariable.getActivityInstanceId());
    assertEquals("procInstVar", procInstVariable.getName());
    assertEquals("procInstValue", procInstVariable.getValue());
    HistoricDetail procInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(procInstVariable.getId()).singleResult();
    assertNotNull(procInstanceVarDetail);
    // when starting before/after an activity instance, the activity instance id of the
    // execution is null and so is the activity instance id of the historic detail
    assertNull(procInstanceVarDetail.getActivityInstanceId());
    HistoricVariableInstance localVariable = historyService.createHistoricVariableInstanceQuery().variableName("localVar").singleResult();
    assertNotNull(localVariable);
    assertNull(localVariable.getActivityInstanceId());
    assertEquals("localVar", localVariable.getName());
    assertEquals("localValue", localVariable.getValue());
    HistoricDetail localInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(localVariable.getId()).singleResult();
    assertNotNull(localInstanceVarDetail);
    assertNull(localInstanceVarDetail.getActivityInstanceId());
    completeTasksInOrder("task1", "task2");
    assertProcessEnded(processInstance.getId());
}
Also used : HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 35 with HistoricDetail

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

the class ProcessInstanceModificationHistoryTest method testStartBeforeScopeWithVariablesInHistory.

@Deployment(resources = SUBPROCESS_PROCESS)
public void testStartBeforeScopeWithVariablesInHistory() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subprocess");
    runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("innerTask").setVariable("procInstVar", "procInstValue").setVariableLocal("localVar", "localValue").execute();
    ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstance.getId());
    HistoricVariableInstance procInstVariable = historyService.createHistoricVariableInstanceQuery().variableName("procInstVar").singleResult();
    assertNotNull(procInstVariable);
    assertEquals(updatedTree.getId(), procInstVariable.getActivityInstanceId());
    assertEquals("procInstVar", procInstVariable.getName());
    assertEquals("procInstValue", procInstVariable.getValue());
    HistoricDetail procInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(procInstVariable.getId()).singleResult();
    assertNotNull(procInstanceVarDetail);
    // when starting before/after an activity instance, the activity instance id of the
    // execution is null and so is the activity instance id of the historic detail
    assertNull(procInstanceVarDetail.getActivityInstanceId());
    HistoricVariableInstance localVariable = historyService.createHistoricVariableInstanceQuery().variableName("localVar").singleResult();
    assertNotNull(localVariable);
    assertEquals(updatedTree.getActivityInstances("subProcess")[0].getId(), localVariable.getActivityInstanceId());
    assertEquals("localVar", localVariable.getName());
    assertEquals("localValue", localVariable.getValue());
    HistoricDetail localInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(localVariable.getId()).singleResult();
    assertNotNull(localInstanceVarDetail);
    assertNull(localInstanceVarDetail.getActivityInstanceId());
}
Also used : HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)40 Deployment (org.camunda.bpm.engine.test.Deployment)23 Test (org.junit.Test)20 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)14 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)14 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)14 Task (org.camunda.bpm.engine.task.Task)13 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)12 HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)10 HashMap (java.util.HashMap)7 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)7 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)6 ArrayList (java.util.ArrayList)3 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)3 HistoricDetailVariableInstanceUpdateEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity)3 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 HistoricDetailQuery (org.camunda.bpm.engine.history.HistoricDetailQuery)2 HistoricFormProperty (org.camunda.bpm.engine.history.HistoricFormProperty)2 HistoricVariableInstanceQuery (org.camunda.bpm.engine.history.HistoricVariableInstanceQuery)2