Search in sources :

Example 41 with HistoricBatch

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

the class BatchModificationHistoryTest method testHistoricBatchCompletion.

@Test
public void testHistoricBatchCompletion() {
    ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);
    Batch batch = helper.startAfterAsync("process1", 1, "user1", processDefinition.getId());
    helper.executeSeedJob(batch);
    helper.executeJobs(batch);
    Date endDate = helper.addSecondsToClock(12);
    // when
    helper.executeMonitorJob(batch);
    // then the historic batch has an end time set
    HistoricBatch historicBatch = helper.getHistoricBatch(batch);
    assertNotNull(historicBatch);
    assertEquals(endDate, historicBatch.getEndTime());
}
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) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Date(java.util.Date) Test(org.junit.Test)

Example 42 with HistoricBatch

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

the class BatchUpdateSuspensionStateAuthorizationTest 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 43 with HistoricBatch

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

the class BatchHelper method removeAllRunningAndHistoricBatches.

/**
 * Remove all batches and historic batches. Usually called in {@link org.junit.After} method.
 */
public void removeAllRunningAndHistoricBatches() {
    HistoryService historyService = getHistoryService();
    ManagementService managementService = getManagementService();
    for (Batch batch : managementService.createBatchQuery().list()) {
        managementService.deleteBatch(batch.getId(), true);
    }
    // remove history of completed batches
    for (HistoricBatch historicBatch : historyService.createHistoricBatchQuery().list()) {
        historyService.deleteHistoricBatch(historicBatch.getId());
    }
}
Also used : HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) ManagementService(org.camunda.bpm.engine.ManagementService) HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) HistoryService(org.camunda.bpm.engine.HistoryService)

Example 44 with HistoricBatch

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

the class BatchRestartAuthorizationTest 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 45 with HistoricBatch

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

the class CleanableHistoricBatchReportTest method testReportNoDefaultConfiguration.

@Test
public void testReportNoDefaultConfiguration() {
    Map<String, String> map = new HashMap<String, String>();
    int modOperationsTTL = 5;
    map.put("instance-modification", "P5D");
    int delOperationsTTL = 7;
    map.put("instance-deletion", "P7D");
    processEngineConfiguration.setBatchOperationsForHistoryCleanup(map);
    processEngineConfiguration.initHistoryCleanup();
    assertNull(processEngineConfiguration.getBatchOperationHistoryTimeToLive());
    Date startDate = new Date();
    int daysInThePast = -11;
    ClockUtil.setCurrentTime(DateUtils.addDays(startDate, daysInThePast));
    Batch modificationBatch = createModificationBatch();
    List<String> batchIds = new ArrayList<String>();
    batchIds.add(modificationBatch.getId());
    int migrationCountBatch = 10;
    List<String> batchIds1 = new ArrayList<String>();
    batchIds1.addAll(createMigrationBatchList(migrationCountBatch));
    int cancelationCountBatch = 20;
    List<String> batchIds2 = new ArrayList<String>();
    batchIds2.addAll(createCancelationBatchList(cancelationCountBatch));
    ClockUtil.setCurrentTime(DateUtils.addDays(startDate, -8));
    for (String batchId : batchIds) {
        managementService.deleteBatch(batchId, false);
    }
    ClockUtil.setCurrentTime(DateUtils.addDays(startDate, -2));
    for (int i = 0; i < 4; i++) {
        managementService.deleteBatch(batchIds1.get(i), false);
    }
    ClockUtil.setCurrentTime(DateUtils.addDays(startDate, -7));
    for (int i = 6; i < batchIds1.size(); i++) {
        managementService.deleteBatch(batchIds1.get(i), false);
    }
    ClockUtil.setCurrentTime(DateUtils.addDays(startDate, -10));
    for (int i = 0; i < 7; i++) {
        managementService.deleteBatch(batchIds2.get(i), false);
    }
    ClockUtil.setCurrentTime(DateUtils.addDays(startDate, -5));
    for (int i = 7; i < 11; i++) {
        managementService.deleteBatch(batchIds2.get(i), false);
    }
    ClockUtil.setCurrentTime(DateUtils.addDays(startDate, -1));
    for (int i = 13; i < batchIds2.size(); i++) {
        managementService.deleteBatch(batchIds2.get(i), false);
    }
    ClockUtil.setCurrentTime(DateUtils.addSeconds(startDate, 1));
    // when
    List<HistoricBatch> historicList = historyService.createHistoricBatchQuery().list();
    assertEquals(31, historicList.size());
    List<CleanableHistoricBatchReportResult> list = historyService.createCleanableHistoricBatchReport().list();
    assertEquals(3, list.size());
    for (CleanableHistoricBatchReportResult result : list) {
        if (result.getBatchType().equals("instance-migration")) {
            checkResultNumbers(result, 0, 8, null);
        } else if (result.getBatchType().equals("instance-modification")) {
            checkResultNumbers(result, 1, 1, modOperationsTTL);
        } else if (result.getBatchType().equals("instance-deletion")) {
            checkResultNumbers(result, delOperationsTTL, 18, delOperationsTTL);
        }
    }
}
Also used : HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) HashMap(java.util.HashMap) HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) CleanableHistoricBatchReportResult(org.camunda.bpm.engine.history.CleanableHistoricBatchReportResult) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

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