Search in sources :

Example 96 with Batch

use of org.camunda.bpm.engine.batch.Batch 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));
}
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 97 with Batch

use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.

the class ModificationExecutionAsyncTest method testMonitorJobPollingForCompletion.

@Test
public void testMonitorJobPollingForCompletion() {
    ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
    Batch batch = helper.startAfterAsync("process1", 3, "user1", processDefinition.getId());
    // when the seed job creates the monitor job
    Date createDate = ClockTestUtil.setClockToDateWithoutMilliseconds();
    helper.executeSeedJob(batch);
    // then the monitor job has a no due date set
    Job monitorJob = helper.getMonitorJob(batch);
    assertNotNull(monitorJob);
    assertNull(monitorJob.getDuedate());
    // when the monitor job is executed
    helper.executeMonitorJob(batch);
    // then the monitor job has a due date of the default batch poll time
    monitorJob = helper.getMonitorJob(batch);
    Date dueDate = helper.addSeconds(createDate, 30);
    assertEquals(dueDate, monitorJob.getDuedate());
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Job(org.camunda.bpm.engine.runtime.Job) Date(java.util.Date) Test(org.junit.Test)

Example 98 with Batch

use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.

the class ModificationExecutionAsyncTest method testSkipListenerInvocationF.

@Test
public void testSkipListenerInvocationF() {
    // given
    DelegateEvent.clearEvents();
    ProcessDefinition processDefinition = testRule.deployAndGetDefinition(modify(instance).activityBuilder("user2").camundaExecutionListenerClass(ExecutionListener.EVENTNAME_START, DelegateExecutionListener.class.getName()).done());
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
    Batch batch = runtimeService.createModification(processDefinition.getId()).cancelAllForActivity("user2").processInstanceIds(Arrays.asList(processInstance.getId())).skipCustomListeners().executeAsync();
    helper.executeSeedJob(batch);
    // when
    helper.executeJobs(batch);
    // then
    assertEquals(0, DelegateEvent.getEvents().size());
}
Also used : DelegateExecutionListener(org.camunda.bpm.engine.test.bpmn.multiinstance.DelegateExecutionListener) Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 99 with Batch

use of org.camunda.bpm.engine.batch.Batch 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));
}
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) Test(org.junit.Test)

Example 100 with Batch

use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.

the class ModificationExecutionAsyncTest method testBatchWithFailedSeedJobDeletionWithCascade.

@Test
public void testBatchWithFailedSeedJobDeletionWithCascade() {
    ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
    Batch batch = helper.cancelAllAsync("process1", 2, "user1", processDefinition.getId());
    // create incident
    Job seedJob = helper.getSeedJob(batch);
    rule.getManagementService().setJobRetries(seedJob.getId(), 0);
    // when
    rule.getManagementService().deleteBatch(batch.getId(), true);
    // then the no historic incidents exists
    long historicIncidents = rule.getHistoryService().createHistoricIncidentQuery().count();
    assertEquals(0, historicIncidents);
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test)

Aggregations

Batch (org.camunda.bpm.engine.batch.Batch)324 Test (org.junit.Test)286 HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)125 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)95 Job (org.camunda.bpm.engine.runtime.Job)78 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)64 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)32 Date (java.util.Date)28 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)28 AbstractAsyncOperationsTest (org.camunda.bpm.engine.test.api.AbstractAsyncOperationsTest)26 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)24 ArrayList (java.util.ArrayList)23 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)19 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)18 HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)17 ExternalTask (org.camunda.bpm.engine.externaltask.ExternalTask)16 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)15 Deployment (org.camunda.bpm.engine.test.Deployment)15 ExpectedException (org.junit.rules.ExpectedException)14 Matchers.anyString (org.mockito.Matchers.anyString)14