Search in sources :

Example 41 with HistoricActivityInstance

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

the class InterruptingEventSubProcessCompensationSenarioTest method testInitThrowCompensateCompletionHistory.

/**
 * Does not work because in PvmAtomicOperationActivityInstanceEnd we don't correctly
 * detect that the compensation throw event has no dedicated scope execution, so we restore
 * activity instance IDs wrongly before firing the history listener.
 */
@Ignore
@Test
@ScenarioUnderTest("init.throwCompensate.2")
public void testInitThrowCompensateCompletionHistory() {
    // given
    ProcessInstance processInstance = rule.processInstance();
    Task undoTask = rule.taskQuery().singleResult();
    // when
    rule.getTaskService().complete(undoTask.getId());
    Task afterCompensateTask = rule.taskQuery().singleResult();
    rule.getTaskService().complete(afterCompensateTask.getId());
    // then the historic throw compensate instance has an end time
    HistoricActivityInstance throwCompensateInstance = rule.getHistoryService().createHistoricActivityInstanceQuery().processInstanceId(processInstance.getId()).activityId("throwCompensate").singleResult();
    Assert.assertNotNull(throwCompensateInstance.getEndTime());
}
Also used : Task(org.camunda.bpm.engine.task.Task) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Ignore(org.junit.Ignore) Test(org.junit.Test) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest)

Example 42 with HistoricActivityInstance

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

the class HistoricProcessInstanceTest method testHistoricProcInstQueryWithExecutedActivityIds.

@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testHistoricProcInstQueryWithExecutedActivityIds() {
    // given
    deployment(ProcessModels.TWO_TASKS_PROCESS);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
    Task task = taskService.createTaskQuery().active().singleResult();
    taskService.complete(task.getId());
    // assume
    HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstance.getId()).activityId("userTask1").singleResult();
    assertNotNull(historicActivityInstance);
    // when
    List<HistoricProcessInstance> result = historyService.createHistoricProcessInstanceQuery().executedActivityIdIn(historicActivityInstance.getActivityId()).list();
    // then
    assertNotNull(result);
    assertEquals(1, result.size());
    assertEquals(result.get(0).getId(), processInstance.getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Test(org.junit.Test) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 43 with HistoricActivityInstance

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

the class HistoricProcessInstanceTest method testHistoricProcInstQueryWithActiveActivityIds.

@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testHistoricProcInstQueryWithActiveActivityIds() {
    // given
    deployment(ProcessModels.TWO_TASKS_PROCESS);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
    // assume
    HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("userTask1").singleResult();
    assertNotNull(historicActivityInstance);
    // when
    List<HistoricProcessInstance> result = historyService.createHistoricProcessInstanceQuery().activeActivityIdIn(historicActivityInstance.getActivityId()).list();
    // then
    assertNotNull(result);
    assertEquals(1, result.size());
    assertEquals(result.get(0).getId(), processInstance.getId());
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Test(org.junit.Test) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 44 with HistoricActivityInstance

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

the class HistoricTaskInstanceTest method testHistoricTaskInstanceAssignmentListener.

@Deployment
public void testHistoricTaskInstanceAssignmentListener() {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("assignee", "jonny");
    runtimeService.startProcessInstanceByKey("testProcess", variables);
    HistoricActivityInstance hai = historyService.createHistoricActivityInstanceQuery().activityId("task").singleResult();
    assertEquals("jonny", hai.getAssignee());
    HistoricTaskInstance hti = historyService.createHistoricTaskInstanceQuery().singleResult();
    assertEquals("jonny", hti.getAssignee());
    assertNull(hti.getOwner());
}
Also used : HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) HashMap(java.util.HashMap) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 45 with HistoricActivityInstance

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

the class FullHistoryTest method testHistoricFormPropertiesOnReEnteringActivity.

/**
 * Test created to validate ACT-621 fix.
 */
@Test
@Deployment
public void testHistoricFormPropertiesOnReEnteringActivity() {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("comeBack", Boolean.TRUE);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("HistoricFormPropertiesProcess", variables);
    assertNotNull(processInstance);
    // Submit form on task
    Map<String, String> data = new HashMap<String, String>();
    data.put("formProp1", "Property value");
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    formService.submitTaskFormData(task.getId(), data);
    // Historic property should be available
    List<HistoricDetail> details = historyService.createHistoricDetailQuery().formProperties().processInstanceId(processInstance.getId()).list();
    assertNotNull(details);
    assertEquals(1, details.size());
    // Task should be active in the same activity as the previous one
    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    formService.submitTaskFormData(task.getId(), data);
    details = historyService.createHistoricDetailQuery().formProperties().processInstanceId(processInstance.getId()).list();
    assertNotNull(details);
    assertEquals(2, details.size());
    // Should have 2 different historic activity instance ID's, with the same activityId
    Assert.assertNotSame(details.get(0).getActivityInstanceId(), details.get(1).getActivityInstanceId());
    HistoricActivityInstance historicActInst1 = historyService.createHistoricActivityInstanceQuery().activityInstanceId(details.get(0).getActivityInstanceId()).singleResult();
    HistoricActivityInstance historicActInst2 = historyService.createHistoricActivityInstanceQuery().activityInstanceId(details.get(1).getActivityInstanceId()).singleResult();
    assertEquals(historicActInst1.getActivityId(), historicActInst2.getActivityId());
}
Also used : HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) Task(org.camunda.bpm.engine.task.Task) HashMap(java.util.HashMap) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)80 Deployment (org.camunda.bpm.engine.test.Deployment)56 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)45 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)24 Task (org.camunda.bpm.engine.task.Task)19 Test (org.junit.Test)17 HistoricActivityInstanceQuery (org.camunda.bpm.engine.history.HistoricActivityInstanceQuery)13 HashMap (java.util.HashMap)12 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)8 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)6 Date (java.util.Date)5 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)5 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)5 HistoricTaskInstance (org.camunda.bpm.engine.history.HistoricTaskInstance)4 ArrayList (java.util.ArrayList)3 HistoryService (org.camunda.bpm.engine.HistoryService)3 HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)3 Response (com.jayway.restassured.response.Response)2 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)2 HistoricVariableInstanceQuery (org.camunda.bpm.engine.history.HistoricVariableInstanceQuery)2