Search in sources :

Example 16 with DeploymentWithDefinitions

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));
}
Also used : ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.camunda.bpm.engine.runtime.Job) DeploymentWithDefinitions(org.camunda.bpm.engine.repository.DeploymentWithDefinitions) Test(org.junit.Test)

Example 17 with DeploymentWithDefinitions

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"));
    }
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) DeploymentWithDefinitions(org.camunda.bpm.engine.repository.DeploymentWithDefinitions) Test(org.junit.Test)

Example 18 with DeploymentWithDefinitions

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"));
}
Also used : ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.camunda.bpm.engine.runtime.Job) DeploymentWithDefinitions(org.camunda.bpm.engine.repository.DeploymentWithDefinitions) Test(org.junit.Test)

Example 19 with DeploymentWithDefinitions

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));
}
Also used : Task(org.camunda.bpm.engine.task.Task) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.camunda.bpm.engine.runtime.Job) DeploymentWithDefinitions(org.camunda.bpm.engine.repository.DeploymentWithDefinitions) Test(org.junit.Test)

Example 20 with DeploymentWithDefinitions

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));
}
Also used : ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.camunda.bpm.engine.runtime.Job) DeploymentWithDefinitions(org.camunda.bpm.engine.repository.DeploymentWithDefinitions) Test(org.junit.Test)

Aggregations

DeploymentWithDefinitions (org.camunda.bpm.engine.repository.DeploymentWithDefinitions)21 Test (org.junit.Test)17 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)15 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)15 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)12 Batch (org.camunda.bpm.engine.batch.Batch)9 Job (org.camunda.bpm.engine.runtime.Job)7 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)2 Task (org.camunda.bpm.engine.task.Task)2 URI (java.net.URI)1 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)1 NotValidException (org.camunda.bpm.engine.exception.NotValidException)1 ReadOnlyProcessDefinition (org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition)1 DeploymentWithDefinitionsDto (org.camunda.bpm.engine.rest.dto.repository.DeploymentWithDefinitionsDto)1 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)1