Search in sources :

Example 91 with Batch

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

the class ModificationExecutionAsyncTest method testIoMappingInvocation.

@Test
public void testIoMappingInvocation() {
    // given
    ProcessDefinition processDefinition = testRule.deployAndGetDefinition(modify(instance).activityBuilder("user1").camundaInputParameter("foo", "bar").done());
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
    Batch batch = runtimeService.createModification(processDefinition.getId()).startAfterActivity("user2").processInstanceIds(Arrays.asList(processInstance.getId())).executeAsync();
    helper.executeSeedJob(batch);
    // when
    helper.executeJobs(batch);
    // then
    VariableInstance inputVariable = runtimeService.createVariableInstanceQuery().singleResult();
    Assert.assertNotNull(inputVariable);
    assertEquals("foo", inputVariable.getName());
    assertEquals("bar", inputVariable.getValue());
    ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstance.getId());
    assertEquals(activityInstance.getActivityInstances("user1")[0].getId(), inputVariable.getActivityInstanceId());
}
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) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Test(org.junit.Test)

Example 92 with Batch

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

the class ModificationExecutionAsyncTest method createBatchModification.

@Test
public void createBatchModification() {
    ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
    List<String> processInstanceIds = helper.startInstances("process1", 2);
    Batch batch = runtimeService.createModification(processDefinition.getId()).startAfterActivity("user2").processInstanceIds(processInstanceIds).executeAsync();
    assertBatchCreated(batch, 2);
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 93 with Batch

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

the class ModificationExecutionAsyncTest method testBatchDeletionWithCascade.

@Test
public void testBatchDeletionWithCascade() {
    ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
    Batch batch = helper.startTransitionAsync("process1", 10, "seq", processDefinition.getId());
    helper.executeSeedJob(batch);
    // when
    rule.getManagementService().deleteBatch(batch.getId(), true);
    // then the batch was deleted
    assertEquals(0, rule.getManagementService().createBatchQuery().count());
    // and the seed and modification job definition were deleted
    assertEquals(0, rule.getManagementService().createJobDefinitionQuery().count());
    // and the seed job and modification jobs were deleted
    assertEquals(0, rule.getManagementService().createJobQuery().count());
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Example 94 with Batch

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

the class ModificationExecutionAsyncTest method testBatchWithFailedMonitorJobDeletionWithCascade.

@Test
public void testBatchWithFailedMonitorJobDeletionWithCascade() {
    ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
    Batch batch = helper.startBeforeAsync("process1", 2, "user2", processDefinition.getId());
    helper.executeSeedJob(batch);
    // create incident
    Job monitorJob = helper.getMonitorJob(batch);
    rule.getManagementService().setJobRetries(monitorJob.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)

Example 95 with Batch

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

the class ModificationExecutionAsyncTest method testCancelWithoutFlag.

@Test
public void testCancelWithoutFlag() {
    // given
    this.instance = Bpmn.createExecutableProcess("process1").startEvent("start").serviceTask("ser").camundaExpression("${true}").userTask("user").endEvent("end").done();
    ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
    List<String> processInstanceIds = helper.startInstances("process1", 1);
    // when
    Batch batch = runtimeService.createModification(processDefinition.getId()).startBeforeActivity("ser").cancelAllForActivity("user").processInstanceIds(processInstanceIds).executeAsync();
    helper.executeSeedJob(batch);
    helper.executeJobs(batch);
    // then
    assertEquals(0, runtimeService.createExecutionQuery().list().size());
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) 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