use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method executeModificationJobsForStartTransition.
@Test
public void executeModificationJobsForStartTransition() {
DeploymentWithDefinitions deployment = testRule.deploy(instance);
ProcessDefinition processDefinition = deployment.getDeployedProcessDefinitions().get(0);
Batch batch = helper.startTransitionAsync("process1", 10, "seq", processDefinition.getId());
helper.executeSeedJob(batch);
List<Job> modificationJobs = helper.getExecutionJobs(batch);
// when
for (Job modificationJob : modificationJobs) {
helper.executeJob(modificationJob);
}
// then all process instances where modified
for (String processInstanceId : helper.currentProcessInstances) {
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processDefinition.getId()).activity("user1").activity("user2").done());
}
// and the no modification jobs exist
assertEquals(0, helper.getExecutionJobs(batch).size());
// but a monitor job exists
assertNotNull(helper.getMonitorJob(batch));
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method executeModificationJobsForStartBeforeAndCancelAll.
@Test
public void executeModificationJobsForStartBeforeAndCancelAll() {
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
List<String> instances = helper.startInstances("process1", 10);
Batch batch = runtimeService.createModification(processDefinition.getId()).startBeforeActivity("user1").cancelAllForActivity("user1").processInstanceIds(instances).executeAsync();
helper.executeSeedJob(batch);
List<Job> modificationJobs = helper.getExecutionJobs(batch);
// when
for (Job modificationJob : modificationJobs) {
helper.executeJob(modificationJob);
}
// then all process instances where modified
for (String processInstanceId : helper.currentProcessInstances) {
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNull(updatedTree);
}
// and the no modification jobs exist
assertEquals(0, helper.getExecutionJobs(batch).size());
// but a monitor job exists
assertNotNull(helper.getMonitorJob(batch));
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method executeModificationJobsForStartBefore.
@Test
public void executeModificationJobsForStartBefore() {
DeploymentWithDefinitions deployment = testRule.deploy(instance);
ProcessDefinition processDefinition = deployment.getDeployedProcessDefinitions().get(0);
Batch batch = helper.startBeforeAsync("process1", 10, "user2", processDefinition.getId());
helper.executeSeedJob(batch);
List<Job> modificationJobs = helper.getExecutionJobs(batch);
// when
for (Job modificationJob : modificationJobs) {
helper.executeJob(modificationJob);
}
// then all process instances where modified
for (String processInstanceId : helper.currentProcessInstances) {
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processDefinition.getId()).activity("user1").activity("user2").done());
}
// and the no modification jobs exist
assertEquals(0, helper.getExecutionJobs(batch).size());
// but a monitor job exists
assertNotNull(helper.getMonitorJob(batch));
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method testModificationJobsExecutionByJobExecutorWithAuthorizationEnabledAndTenant.
@Test
public void testModificationJobsExecutionByJobExecutorWithAuthorizationEnabledAndTenant() {
ProcessEngineConfigurationImpl processEngineConfiguration = rule.getProcessEngineConfiguration();
processEngineConfiguration.setAuthorizationEnabled(true);
ProcessDefinition processDefinition = testRule.deployForTenantAndGetDefinition("tenantId", instance);
try {
Batch batch = helper.startAfterAsync("process1", 10, "user1", processDefinition.getId());
helper.executeSeedJob(batch);
testRule.waitForJobExecutorToProcessAllJobs();
// then all process instances where modified
for (String processInstanceId : helper.currentProcessInstances) {
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processDefinition.getId()).activity("user1").activity("user2").done());
}
} finally {
processEngineConfiguration.setAuthorizationEnabled(false);
}
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationAsyncTest method testCancelTransitionInstanceTwiceFails.
/**
* CAM-4090
*/
@Deployment(resources = NESTED_ASYNC_BEFORE_TASK_PROCESS)
public void testCancelTransitionInstanceTwiceFails() {
// given there are two transition instances in an inner scope
// and an active activity instance in an outer scope
ProcessInstance instance = runtimeService.createProcessInstanceByKey("nestedOneTaskProcess").startBeforeActivity("innerTask").startBeforeActivity("innerTask").execute();
ActivityInstance tree = runtimeService.getActivityInstance(instance.getId());
// when i cancel both transition instances
TransitionInstance[] transitionInstances = tree.getTransitionInstances("innerTask");
// this test ensures that the replacedBy link of executions is not followed
// in case the original execution was actually removed/cancelled
String transitionInstanceId = transitionInstances[0].getId();
try {
runtimeService.createProcessInstanceModification(instance.getId()).cancelTransitionInstance(transitionInstanceId).cancelTransitionInstance(transitionInstanceId).execute();
fail("should not be possible to cancel the first instance twice");
} catch (NotValidException e) {
assertTextPresentIgnoreCase("Cannot perform instruction: Cancel transition instance '" + transitionInstanceId + "'; Transition instance '" + transitionInstanceId + "' does not exist: transitionInstance is null", e.getMessage());
}
}
Aggregations