use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class UpdateProcessInstancesSuspendStateAsyncTest method testBatchSuspensionById.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/externaltask/twoExternalTaskProcess.bpmn20.xml" })
public void testBatchSuspensionById() {
// given
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
// when
Batch suspendprocess = runtimeService.updateProcessInstanceSuspensionState().byProcessInstanceIds(Arrays.asList(processInstance1.getId(), processInstance2.getId())).suspendAsync();
helper.executeSeedJob(suspendprocess);
helper.executeJobs(suspendprocess);
// then
ProcessInstance p1c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance1.getId()).singleResult();
assertTrue(p1c.isSuspended());
ProcessInstance p2c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance2.getId()).singleResult();
assertTrue(p2c.isSuspended());
}
use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class UpdateProcessInstancesSuspendStateAsyncTest method testBatchActivationByProcessInstanceQuery.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/externaltask/twoExternalTaskProcess.bpmn20.xml" })
public void testBatchActivationByProcessInstanceQuery() {
// given
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
// when
Batch suspendprocess = runtimeService.updateProcessInstanceSuspensionState().byProcessInstanceQuery(runtimeService.createProcessInstanceQuery().active()).suspendAsync();
helper.executeSeedJob(suspendprocess);
helper.executeJobs(suspendprocess);
Batch activateprocess = runtimeService.updateProcessInstanceSuspensionState().byProcessInstanceQuery(runtimeService.createProcessInstanceQuery().suspended()).activateAsync();
helper.executeSeedJob(activateprocess);
helper.executeJobs(activateprocess);
// then
ProcessInstance p1c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance1.getId()).singleResult();
assertFalse(p1c.isSuspended());
ProcessInstance p2c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance2.getId()).singleResult();
assertFalse(p2c.isSuspended());
}
use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class UpdateProcessInstancesSuspendStateAsyncTest method testBatchSuspensionByHistoricProcessInstanceQuery.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/externaltask/twoExternalTaskProcess.bpmn20.xml" })
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
public void testBatchSuspensionByHistoricProcessInstanceQuery() {
// given
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");
// when
Batch suspendprocess = runtimeService.updateProcessInstanceSuspensionState().byHistoricProcessInstanceQuery(historyService.createHistoricProcessInstanceQuery().processInstanceIds(Sets.newHashSet(processInstance1.getId(), processInstance2.getId()))).suspendAsync();
helper.executeSeedJob(suspendprocess);
helper.executeJobs(suspendprocess);
// then
ProcessInstance p1c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance1.getId()).singleResult();
assertTrue(p1c.isSuspended());
ProcessInstance p2c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance2.getId()).singleResult();
assertTrue(p2c.isSuspended());
}
use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceAsyncTest method restartProcessInstanceWithNotMatchingProcessDefinition.
@Test
public void restartProcessInstanceWithNotMatchingProcessDefinition() {
// given
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
runtimeService.deleteProcessInstance(processInstance.getId(), null);
BpmnModelInstance instance2 = Bpmn.createExecutableProcess().done();
ProcessDefinition processDefinition2 = testRule.deployAndGetDefinition(instance2);
// when
Batch batch = runtimeService.restartProcessInstances(processDefinition2.getId()).startBeforeActivity("userTask1").processInstanceIds(processInstance.getId()).executeAsync();
try {
helper.completeBatch(batch);
fail("exception expected");
} catch (ProcessEngineException e) {
// then
Assert.assertThat(e.getMessage(), containsString("Its process definition '" + processDefinition.getId() + "' does not match given process definition '" + processDefinition2.getId() + "'"));
}
}
use of org.camunda.bpm.engine.batch.Batch in project camunda-bpm-platform by camunda.
the class RestartProcessInstanceAsyncTest method restartProcessInstanceWithoutInstructions.
@Test
public void restartProcessInstanceWithoutInstructions() {
ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
try {
Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).processInstanceIds(processInstance.getId()).executeAsync();
helper.completeBatch(batch);
fail("exception expected");
} catch (BadUserRequestException e) {
Assert.assertThat(e.getMessage(), containsString("instructions is empty"));
}
}
Aggregations