Search in sources :

Example 76 with HistoricProcessInstance

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

the class TestWarDeploymentWithProcessEnginePlugin method testPAGroovyProcessEnginePlugin.

@Test
public void testPAGroovyProcessEnginePlugin() {
    ProcessEngine groovyEngine = processEngineService.getProcessEngine("groovy");
    Assert.assertNotNull(groovyEngine);
    ProcessInstance pi = groovyEngine.getRuntimeService().startProcessInstanceByKey("groovy");
    HistoricProcessInstance hpi = groovyEngine.getHistoryService().createHistoricProcessInstanceQuery().processDefinitionKey("groovy").finished().singleResult();
    assertEquals(pi.getId(), hpi.getId());
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) Test(org.junit.Test) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)

Example 77 with HistoricProcessInstance

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

the class TestWarDeploymentWithProcessEnginePlugin method testPAGroovyAsyncProcessEnginePlugin.

@Test
public void testPAGroovyAsyncProcessEnginePlugin() {
    ProcessEngine groovyEngine = processEngineService.getProcessEngine("groovy");
    Assert.assertNotNull(groovyEngine);
    ProcessInstance pi = groovyEngine.getRuntimeService().startProcessInstanceByKey("groovyAsync");
    waitForJobExecutorToProcessAllJobs();
    HistoricProcessInstance hpi = groovyEngine.getHistoryService().createHistoricProcessInstanceQuery().processDefinitionKey("groovyAsync").finished().singleResult();
    assertEquals(pi.getId(), hpi.getId());
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) Test(org.junit.Test) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)

Example 78 with HistoricProcessInstance

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

the class CompleteProcessWithParallelGatewayTest method testQueryHistoricProcessWithParallelGateway.

@Test
@ScenarioUnderTest("init.complete.two.1")
public void testQueryHistoricProcessWithParallelGateway() {
    // given an already finished process instance with parallel gateway and two user tasks
    HistoricProcessInstance historicProcessInstance = rule.historicProcessInstance();
    // when query history
    HistoricTaskInstanceQuery historicTaskQuery = rule.getHistoryService().createHistoricTaskInstanceQuery().processInstanceId(historicProcessInstance.getId());
    // then two historic user tasks are returned
    Assert.assertEquals(2, historicTaskQuery.count());
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricTaskInstanceQuery(org.camunda.bpm.engine.history.HistoricTaskInstanceQuery) Test(org.junit.Test) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest) ScenarioUnderTest(org.camunda.bpm.qa.upgrade.ScenarioUnderTest)

Example 79 with HistoricProcessInstance

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

the class DeleteHistoricProcessInstancesCmd method execute.

@Override
public Void execute(CommandContext commandContext) {
    ensureNotEmpty(BadUserRequestException.class, "processInstanceIds", processInstanceIds);
    ensureNotContainsNull(BadUserRequestException.class, "processInstanceId is null", "processInstanceIds", processInstanceIds);
    // Check if process instance is still running
    List<HistoricProcessInstance> instances = commandContext.runWithoutAuthorization(new Callable<List<HistoricProcessInstance>>() {

        @Override
        public List<HistoricProcessInstance> call() throws Exception {
            return new HistoricProcessInstanceQueryImpl().processInstanceIds(new HashSet<String>(processInstanceIds)).list();
        }
    });
    if (processInstanceIds.size() == 1) {
        ensureNotEmpty(BadUserRequestException.class, "No historic process instance found with id: " + processInstanceIds.get(0), "historicProcessInstanceIds", instances);
    } else {
        ensureNotEmpty(BadUserRequestException.class, "No historic process instances found", "historicProcessInstanceIds", instances);
    }
    // check if all historicProcessInstances were found
    List<String> existingIds = new ArrayList<String>();
    for (HistoricProcessInstance historicProcessInstance : instances) {
        existingIds.add(historicProcessInstance.getId());
        for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
            checker.checkDeleteHistoricProcessInstance(historicProcessInstance);
        }
        ensureNotNull(BadUserRequestException.class, "Process instance is still running, cannot delete historic process instance: " + historicProcessInstance, "instance.getEndTime()", historicProcessInstance.getEndTime());
    }
    ArrayList<String> nonExistingIds = new ArrayList<String>(processInstanceIds);
    nonExistingIds.removeAll(existingIds);
    ensureNumberOfElements(BadUserRequestException.class, "No historic process instances found with ids " + nonExistingIds, "nonExistingIds", nonExistingIds, 0);
    commandContext.getHistoricProcessInstanceManager().deleteHistoricProcessInstanceByIds(processInstanceIds);
    return null;
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ArrayList(java.util.ArrayList) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) HistoricProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl) ArrayList(java.util.ArrayList) List(java.util.List)

Example 80 with HistoricProcessInstance

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

the class BulkHistoryDeleteCmmnDisabledTest method clearDatabase.

@After
public void clearDatabase() {
    engineRule.getProcessEngineConfiguration().getCommandExecutorTxRequired().execute(new Command<Void>() {

        public Void execute(CommandContext commandContext) {
            List<Job> jobs = engineRule.getManagementService().createJobQuery().list();
            if (jobs.size() > 0) {
                assertEquals(1, jobs.size());
                String jobId = jobs.get(0).getId();
                commandContext.getJobManager().deleteJob((JobEntity) jobs.get(0));
                commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(jobId);
            }
            commandContext.getMeterLogManager().deleteAll();
            return null;
        }
    });
    List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
    for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
        historyService.deleteHistoricProcessInstance(historicProcessInstance.getId());
    }
    List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().list();
    for (HistoricDecisionInstance historicDecisionInstance : historicDecisionInstances) {
        historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.getId());
    }
}
Also used : JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ArrayList(java.util.ArrayList) List(java.util.List) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) After(org.junit.After)

Aggregations

HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)113 Deployment (org.camunda.bpm.engine.test.Deployment)46 Test (org.junit.Test)37 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)36 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)25 Task (org.camunda.bpm.engine.task.Task)19 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)18 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)17 ArrayList (java.util.ArrayList)15 Calendar (java.util.Calendar)12 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)12 GregorianCalendar (java.util.GregorianCalendar)11 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)9 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)9 HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)7 List (java.util.List)5 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)5 Response (com.jayway.restassured.response.Response)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4