use of org.camunda.bpm.engine.repository.DeploymentWithDefinitions in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method executeModificationJobsForStartAfter.
@Test
public void executeModificationJobsForStartAfter() {
DeploymentWithDefinitions deployment = testRule.deploy(instance);
ProcessDefinition processDefinition = deployment.getDeployedProcessDefinitions().get(0);
Batch batch = helper.startAfterAsync("process1", 10, "user1", 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.repository.DeploymentWithDefinitions in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method createModificationWithNonExistingProcessDefinitionId.
@Test
public void createModificationWithNonExistingProcessDefinitionId() {
DeploymentWithDefinitions deployment = testRule.deploy(instance);
deployment.getDeployedProcessDefinitions().get(0);
List<String> processInstanceIds = helper.startInstances("process1", 2);
try {
runtimeService.createModification("foo").cancelAllForActivity("activityId").processInstanceIds(processInstanceIds).executeAsync();
fail("Should not succed");
} catch (ProcessEngineException e) {
assertThat(e.getMessage(), containsString("processDefinition is null"));
}
}
use of org.camunda.bpm.engine.repository.DeploymentWithDefinitions in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method testBatchExecutionFailureWithMissingProcessInstance.
@Test
public void testBatchExecutionFailureWithMissingProcessInstance() {
DeploymentWithDefinitions deployment = testRule.deploy(instance);
ProcessDefinition processDefinition = deployment.getDeployedProcessDefinitions().get(0);
Batch batch = helper.startAfterAsync("process1", 2, "user1", processDefinition.getId());
helper.executeSeedJob(batch);
List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().list();
String deletedProcessInstanceId = processInstances.get(0).getId();
// when
runtimeService.deleteProcessInstance(deletedProcessInstanceId, "test");
helper.executeJobs(batch);
// then the remaining process instance was modified
for (String processInstanceId : helper.currentProcessInstances) {
if (processInstanceId.equals(helper.currentProcessInstances.get(0))) {
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNull(updatedTree);
continue;
}
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processDefinition.getId()).activity("user1").activity("user2").done());
}
// and one batch job failed and has 2 retries left
List<Job> modificationJobs = helper.getExecutionJobs(batch);
assertEquals(1, modificationJobs.size());
Job failedJob = modificationJobs.get(0);
assertEquals(2, failedJob.getRetries());
assertThat(failedJob.getExceptionMessage(), startsWith("ENGINE-13036"));
assertThat(failedJob.getExceptionMessage(), containsString("Process instance '" + deletedProcessInstanceId + "' cannot be modified"));
}
use of org.camunda.bpm.engine.repository.DeploymentWithDefinitions in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method executeModificationJobsForProcessInstancesWithDifferentStates.
@Test
public void executeModificationJobsForProcessInstancesWithDifferentStates() {
DeploymentWithDefinitions deployment = testRule.deploy(instance);
ProcessDefinition processDefinition = deployment.getDeployedProcessDefinitions().get(0);
List<String> processInstanceIds = helper.startInstances("process1", 1);
Task task = rule.getTaskService().createTaskQuery().singleResult();
rule.getTaskService().complete(task.getId());
List<String> anotherProcessInstanceIds = helper.startInstances("process1", 1);
processInstanceIds.addAll(anotherProcessInstanceIds);
Batch batch = runtimeService.createModification(processDefinition.getId()).startBeforeActivity("user2").processInstanceIds(processInstanceIds).executeAsync();
helper.executeSeedJob(batch);
List<Job> modificationJobs = helper.getExecutionJobs(batch);
// when
for (Job modificationJob : modificationJobs) {
helper.executeJob(modificationJob);
}
// then all process instances where modified
ActivityInstance updatedTree = null;
String processInstanceId = processInstanceIds.get(0);
updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processDefinition.getId()).activity("user2").activity("user2").done());
processInstanceId = processInstanceIds.get(1);
updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
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.repository.DeploymentWithDefinitions in project camunda-bpm-platform by camunda.
the class ModificationExecutionAsyncTest method executeModificationJobsForStartAfterAndCancelAll.
@Test
public void executeModificationJobsForStartAfterAndCancelAll() {
DeploymentWithDefinitions deployment = testRule.deploy(instance);
ProcessDefinition processDefinition = deployment.getDeployedProcessDefinitions().get(0);
List<String> instances = helper.startInstances("process1", 10);
Batch batch = runtimeService.createModification(processDefinition.getId()).startAfterActivity("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);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processDefinition.getId()).activity("user2").done());
}
// and the no modification jobs exist
assertEquals(0, helper.getExecutionJobs(batch).size());
// but a monitor job exists
assertNotNull(helper.getMonitorJob(batch));
}
Aggregations