Search in sources :

Example 31 with Batch

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());
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 32 with Batch

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());
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 33 with Batch

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());
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 34 with Batch

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() + "'"));
    }
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Example 35 with Batch

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"));
    }
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) 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