Search in sources :

Example 61 with Batch

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

the class BatchStatisticsQueryTest method testStatisticsRetriedFailedJobs.

@Test
public void testStatisticsRetriedFailedJobs() {
    // given
    Batch batch = helper.createMigrationBatchWithSize(3);
    // when
    helper.completeSeedJobs(batch);
    helper.failExecutionJobs(batch, 3);
    // then
    BatchStatistics batchStatistics = managementService.createBatchStatisticsQuery().singleResult();
    assertEquals(3, batchStatistics.getTotalJobs());
    assertEquals(3, batchStatistics.getJobsCreated());
    assertEquals(3, batchStatistics.getRemainingJobs());
    assertEquals(0, batchStatistics.getCompletedJobs());
    assertEquals(3, batchStatistics.getFailedJobs());
    // when
    helper.setRetries(batch, 3, 1);
    helper.completeJobs(batch, 3);
    // then
    batchStatistics = managementService.createBatchStatisticsQuery().singleResult();
    assertEquals(3, batchStatistics.getTotalJobs());
    assertEquals(3, batchStatistics.getJobsCreated());
    assertEquals(0, batchStatistics.getRemainingJobs());
    assertEquals(3, batchStatistics.getCompletedJobs());
    assertEquals(0, batchStatistics.getFailedJobs());
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) BatchStatistics(org.camunda.bpm.engine.batch.BatchStatistics) Test(org.junit.Test)

Example 62 with Batch

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

the class ManagementServiceAsyncOperationsTest method cleanBatch.

@After
public void cleanBatch() {
    Batch batch = managementService.createBatchQuery().singleResult();
    if (batch != null) {
        managementService.deleteBatch(batch.getId(), true);
    }
    HistoricBatch historicBatch = historyService.createHistoricBatchQuery().singleResult();
    if (historicBatch != null) {
        historyService.deleteHistoricBatch(historicBatch.getId());
    }
}
Also used : HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) After(org.junit.After)

Example 63 with Batch

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

the class ManagementServiceAsyncOperationsTest method testSetJobsRetryAsyncWithProcessQuery.

@Test
public void testSetJobsRetryAsyncWithProcessQuery() throws Exception {
    // given
    ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
    // when
    Batch batch = managementService.setJobRetriesAsync(null, query, RETRIES);
    executeSeedJob(batch);
    List<Exception> exceptions = executeBatchJobs(batch);
    // then
    assertThat(exceptions.size(), is(0));
    assertRetries(ids, RETRIES);
    assertHistoricBatchExists(testRule);
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) 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 64 with Batch

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

the class ManagementServiceAsyncOperationsTest method testSetJobsRetryAsyncWithJobQueryAndList.

@Test
public void testSetJobsRetryAsyncWithJobQueryAndList() throws Exception {
    // given
    List<String> extraPi = startTestProcesses(1);
    JobQuery query = managementService.createJobQuery().processInstanceId(extraPi.get(0));
    // when
    Batch batch = managementService.setJobRetriesAsync(ids, query, RETRIES);
    executeSeedJob(batch);
    List<Exception> exceptions = executeBatchJobs(batch);
    // then
    assertThat(exceptions.size(), is(0));
    assertRetries(getAllJobIds(), RETRIES);
    assertHistoricBatchExists(testRule);
}
Also used : HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) JobQuery(org.camunda.bpm.engine.runtime.JobQuery) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ExpectedException(org.junit.rules.ExpectedException) Test(org.junit.Test) AbstractAsyncOperationsTest(org.camunda.bpm.engine.test.api.AbstractAsyncOperationsTest)

Example 65 with Batch

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

the class ManagementServiceAsyncOperationsTest method testSetJobsRetryAsyncWithJobQuery.

@Test
public void testSetJobsRetryAsyncWithJobQuery() throws Exception {
    // given
    JobQuery query = managementService.createJobQuery();
    // when
    Batch batch = managementService.setJobRetriesAsync(query, RETRIES);
    executeSeedJob(batch);
    List<Exception> exceptions = executeBatchJobs(batch);
    // then
    assertThat(exceptions.size(), is(0));
    assertRetries(ids, RETRIES);
    assertHistoricBatchExists(testRule);
}
Also used : HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) JobQuery(org.camunda.bpm.engine.runtime.JobQuery) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ExpectedException(org.junit.rules.ExpectedException) Test(org.junit.Test) AbstractAsyncOperationsTest(org.camunda.bpm.engine.test.api.AbstractAsyncOperationsTest)

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