Search in sources :

Example 56 with HistoricProcessInstanceQuery

use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.

the class HistoryServiceAsyncOperationsTest method testDeleteHistoryProcessInstancesAsyncWithNonExistingIDAsQuery.

@Test
public void testDeleteHistoryProcessInstancesAsyncWithNonExistingIDAsQuery() throws Exception {
    // given
    ArrayList<String> processInstanceIds = new ArrayList<String>();
    processInstanceIds.add(historicProcessInstances.get(0));
    processInstanceIds.add("aFakeId");
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processInstanceIds(new HashSet(processInstanceIds));
    // when
    Batch batch = historyService.deleteHistoricProcessInstancesAsync(query, TEST_REASON);
    executeSeedJob(batch);
    executeBatchJobs(batch);
    // then
    assertHistoricBatchExists(testRule);
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Test(org.junit.Test) AbstractAsyncOperationsTest(org.camunda.bpm.engine.test.api.AbstractAsyncOperationsTest)

Example 57 with HistoricProcessInstanceQuery

use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.

the class HistoryServiceAsyncOperationsTest method testDeleteHistoryProcessInstancesAsyncWithQueryAndList.

@Test
public void testDeleteHistoryProcessInstancesAsyncWithQueryAndList() throws Exception {
    // given
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processInstanceId(historicProcessInstances.get(0));
    Batch batch = historyService.deleteHistoricProcessInstancesAsync(historicProcessInstances.subList(1, historicProcessInstances.size()), query, TEST_REASON);
    executeSeedJob(batch);
    // when
    List<Exception> exceptions = executeBatchJobs(batch);
    // then
    assertThat(exceptions.size(), is(0));
    assertNoHistoryForTasks();
    assertHistoricBatchExists(testRule);
    assertAllHistoricProcessInstancesAreDeleted();
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ExpectedException(org.junit.rules.ExpectedException) Test(org.junit.Test) AbstractAsyncOperationsTest(org.camunda.bpm.engine.test.api.AbstractAsyncOperationsTest)

Example 58 with HistoricProcessInstanceQuery

use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.

the class HistoryServiceAsyncOperationsTest method testDeleteHistoryProcessInstancesAsyncWithEmptyQuery.

@Test
public void testDeleteHistoryProcessInstancesAsyncWithEmptyQuery() throws Exception {
    // expect
    thrown.expect(ProcessEngineException.class);
    // given
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().unfinished();
    // when
    historyService.deleteHistoricProcessInstancesAsync(query, TEST_REASON);
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) Test(org.junit.Test) AbstractAsyncOperationsTest(org.camunda.bpm.engine.test.api.AbstractAsyncOperationsTest)

Example 59 with HistoricProcessInstanceQuery

use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.

the class RestartProcessInstanceAsyncTest method testBatchCreationWithOverlappingProcessInstanceIdsAndQuery.

@Test
public void testBatchCreationWithOverlappingProcessInstanceIdsAndQuery() {
    // given
    int processInstanceCount = 2;
    ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("Process");
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("Process");
    runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
    runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
    // when
    HistoricProcessInstanceQuery processInstanceQuery = engineRule.getHistoryService().createHistoricProcessInstanceQuery().processDefinitionId(processDefinition.getId());
    Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).startTransition("flow1").processInstanceIds(processInstance1.getId(), processInstance2.getId()).historicProcessInstanceQuery(processInstanceQuery).executeAsync();
    helper.completeBatch(batch);
    // then
    List<ProcessInstance> restartedProcessInstances = engineRule.getRuntimeService().createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).list();
    assertEquals(restartedProcessInstances.size(), processInstanceCount);
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) 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 60 with HistoricProcessInstanceQuery

use of org.camunda.bpm.engine.history.HistoricProcessInstanceQuery in project camunda-bpm-platform by camunda.

the class RestartProcessInstanceAsyncTest method shouldRestartProcessInstanceUsingHistoricProcessInstanceQuery.

@Test
public void shouldRestartProcessInstanceUsingHistoricProcessInstanceQuery() {
    // given
    ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("Process");
    Task task1 = taskService.createTaskQuery().processInstanceId(processInstance1.getId()).active().singleResult();
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("Process");
    Task task2 = taskService.createTaskQuery().processInstanceId(processInstance2.getId()).active().singleResult();
    runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
    runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
    // when
    HistoricProcessInstanceQuery historicProcessInstanceQuery = engineRule.getHistoryService().createHistoricProcessInstanceQuery().processDefinitionId(processDefinition.getId());
    Batch batch = runtimeService.restartProcessInstances(processDefinition.getId()).startBeforeActivity("userTask1").historicProcessInstanceQuery(historicProcessInstanceQuery).executeAsync();
    helper.completeBatch(batch);
    // then
    List<ProcessInstance> restartedProcessInstances = runtimeService.createProcessInstanceQuery().active().list();
    ProcessInstance restartedProcessInstance = restartedProcessInstances.get(0);
    Task restartedTask = taskService.createTaskQuery().processInstanceId(restartedProcessInstance.getId()).active().singleResult();
    Assert.assertEquals(task1.getTaskDefinitionKey(), restartedTask.getTaskDefinitionKey());
    restartedProcessInstance = restartedProcessInstances.get(1);
    restartedTask = taskService.createTaskQuery().processInstanceId(restartedProcessInstance.getId()).active().singleResult();
    Assert.assertEquals(task2.getTaskDefinitionKey(), restartedTask.getTaskDefinitionKey());
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) 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)

Aggregations

HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)71 Test (org.junit.Test)29 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)25 Batch (org.camunda.bpm.engine.batch.Batch)16 HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)14 HashMap (java.util.HashMap)12 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)11 Deployment (org.camunda.bpm.engine.test.Deployment)11 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)10 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)9 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 Matchers.anyString (org.mockito.Matchers.anyString)8 ArrayList (java.util.ArrayList)7 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)7 Response (com.jayway.restassured.response.Response)6 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)6 HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)6 ExternalTask (org.camunda.bpm.engine.externaltask.ExternalTask)4 HistoricProcessInstanceQueryImpl (org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl)4 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)4