Search in sources :

Example 66 with HistoricProcessInstance

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

the class ActivityPerfTestWatcher method logActivityResults.

protected void logActivityResults(PerfTestPass pass, PerfTestRun run, HistoryService historyService) {
    String processInstanceId = run.getVariable(PerfTestConstants.PROCESS_INSTANCE_ID);
    List<ActivityPerfTestResult> activityResults = new ArrayList<ActivityPerfTestResult>();
    HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
    Date startTime = processInstance.getStartTime();
    List<HistoricActivityInstance> activityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).orderByHistoricActivityInstanceStartTime().asc().list();
    for (HistoricActivityInstance activityInstance : activityInstances) {
        if (watchAllActivities || activityIds.contains(activityInstance.getActivityId())) {
            ActivityPerfTestResult result = new ActivityPerfTestResult(activityInstance);
            if (activityInstance.getActivityType().equals("startEvent")) {
                result.setStartTime(startTime);
            }
            activityResults.add(result);
        }
    }
    pass.logActivityResult(processInstanceId, activityResults);
}
Also used : HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ArrayList(java.util.ArrayList) Date(java.util.Date) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance)

Example 67 with HistoricProcessInstance

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

the class HistoricJobLogAuthorizationTest method testQueryAfterDeletingDeployment.

// delete deployment (cascade = false)
public void testQueryAfterDeletingDeployment() {
    // given
    startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY);
    startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY);
    startProcessInstanceByKey(TIMER_BOUNDARY_PROCESS_KEY);
    createGrantAuthorization(PROCESS_DEFINITION, TIMER_BOUNDARY_PROCESS_KEY, userId, READ_HISTORY);
    disableAuthorization();
    List<Task> tasks = taskService.createTaskQuery().list();
    for (Task task : tasks) {
        taskService.complete(task.getId());
    }
    enableAuthorization();
    disableAuthorization();
    repositoryService.deleteDeployment(deploymentId);
    enableAuthorization();
    // when
    HistoricJobLogQuery query = historyService.createHistoricJobLogQuery();
    // then
    verifyQueryResults(query, 6);
    disableAuthorization();
    List<HistoricProcessInstance> instances = historyService.createHistoricProcessInstanceQuery().list();
    for (HistoricProcessInstance instance : instances) {
        historyService.deleteHistoricProcessInstance(instance.getId());
    }
    enableAuthorization();
}
Also used : HistoricJobLogQuery(org.camunda.bpm.engine.history.HistoricJobLogQuery) Task(org.camunda.bpm.engine.task.Task) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance)

Example 68 with HistoricProcessInstance

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

the class HistoricProcessInstanceAuthorizationTest method testSimpleQueryWithReadHistoryPermissionOnProcessDefinition.

public void testSimpleQueryWithReadHistoryPermissionOnProcessDefinition() {
    // given
    String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_HISTORY);
    // when
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
    // then
    verifyQueryResults(query, 1);
    HistoricProcessInstance instance = query.singleResult();
    assertNotNull(instance);
    assertEquals(processInstanceId, instance.getId());
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance)

Example 69 with HistoricProcessInstance

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

the class HistoricProcessInstanceAuthorizationTest method testSimpleQueryWithReadHistoryPermissionOnAnyProcessDefinition.

public void testSimpleQueryWithReadHistoryPermissionOnAnyProcessDefinition() {
    // given
    String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY);
    // when
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
    // then
    verifyQueryResults(query, 1);
    HistoricProcessInstance instance = query.singleResult();
    assertNotNull(instance);
    assertEquals(processInstanceId, instance.getId());
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance)

Example 70 with HistoricProcessInstance

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

the class HistoricProcessInstanceAuthorizationTest method testQueryAfterDeletingDeployment.

// delete deployment (cascade = false)
public void testQueryAfterDeletingDeployment() {
    // given
    startProcessInstanceByKey(PROCESS_KEY);
    startProcessInstanceByKey(PROCESS_KEY);
    startProcessInstanceByKey(PROCESS_KEY);
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_HISTORY);
    disableAuthorization();
    List<Task> tasks = taskService.createTaskQuery().list();
    for (Task task : tasks) {
        taskService.complete(task.getId());
    }
    enableAuthorization();
    disableAuthorization();
    repositoryService.deleteDeployment(deploymentId);
    enableAuthorization();
    // when
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery();
    // then
    verifyQueryResults(query, 3);
    disableAuthorization();
    List<HistoricProcessInstance> instances = historyService.createHistoricProcessInstanceQuery().list();
    for (HistoricProcessInstance instance : instances) {
        historyService.deleteHistoricProcessInstance(instance.getId());
    }
    enableAuthorization();
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance)

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