Search in sources :

Example 1 with ScenarioUnderTest

use of org.camunda.bpm.qa.upgrade.ScenarioUnderTest in project camunda-bpm-platform by camunda.

the class InterruptingEventSubProcessNestedCompensationSenarioTest method testInitThrowCompensateCompletionCase1.

@Test
@ScenarioUnderTest("init.throwCompensate.1")
public void testInitThrowCompensateCompletionCase1() {
    // given
    Task undoTask = rule.taskQuery().singleResult();
    // when
    rule.getTaskService().complete(undoTask.getId());
    // then it is possible to complete the process successfully
    // by completing the sub process regularly
    Task afterCompensateTask = rule.taskQuery().singleResult();
    Assert.assertNotNull(afterCompensateTask);
    Assert.assertEquals("afterCompensate", afterCompensateTask.getTaskDefinitionKey());
    rule.getTaskService().complete(afterCompensateTask.getId());
    rule.assertScenarioEnded();
}
Also used : Task(org.camunda.bpm.engine.task.Task) Test(org.junit.Test) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest)

Example 2 with ScenarioUnderTest

use of org.camunda.bpm.qa.upgrade.ScenarioUnderTest in project camunda-bpm-platform by camunda.

the class InterruptingEventSubProcessNestedCompensationSenarioTest method testInitThrowCompensateCompletionCase2.

/**
 * Fails because wrongly destroy the sub process scope execution when completing the
 * compensation throw event. See CAM-4914
 */
@Ignore
@Test
@ScenarioUnderTest("init.throwCompensate.2")
public void testInitThrowCompensateCompletionCase2() {
    // given
    Task undoTask = rule.taskQuery().singleResult();
    // when
    rule.getTaskService().complete(undoTask.getId());
    // then it is possible to complete the process successfully
    // by triggering the message boundary event
    rule.messageCorrelation("BoundaryEventMessage").correlate();
    Task afterBoundaryTask = rule.taskQuery().singleResult();
    Assert.assertNotNull(afterBoundaryTask);
    Assert.assertEquals("afterBoundaryTask", afterBoundaryTask.getTaskDefinitionKey());
    rule.getTaskService().complete(afterBoundaryTask.getId());
    rule.assertScenarioEnded();
}
Also used : Task(org.camunda.bpm.engine.task.Task) Ignore(org.junit.Ignore) Test(org.junit.Test) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest)

Example 3 with ScenarioUnderTest

use of org.camunda.bpm.qa.upgrade.ScenarioUnderTest in project camunda-bpm-platform by camunda.

the class InterruptingEventSubProcessNestedCompensationSenarioTest method testInitThrowCompensateActivityInstanceTree.

@Test
@ScenarioUnderTest("init.throwCompensate.4")
public void testInitThrowCompensateActivityInstanceTree() {
    // given
    ProcessInstance processInstance = rule.processInstance();
    // when
    ActivityInstance tree = rule.getRuntimeService().getActivityInstance(processInstance.getId());
    // then
    Assert.assertNotNull(tree);
    assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("innerSubProcess").beginScope("throwCompensate").activity("undoTask").done());
}
Also used : ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest)

Example 4 with ScenarioUnderTest

use of org.camunda.bpm.qa.upgrade.ScenarioUnderTest in project camunda-bpm-platform by camunda.

the class NestedCompensationScenarioTest method testHistory.

@Test
@ScenarioUnderTest("init.throwCompensate.1")
public void testHistory() {
    // given
    Task compensationHandler = rule.taskQuery().singleResult();
    // when
    rule.getTaskService().complete(compensationHandler.getId());
    // then history is written for the remaining activity instances
    HistoricProcessInstance historicProcessInstance = rule.historicProcessInstance();
    Assert.assertNotNull(historicProcessInstance);
    Assert.assertNotNull(historicProcessInstance.getEndTime());
    HistoricActivityInstance subProcessInstance = rule.getHistoryService().createHistoricActivityInstanceQuery().processInstanceId(historicProcessInstance.getId()).activityId("subProcess").singleResult();
    Assert.assertNotNull(subProcessInstance);
    Assert.assertNotNull(subProcessInstance.getEndTime());
    Assert.assertEquals(historicProcessInstance.getId(), subProcessInstance.getParentActivityInstanceId());
    HistoricActivityInstance compensationThrowInstance = rule.getHistoryService().createHistoricActivityInstanceQuery().processInstanceId(historicProcessInstance.getId()).activityId("throwCompensate").singleResult();
    Assert.assertNotNull(compensationThrowInstance);
    Assert.assertNotNull(compensationThrowInstance.getEndTime());
    Assert.assertEquals(subProcessInstance.getId(), compensationThrowInstance.getParentActivityInstanceId());
    HistoricActivityInstance compensationHandlerInstance = rule.getHistoryService().createHistoricActivityInstanceQuery().processInstanceId(historicProcessInstance.getId()).activityId("undoTask").singleResult();
    Assert.assertNotNull(compensationHandlerInstance);
    Assert.assertNotNull(compensationHandlerInstance.getEndTime());
    Assert.assertEquals(subProcessInstance.getId(), compensationHandlerInstance.getParentActivityInstanceId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Test(org.junit.Test) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest)

Example 5 with ScenarioUnderTest

use of org.camunda.bpm.qa.upgrade.ScenarioUnderTest in project camunda-bpm-platform by camunda.

the class NonInterruptingEventSubProcessCompensationSenarioTest method testInitThrowCompensateCompletionCase1.

@Test
@ScenarioUnderTest("init.throwCompensate.1")
public void testInitThrowCompensateCompletionCase1() {
    // given
    Task outerTask = rule.taskQuery().taskDefinitionKey("outerTask").singleResult();
    Task undoTask = rule.taskQuery().taskDefinitionKey("undoTask").singleResult();
    // when
    rule.getTaskService().complete(undoTask.getId());
    // then it is possible to complete the process successfully
    Task afterCompensateTask = rule.taskQuery().taskDefinitionKey("afterCompensate").singleResult();
    Assert.assertNotNull(afterCompensateTask);
    Assert.assertEquals("afterCompensate", afterCompensateTask.getTaskDefinitionKey());
    rule.getTaskService().complete(afterCompensateTask.getId());
    rule.getTaskService().complete(outerTask.getId());
    rule.assertScenarioEnded();
}
Also used : Task(org.camunda.bpm.engine.task.Task) Test(org.junit.Test) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest)

Aggregations

ScenarioUnderTest (org.camunda.bpm.qa.upgrade.ScenarioUnderTest)314 Test (org.junit.Test)311 Task (org.camunda.bpm.engine.task.Task)190 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)183 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)80 ThrowBpmnErrorDelegateException (org.camunda.bpm.qa.upgrade.util.ThrowBpmnErrorDelegate.ThrowBpmnErrorDelegateException)19 Job (org.camunda.bpm.engine.runtime.Job)14 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)6 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)4 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)4 Ignore (org.junit.Ignore)4 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)3 HistoricTaskInstanceQuery (org.camunda.bpm.engine.history.HistoricTaskInstanceQuery)3 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)3 CaseSentryPartEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseSentryPartEntity)3 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)2 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)2 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)2 Execution (org.camunda.bpm.engine.runtime.Execution)2 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)2