Search in sources :

Example 11 with HistoricDecisionInstanceQuery

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

the class BatchHistoricDecisionInstanceDeletionTest method createBatchDeletionByInvalidQueryByKey.

@Test
public void createBatchDeletionByInvalidQueryByKey() {
    // given
    HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey("foo");
    // then
    thrown.expect(BadUserRequestException.class);
    // when
    historyService.deleteHistoricDecisionInstancesAsync(query, null);
}
Also used : HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery) Test(org.junit.Test)

Example 12 with HistoricDecisionInstanceQuery

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

the class BatchHistoricDecisionInstanceDeletionTest method createSeedJobByQuery.

@Test
public void createSeedJobByQuery() {
    // given
    HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);
    // when
    Batch batch = historyService.deleteHistoricDecisionInstancesAsync(decisionInstanceIds, query, null);
    // then there exists a seed job definition with the batch id as
    // configuration
    JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);
    assertNotNull(seedJobDefinition);
    assertEquals(batch.getId(), seedJobDefinition.getJobConfiguration());
    assertEquals(BatchSeedJobHandler.TYPE, seedJobDefinition.getJobType());
    // and there exists a deletion job definition
    JobDefinition deletionJobDefinition = helper.getExecutionJobDefinition(batch);
    assertNotNull(deletionJobDefinition);
    assertEquals(Batch.TYPE_HISTORIC_DECISION_INSTANCE_DELETION, deletionJobDefinition.getJobType());
    // and a seed job with no relation to a process or execution etc.
    Job seedJob = helper.getSeedJob(batch);
    assertNotNull(seedJob);
    assertEquals(seedJobDefinition.getId(), seedJob.getJobDefinitionId());
    assertNull(seedJob.getDuedate());
    assertNull(seedJob.getDeploymentId());
    assertNull(seedJob.getProcessDefinitionId());
    assertNull(seedJob.getProcessDefinitionKey());
    assertNull(seedJob.getProcessInstanceId());
    assertNull(seedJob.getExecutionId());
    // but no deletion jobs where created
    List<Job> deletionJobs = helper.getExecutionJobs(batch);
    assertEquals(0, deletionJobs.size());
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery) Job(org.camunda.bpm.engine.runtime.Job) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 13 with HistoricDecisionInstanceQuery

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

the class BatchHistoricDecisionInstanceDeletionTest method createMonitorJobByIdsAndQuery.

@Test
public void createMonitorJobByIdsAndQuery() {
    // given
    HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);
    Batch batch = historyService.deleteHistoricDecisionInstancesAsync(decisionInstanceIds, query, null);
    // when
    helper.executeSeedJob(batch);
    // then the seed job definition still exists but the seed job is removed
    JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);
    assertNotNull(seedJobDefinition);
    Job seedJob = helper.getSeedJob(batch);
    assertNull(seedJob);
    // and a monitor job definition and job exists
    JobDefinition monitorJobDefinition = helper.getMonitorJobDefinition(batch);
    assertNotNull(monitorJobDefinition);
    Job monitorJob = helper.getMonitorJob(batch);
    assertNotNull(monitorJob);
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery) Job(org.camunda.bpm.engine.runtime.Job) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 14 with HistoricDecisionInstanceQuery

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

the class BatchHistoricDecisionInstanceDeletionTest method createDeletionJobsByIdsAndQuery.

@Test
public void createDeletionJobsByIdsAndQuery() {
    // given
    rule.getProcessEngineConfiguration().setBatchJobsPerSeed(5);
    HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);
    Batch batch = historyService.deleteHistoricDecisionInstancesAsync(decisionInstanceIds, query, null);
    JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);
    JobDefinition deletionJobDefinition = helper.getExecutionJobDefinition(batch);
    ;
    // when
    helper.executeSeedJob(batch);
    // then
    List<Job> deletionJobs = helper.getJobsForDefinition(deletionJobDefinition);
    assertEquals(5, deletionJobs.size());
    for (Job deletionJob : deletionJobs) {
        assertEquals(deletionJobDefinition.getId(), deletionJob.getJobDefinitionId());
        assertNull(deletionJob.getDuedate());
        assertNull(deletionJob.getProcessDefinitionId());
        assertNull(deletionJob.getProcessDefinitionKey());
        assertNull(deletionJob.getProcessInstanceId());
        assertNull(deletionJob.getExecutionId());
    }
    // and the seed job still exists
    Job seedJob = helper.getJobForDefinition(seedJobDefinition);
    assertNotNull(seedJob);
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery) Job(org.camunda.bpm.engine.runtime.Job) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 15 with HistoricDecisionInstanceQuery

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

the class BatchHistoricDecisionInstanceDeletionTest method createDeletionJobsByQuery.

@Test
public void createDeletionJobsByQuery() {
    // given
    rule.getProcessEngineConfiguration().setBatchJobsPerSeed(5);
    HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);
    Batch batch = historyService.deleteHistoricDecisionInstancesAsync(query, null);
    JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);
    JobDefinition deletionJobDefinition = helper.getExecutionJobDefinition(batch);
    ;
    // when
    helper.executeSeedJob(batch);
    // then
    List<Job> deletionJobs = helper.getJobsForDefinition(deletionJobDefinition);
    assertEquals(5, deletionJobs.size());
    for (Job deletionJob : deletionJobs) {
        assertEquals(deletionJobDefinition.getId(), deletionJob.getJobDefinitionId());
        assertNull(deletionJob.getDuedate());
        assertNull(deletionJob.getProcessDefinitionId());
        assertNull(deletionJob.getProcessDefinitionKey());
        assertNull(deletionJob.getProcessInstanceId());
        assertNull(deletionJob.getExecutionId());
    }
    // and the seed job still exists
    Job seedJob = helper.getJobForDefinition(seedJobDefinition);
    assertNotNull(seedJob);
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery) Job(org.camunda.bpm.engine.runtime.Job) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Aggregations

HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)82 Deployment (org.camunda.bpm.engine.test.Deployment)37 NativeHistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.NativeHistoricDecisionInstanceQuery)36 Test (org.junit.Test)22 Batch (org.camunda.bpm.engine.batch.Batch)17 Job (org.camunda.bpm.engine.runtime.Job)9 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)7 HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)7 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)6 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)4 Response (com.jayway.restassured.response.Response)3 HashMap (java.util.HashMap)3 HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)3 Matchers.anyString (org.mockito.Matchers.anyString)3 Date (java.util.Date)2 List (java.util.List)2 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)2 UserOperationLogEntry (org.camunda.bpm.engine.history.UserOperationLogEntry)2 DecisionDefinition (org.camunda.bpm.engine.repository.DecisionDefinition)2 DecisionRequirementsDefinition (org.camunda.bpm.engine.repository.DecisionRequirementsDefinition)2