Search in sources :

Example 6 with HistoricBatch

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

the class RuntimeServiceAsyncOperationsTest method cleanBatch.

@After
public void cleanBatch() {
    List<Batch> batches = managementService.createBatchQuery().list();
    if (batches.size() > 0) {
        for (Batch batch : batches) 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 7 with HistoricBatch

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

the class BatchCreationAuthorizationTest method cleanBatch.

@After
public void cleanBatch() {
    Batch batch = engineRule.getManagementService().createBatchQuery().singleResult();
    if (batch != null) {
        engineRule.getManagementService().deleteBatch(batch.getId(), true);
    }
    HistoricBatch historicBatch = engineRule.getHistoryService().createHistoricBatchQuery().singleResult();
    if (historicBatch != null) {
        engineRule.getHistoryService().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 8 with HistoricBatch

use of org.camunda.bpm.engine.batch.history.HistoricBatch 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 9 with HistoricBatch

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

the class HistoryCleanupHistoricBatchTest method testBatchOperationTypeConfigurationOnly.

@Test
public void testBatchOperationTypeConfigurationOnly() {
    Map<String, String> map = new HashMap<String, String>();
    map.put("instance-migration", "P2D");
    map.put("instance-deletion", DEFAULT_TTL_DAYS);
    processEngineConfiguration.setBatchOperationHistoryTimeToLive(null);
    processEngineConfiguration.setBatchOperationsForHistoryCleanup(map);
    processEngineConfiguration.initHistoryCleanup();
    assertNull(processEngineConfiguration.getBatchOperationHistoryTimeToLive());
    Date startDate = ClockUtil.getCurrentTime();
    int daysInThePast = -11;
    ClockUtil.setCurrentTime(DateUtils.addDays(startDate, daysInThePast));
    List<String> batchIds = new ArrayList<String>();
    int migrationCountBatch = 10;
    batchIds.addAll(createMigrationBatchList(migrationCountBatch));
    int cancelationCountBatch = 20;
    batchIds.addAll(createCancelationBatchList(cancelationCountBatch));
    ClockUtil.setCurrentTime(DateUtils.addDays(startDate, -7));
    for (String batchId : batchIds) {
        managementService.deleteBatch(batchId, false);
    }
    ClockUtil.setCurrentTime(new Date());
    // when
    List<HistoricBatch> historicList = historyService.createHistoricBatchQuery().list();
    assertEquals(30, historicList.size());
    String jobId = historyService.cleanUpHistoryAsync(true).getId();
    managementService.executeJob(jobId);
    // then
    assertEquals(0, historyService.createHistoricBatchQuery().count());
    for (String batchId : batchIds) {
        assertEquals(0, historyService.createHistoricJobLogQuery().jobDefinitionConfiguration(batchId).count());
    }
}
Also used : HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

Example 10 with HistoricBatch

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

the class MultiTenancyBatchTest method testHistoricBatchTenantId.

@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testHistoricBatchTenantId() {
    // given
    batchHelper.migrateProcessInstanceAsync(tenant1Definition, tenant1Definition);
    // then
    HistoricBatch historicBatch = historyService.createHistoricBatchQuery().singleResult();
    Assert.assertEquals(TENANT_ONE, historicBatch.getTenantId());
}
Also used : HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Test(org.junit.Test) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Aggregations

HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)45 Batch (org.camunda.bpm.engine.batch.Batch)34 Test (org.junit.Test)26 Date (java.util.Date)13 After (org.junit.After)12 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)4 HistoryService (org.camunda.bpm.engine.HistoryService)4 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)4 ManagementService (org.camunda.bpm.engine.ManagementService)3 CleanableHistoricBatchReportResult (org.camunda.bpm.engine.history.CleanableHistoricBatchReportResult)3 HistoricBatchQuery (org.camunda.bpm.engine.batch.history.HistoricBatchQuery)2 HashSet (java.util.HashSet)1 List (java.util.List)1 HashedMap (org.apache.commons.collections.map.HashedMap)1 BatchEntity (org.camunda.bpm.engine.impl.batch.BatchEntity)1 HistoricBatchEntity (org.camunda.bpm.engine.impl.batch.history.HistoricBatchEntity)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1 HistoricBatchManager (org.camunda.bpm.engine.impl.persistence.entity.HistoricBatchManager)1 HistoricBatchDto (org.camunda.bpm.engine.rest.dto.history.batch.HistoricBatchDto)1