Search in sources :

Example 11 with ScenarioUnderTest

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

the class SequentialMultiInstanceCompensationScenarioTest method testDefaultHandlerThrowCompensateCompletion.

@Test
@ScenarioUnderTest("defaultHandler.beforeCompensate.throwCompensate.1")
public void testDefaultHandlerThrowCompensateCompletion() {
    // given active compensation
    List<Task> miCompensationTasks = rule.taskQuery().list();
    Assert.assertEquals(3, miCompensationTasks.size());
    // when completing the compensation handlers
    for (int i = 0; i < miCompensationTasks.size(); i++) {
        Assert.assertEquals(3 - i, rule.taskQuery().count());
        Task compensationTask = miCompensationTasks.get(i);
        Assert.assertEquals("undoTask", compensationTask.getTaskDefinitionKey());
        rule.getTaskService().complete(compensationTask.getId());
    }
    // then it is possible to complete the process successfully
    Task afterCompensateTask = rule.taskQuery().singleResult();
    Assert.assertNotNull(afterCompensateTask);
    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 12 with ScenarioUnderTest

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

the class SequentialMultiInstanceCompensationScenarioTest method testDefaultHandlerMultiInstancePartialCompletion.

@Test
@ScenarioUnderTest("defaultHandler.multiInstancePartial.1")
public void testDefaultHandlerMultiInstancePartialCompletion() {
    // given the last multi instance task
    Task lastMiTask = rule.taskQuery().singleResult();
    // when completing it
    rule.getTaskService().complete(lastMiTask.getId());
    // then it is possible to throw compensation, compensate the three instances,
    // and finish the process successfully
    Task beforeCompensateTask = rule.taskQuery().singleResult();
    Assert.assertNotNull(beforeCompensateTask);
    rule.getTaskService().complete(beforeCompensateTask.getId());
    List<Task> miCompensationTasks = rule.taskQuery().list();
    Assert.assertEquals(3, miCompensationTasks.size());
    for (int i = 0; i < miCompensationTasks.size(); i++) {
        Assert.assertEquals(3 - i, rule.taskQuery().count());
        Task compensationTask = miCompensationTasks.get(i);
        Assert.assertEquals("undoTask", compensationTask.getTaskDefinitionKey());
        rule.getTaskService().complete(compensationTask.getId());
    }
    Task afterCompensateTask = rule.taskQuery().singleResult();
    Assert.assertNotNull(afterCompensateTask);
    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 13 with ScenarioUnderTest

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

the class SequentialMultiInstanceCompensationScenarioTest method testDefaultHandlerMultiInstancePartialDeletion.

@Test
@ScenarioUnderTest("defaultHandler.multiInstancePartial.2")
public void testDefaultHandlerMultiInstancePartialDeletion() {
    // when throwing compensation
    Task lastMiTask = rule.taskQuery().singleResult();
    rule.getTaskService().complete(lastMiTask.getId());
    Task beforeCompensateTask = rule.taskQuery().singleResult();
    rule.getTaskService().complete(beforeCompensateTask.getId());
    // then it is possible to delete the process instance
    rule.getRuntimeService().deleteProcessInstance(rule.processInstance().getId(), null);
    // and the process is ended
    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 14 with ScenarioUnderTest

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

the class SequentialMultiInstanceCompensationScenarioTest method testSubProcessHandlerThrowCompensateCompletion.

@Test
@ScenarioUnderTest("subProcessHandler.beforeCompensate.throwCompensate.1")
public void testSubProcessHandlerThrowCompensateCompletion() {
    // given active compensation
    List<Task> miCompensationTasks = rule.taskQuery().list();
    Assert.assertEquals(3, miCompensationTasks.size());
    // when completing the compensation handlers
    for (int i = 0; i < miCompensationTasks.size(); i++) {
        Assert.assertEquals(3 - i, rule.taskQuery().count());
        Task compensationTask = miCompensationTasks.get(i);
        Assert.assertEquals("undoTask", compensationTask.getTaskDefinitionKey());
        rule.getTaskService().complete(compensationTask.getId());
    }
    // then it is possible to complete the process successfully
    Task afterCompensateTask = rule.taskQuery().singleResult();
    Assert.assertNotNull(afterCompensateTask);
    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 15 with ScenarioUnderTest

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

the class SequentialMultiInstanceCompensationScenarioTest method testSubProcessHandlerMultiInstancePartialActivityInstanceTree.

@Test
@ScenarioUnderTest("subProcessHandler.multiInstancePartial.3")
public void testSubProcessHandlerMultiInstancePartialActivityInstanceTree() {
    // given
    ProcessInstance instance = rule.processInstance();
    // when throwing compensation
    Task lastMiTask = rule.taskQuery().singleResult();
    rule.getTaskService().complete(lastMiTask.getId());
    Task beforeCompensateTask = rule.taskQuery().singleResult();
    rule.getTaskService().complete(beforeCompensateTask.getId());
    // then the activity instance tree is meaningful
    ActivityInstance activityInstance = rule.getRuntimeService().getActivityInstance(instance.getId());
    Assert.assertNotNull(activityInstance);
    assertThat(activityInstance).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).activity("throwCompensate").beginScope("undoSubProcess", "userTask#multiInstanceBody").beginScope("undoSubProcess").activity("undoTask").endScope().activity("undoTask").activity("undoTask").done());
}
Also used : Task(org.camunda.bpm.engine.task.Task) 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)

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