org.camunda.bpm.engine.history.HistoricCaseActivityInstance Java Examples

The following examples show how to use org.camunda.bpm.engine.history.HistoricCaseActivityInstance. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HistoricCaseActivityInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/history/HistoricCaseActivityInstanceTest.oneStageAndOneTaskCaseWithManualActivation.cmmn"})
public void testHistoricActivityInstanceWithinStageIsMarkedTerminatedOnComplete() {

  // given
  createCaseInstance();

  String stageExecutionId = queryCaseExecutionByActivityId("PI_Stage_1").getId();
  manualStart(stageExecutionId);
  String activeStageTaskExecutionId = queryCaseExecutionByActivityId("PI_HumanTask_Stage_2").getId();
  complete(activeStageTaskExecutionId);
  CaseExecution enabledStageTaskExecutionId = queryCaseExecutionByActivityId("PI_HumanTask_Stage_1");
  assertTrue(enabledStageTaskExecutionId.isEnabled());

  // when
  complete(stageExecutionId);

  // then the remaining stage task that was enabled is set to terminated in history
  HistoricCaseActivityInstance manualActivationTask =
      historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_Stage_1").singleResult();
  HistoricCaseActivityInstance completedTask =
      historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_Stage_2").singleResult();

  assertTrue(manualActivationTask.isTerminated());
  assertTrue(completedTask.isCompleted());
}
 
Example #2
Source File: HistoricCaseActivityInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/emptyStageWithManualActivationCase.cmmn"})
public void testHistoricCaseActivityInstanceProperties() {
  String activityId = "PI_Stage_1";

  createCaseInstance();
  CaseExecution stage = queryCaseExecutionByActivityId(activityId);
  HistoricCaseActivityInstance historicStage = queryHistoricActivityCaseInstance(activityId);

  assertEquals(stage.getId(), historicStage.getId());
  assertEquals(stage.getParentId(), historicStage.getParentCaseActivityInstanceId());
  assertEquals(stage.getCaseDefinitionId(), historicStage.getCaseDefinitionId());
  assertEquals(stage.getCaseInstanceId(), historicStage.getCaseInstanceId());
  assertEquals(stage.getActivityId(), historicStage.getCaseActivityId());
  assertEquals(stage.getActivityName(), historicStage.getCaseActivityName());
  assertEquals(stage.getActivityType(), historicStage.getCaseActivityType());

  manualStart(stage.getId());

  historicStage = queryHistoricActivityCaseInstance(activityId);
  assertNotNull(historicStage.getEndTime());
}
 
Example #3
Source File: AutoCompleteTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {
  "org/camunda/bpm/engine/test/cmmn/stage/AutoCompleteTest.testProcessTasksOnStage.cmmn",
  "org/camunda/bpm/engine/test/cmmn/stage/AutoCompleteTest.testProcessTasksOnStage.bpmn"
})
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testProcessTasksOnStage() {
  // given

  // when
  createCaseInstanceByKey(CASE_DEFINITION_KEY);

  List<HistoricCaseActivityInstance> historicCaseActivityInstances =
    historyService.createHistoricCaseActivityInstanceQuery()
    .caseActivityType("processTask")
    .list();

  // then
  assertThat(historicCaseActivityInstances.size(), is(2));
}
 
Example #4
Source File: BulkHistoryDeleteTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCleanupHistoryCaseActivityInstance() {
  // given
  // create case instance
  String caseInstanceId = caseService.createCaseInstanceByKey("oneTaskCase").getId();
  terminateAndCloseCaseInstance(caseInstanceId, null);

  // assume
  List<HistoricCaseActivityInstance> activityInstances = historyService.createHistoricCaseActivityInstanceQuery().list();
  assertEquals(1, activityInstances.size());

  // when
  historyService.deleteHistoricCaseInstancesBulk(Arrays.asList(caseInstanceId));

  // then
  activityInstances = historyService.createHistoricCaseActivityInstanceQuery().list();
  assertEquals(0, activityInstances.size());
}
 
Example #5
Source File: HistoricCaseActivityInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/stage/AutoCompleteTest.testCasePlanModel.cmmn"})
public void testAutoCompleteEnabled() {
  String caseInstanceId = createCaseInstanceByKey("case").getId();

  HistoricCaseInstance caseInstance = historyService
      .createHistoricCaseInstanceQuery()
      .caseInstanceId(caseInstanceId)
      .singleResult();
  assertNotNull(caseInstance);
  assertTrue(caseInstance.isCompleted());

  HistoricCaseActivityInstanceQuery query = historyService.createHistoricCaseActivityInstanceQuery();

  HistoricCaseActivityInstance humanTask1 = query.caseActivityId("PI_HumanTask_1").singleResult();
  assertNotNull(humanTask1);
  assertTrue(humanTask1.isTerminated());
  assertNotNull(humanTask1.getEndTime());
  assertNotNull(humanTask1.getDurationInMillis());


  HistoricCaseActivityInstance humanTask2 = query.caseActivityId("PI_HumanTask_2").singleResult();
  assertNotNull(humanTask2);
  assertTrue(humanTask2.isTerminated());
  assertNotNull(humanTask2.getEndTime());
  assertNotNull(humanTask2.getDurationInMillis());
}
 
Example #6
Source File: HistoricCaseActivityInstanceRestServiceImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public List<HistoricCaseActivityInstanceDto> queryHistoricCaseActivityInstances(HistoricCaseActivityInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) {
  HistoricCaseActivityInstanceQuery query = queryDto.toQuery(processEngine);

  List<HistoricCaseActivityInstance> matchingHistoricCaseActivityInstances;
  if (firstResult != null || maxResults != null) {
    matchingHistoricCaseActivityInstances = executePaginatedQuery(query, firstResult, maxResults);
  } else {
    matchingHistoricCaseActivityInstances = query.list();
  }

  List<HistoricCaseActivityInstanceDto> historicCaseActivityInstanceResults = new ArrayList<HistoricCaseActivityInstanceDto>();
  for (HistoricCaseActivityInstance historicCaseActivityInstance : matchingHistoricCaseActivityInstances) {
    HistoricCaseActivityInstanceDto resultHistoricCaseActivityInstance = HistoricCaseActivityInstanceDto.fromHistoricCaseActivityInstance(historicCaseActivityInstance);
    historicCaseActivityInstanceResults.add(resultHistoricCaseActivityInstance);
  }
  return historicCaseActivityInstanceResults;
}
 
Example #7
Source File: HistoricCaseActivityInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/history/HistoricCaseActivityInstanceTest.oneStageAndOneTaskCaseWithManualActivation.cmmn"})
public void testHistoricActivityInstancesAreMarkedTerminatedOnComplete() {

  // given
  createCaseInstance();

  CaseExecution humanTask = queryCaseExecutionByActivityId("PI_HumanTask_3");
  assertTrue(humanTask.isEnabled());
  CaseExecution stage = queryCaseExecutionByActivityId("PI_Stage_1");
  assertTrue(stage.isEnabled());

  // when
  CaseExecution casePlanExecution = queryCaseExecutionByActivityId("CasePlanModel_1");
  complete(casePlanExecution.getId());

  // then make sure all cases in the lower scope are marked as terminated in history
  HistoricCaseActivityInstance stageInstance =
      historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_Stage_1").singleResult();
  HistoricCaseActivityInstance taskInstance =
      historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_3").singleResult();

  assertTrue(stageInstance.isTerminated());
  assertTrue(taskInstance.isTerminated());
}
 
Example #8
Source File: HistoricCaseActivityInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/history/HistoricCaseActivityInstanceTest.oneStageAndOneTaskCaseWithManualActivation.cmmn"})
public void testDisabledHistoricActivityInstancesStayDisabledOnComplete() {

  // given
  createCaseInstance();

  CaseExecution humanTask = queryCaseExecutionByActivityId("PI_HumanTask_3");
  assertTrue(humanTask.isEnabled());
  CaseExecution stageExecution = queryCaseExecutionByActivityId("PI_Stage_1");
  disable(stageExecution.getId());
  stageExecution = queryCaseExecutionByActivityId("PI_Stage_1");
  assertTrue(stageExecution.isDisabled());

  // when
  CaseExecution casePlanExecution = queryCaseExecutionByActivityId("CasePlanModel_1");
  complete(casePlanExecution.getId());

  // then make sure disabled executions stay disabled
  HistoricCaseActivityInstance stageInstance =
      historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_Stage_1").singleResult();
  HistoricCaseActivityInstance taskInstance =
      historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_3").singleResult();

  assertTrue(stageInstance.isDisabled());
  assertTrue(taskInstance.isTerminated());
}
 
Example #9
Source File: HistoricCaseActivityInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testMilestoneHistoricActivityInstanceIsTerminatedOnComplete() {

  // given
  createCaseInstance();
  final String milestoneId = "PI_Milestone_1";
  CaseExecution caseMilestone = queryCaseExecutionByActivityId(milestoneId);
  assertTrue(caseMilestone.isAvailable());

  // when
  CaseExecution casePlanExecution = queryCaseExecutionByActivityId("CasePlanModel_1");
  complete(casePlanExecution.getId());

  // then make sure that the milestone is terminated
  HistoricCaseActivityInstance milestoneInstance =
      historyService.createHistoricCaseActivityInstanceQuery().caseActivityId(milestoneId).singleResult();

  assertTrue(milestoneInstance.isTerminated());
}
 
Example #10
Source File: HistoricCaseActivityInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/history/HistoricCaseActivityInstanceTest.oneStageWithSentryAsEntryPointCase.cmmn"})
public void testHistoricTaskWithSentryIsMarkedTerminatedOnComplete() {

  // given
  createCaseInstance();

  // when
  CaseExecution casePlanExecution = queryCaseExecutionByActivityId("PI_Stage_1");
  complete(casePlanExecution.getId());

  // then both tasks are terminated
  HistoricCaseActivityInstance taskInstance =
      historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_1").singleResult();

  HistoricCaseActivityInstance taskInstance2 =
      historyService.createHistoricCaseActivityInstanceQuery().caseActivityId("PI_HumanTask_2").singleResult();

  assertTrue(taskInstance.isTerminated());
  assertTrue(taskInstance2.isTerminated());
}
 
Example #11
Source File: HistoricCaseActivityInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn"})
public void testDeleteHistoricCaseActivityInstance() {
  CaseInstance caseInstance = createCaseInstance();

  HistoricCaseActivityInstance historicInstance = historicQuery().singleResult();
  assertNotNull(historicInstance);

  // disable human task to complete case
  disable(historicInstance.getId());
  // close case to be able to delete historic case instance
  close(caseInstance.getId());
  // delete historic case instance
  historyService.deleteHistoricCaseInstance(caseInstance.getId());

  assertCount(0, historicQuery());
}
 
Example #12
Source File: HistoricCaseActivityInstanceRestServiceQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testQueryWithoutTenantIdQueryParameter() {
  // given
  HistoricCaseActivityInstance caseInstance = MockProvider.createMockHistoricCaseActivityInstance(null);
  mockedQuery = setUpMockHistoricCaseActivityInstanceQuery(Collections.singletonList(caseInstance));

  // when
  Response response = given()
      .queryParam("withoutTenantId", true)
      .then().expect()
      .statusCode(Status.OK.getStatusCode())
      .when()
      .get(HISTORIC_CASE_ACTIVITY_INSTANCE_RESOURCE_URL);

  // then
  verify(mockedQuery).withoutTenantId();
  verify(mockedQuery).list();

  String content = response.asString();
  List<String> definitions = from(content).getList("");
  assertThat(definitions).hasSize(1);

  String returnedTenantId = from(content).getString("[0].tenantId");
  assertThat(returnedTenantId).isEqualTo(null);
}
 
Example #13
Source File: HistoricCaseActivityInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected HistoricCaseActivityInstance queryHistoricActivityCaseInstance(String activityId) {
  HistoricCaseActivityInstance historicActivityInstance = historicQuery()
    .caseActivityId(activityId)
    .singleResult();
  assertNotNull("No historic activity instance found for activity id: " + activityId, historicActivityInstance);
  return historicActivityInstance;
}
 
Example #14
Source File: HistoricCaseActivityInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = "org/camunda/bpm/engine/test/cmmn/required/RequiredRuleTest.testVariableBasedRule.cmmn")
public void testRequiredRuleEvaluatesToTrue() {
  caseService.createCaseInstanceByKey("case", Collections.<String, Object>singletonMap("required", true));

  HistoricCaseActivityInstance task = historyService
      .createHistoricCaseActivityInstanceQuery()
      .caseActivityId("PI_HumanTask_1")
      .singleResult();

  assertNotNull(task);
  assertTrue(task.isRequired());
}
 
Example #15
Source File: HistoricCaseActivityInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = "org/camunda/bpm/engine/test/cmmn/required/RequiredRuleTest.testVariableBasedRule.cmmn")
public void testRequiredRuleEvaluatesToFalse() {
  caseService.createCaseInstanceByKey("case", Collections.<String, Object>singletonMap("required", false));

  HistoricCaseActivityInstance task = historyService
      .createHistoricCaseActivityInstanceQuery()
      .caseActivityId("PI_HumanTask_1")
      .singleResult();

  assertNotNull(task);
  assertFalse(task.isRequired());
}
 
Example #16
Source File: HistoricCaseActivityInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = "org/camunda/bpm/engine/test/cmmn/required/RequiredRuleTest.testVariableBasedRule.cmmn")
public void testQueryByRequired() {
  caseService.createCaseInstanceByKey("case", Collections.<String, Object>singletonMap("required", true));

  HistoricCaseActivityInstanceQuery query = historyService
      .createHistoricCaseActivityInstanceQuery()
      .required();

  assertEquals(1, query.count());
  assertEquals(1, query.list().size());

  HistoricCaseActivityInstance activityInstance = query.singleResult();
  assertNotNull(activityInstance);
  assertTrue(activityInstance.isRequired());
}
 
Example #17
Source File: HistoricCaseActivityInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"})
public void testNativeQueryPaging() {
  createCaseInstance();
  createCaseInstance();
  createCaseInstance();
  createCaseInstance();

  String tableName = managementService.getTableName(HistoricCaseActivityInstance.class);
  assertEquals(3, historyService.createNativeHistoricCaseActivityInstanceQuery().sql("SELECT * FROM " + tableName).listPage(0, 3).size());
  assertEquals(2, historyService.createNativeHistoricCaseActivityInstanceQuery().sql("SELECT * FROM " + tableName).listPage(2, 2).size());
}
 
Example #18
Source File: HistoricCaseActivityInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment
public void testDecisionTask() {
  createCaseInstance();

  HistoricCaseActivityInstance decisionTask = historyService
      .createHistoricCaseActivityInstanceQuery()
      .caseActivityId("PI_DecisionTask_1")
      .singleResult();

  assertNotNull(decisionTask);
  assertEquals("decisionTask", decisionTask.getCaseActivityType());
}
 
Example #19
Source File: HistoricCaseActivityInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = {
  "org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCaseWithManualActivation.cmmn",
  "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn"
})
public void testHistoricCaseActivityCalledCaseInstanceId() {
  String taskId = "PI_CaseTask_1";

  String calledCaseId = "oneTaskCase";
  String calledTaskId = "PI_HumanTask_1";

  createCaseInstanceByKey("oneCaseTaskCase").getId();

  // as long as the case task is not activated there should be no other case instance
  assertCount(0, caseService.createCaseInstanceQuery().caseDefinitionKey(calledCaseId));

  HistoricCaseActivityInstance historicInstance = queryHistoricActivityCaseInstance(taskId);
  assertNull(historicInstance.getCalledCaseInstanceId());

  // start case task manually to create case instance
  CaseExecution caseTask = queryCaseExecutionByActivityId(taskId);
  manualStart(caseTask.getId());

  // there should exist a new case instance
  CaseInstance calledCaseInstance = caseService.createCaseInstanceQuery().caseDefinitionKey(calledCaseId).singleResult();
  assertNotNull(calledCaseInstance);

  // check that the called case instance id was correctly set
  historicInstance = queryHistoricActivityCaseInstance(taskId);
  assertEquals(calledCaseInstance.getId(), historicInstance.getCalledCaseInstanceId());

  // disable task to complete called case instance and close it
  CaseExecution calledTask = queryCaseExecutionByActivityId(calledTaskId);
  disable(calledTask.getId());
  close(calledCaseInstance.getId());

  // check that the called case instance id is still set
  assertCount(0, caseService.createCaseInstanceQuery().caseDefinitionKey(calledCaseId));
  historicInstance = queryHistoricActivityCaseInstance(taskId);
  assertEquals(calledCaseInstance.getId(), historicInstance.getCalledCaseInstanceId());
}
 
Example #20
Source File: HistoricCaseActivityInstanceResourceImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public HistoricCaseActivityInstanceDto getHistoricCaseActivityInstance() {
  HistoryService historyService = engine.getHistoryService();
  HistoricCaseActivityInstance instance = historyService.createHistoricCaseActivityInstanceQuery()
    .caseActivityInstanceId(caseActivityInstanceId).singleResult();

  if (instance == null) {
    throw new InvalidRequestException(Status.NOT_FOUND, "Historic case activity instance with id '" + caseActivityInstanceId + "' does not exist");
  }

  return HistoricCaseActivityInstanceDto.fromHistoricCaseActivityInstance(instance);
}
 
Example #21
Source File: HistoricCaseActivityInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources={
  "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCaseWithManualActivation.cmmn",
  "org/camunda/bpm/engine/test/history/HistoricCaseActivityInstanceTest.oneTaskProcess.bpmn20.xml"
})
public void testHistoricCalledProcessInstanceId() {
  String taskId = "PI_ProcessTask_1";

  createCaseInstanceByKey("oneProcessTaskCase").getId();

  // as long as the process task is not activated there should be no process instance
  assertCount(0, historyService.createHistoricProcessInstanceQuery());

  HistoricCaseActivityInstance historicInstance = queryHistoricActivityCaseInstance(taskId);
  assertNull(historicInstance.getCalledProcessInstanceId());

  // start process task manually to create case instance
  CaseExecution processTask = queryCaseExecutionByActivityId(taskId);
  manualStart(processTask.getId());

  // there should exist a new process instance
  HistoricProcessInstance calledProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
  assertNotNull(calledProcessInstance);
  assertNotNull(calledProcessInstance.getEndTime());

  // check that the called process instance id was correctly set
  historicInstance = queryHistoricActivityCaseInstance(taskId);
  assertEquals(calledProcessInstance.getId(), historicInstance.getCalledProcessInstanceId());
}
 
Example #22
Source File: HistoricCaseActivityInstanceDto.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static HistoricCaseActivityInstanceDto fromHistoricCaseActivityInstance(HistoricCaseActivityInstance historicCaseActivityInstance) {

    HistoricCaseActivityInstanceDto dto = new HistoricCaseActivityInstanceDto();

    dto.id = historicCaseActivityInstance.getId();
    dto.parentCaseActivityInstanceId = historicCaseActivityInstance.getParentCaseActivityInstanceId();
    dto.caseActivityId = historicCaseActivityInstance.getCaseActivityId();
    dto.caseActivityName = historicCaseActivityInstance.getCaseActivityName();
    dto.caseActivityType = historicCaseActivityInstance.getCaseActivityType();
    dto.caseDefinitionId = historicCaseActivityInstance.getCaseDefinitionId();
    dto.caseInstanceId = historicCaseActivityInstance.getCaseInstanceId();
    dto.caseExecutionId = historicCaseActivityInstance.getCaseExecutionId();
    dto.taskId = historicCaseActivityInstance.getTaskId();
    dto.calledProcessInstanceId = historicCaseActivityInstance.getCalledProcessInstanceId();
    dto.calledCaseInstanceId = historicCaseActivityInstance.getCalledCaseInstanceId();
    dto.tenantId = historicCaseActivityInstance.getTenantId();
    dto.createTime = historicCaseActivityInstance.getCreateTime();
    dto.endTime = historicCaseActivityInstance.getEndTime();
    dto.durationInMillis = historicCaseActivityInstance.getDurationInMillis();
    dto.required = historicCaseActivityInstance.isRequired();
    dto.available = historicCaseActivityInstance.isAvailable();
    dto.enabled = historicCaseActivityInstance.isEnabled();
    dto.disabled = historicCaseActivityInstance.isDisabled();
    dto.active = historicCaseActivityInstance.isActive();
    dto.completed = historicCaseActivityInstance.isCompleted();
    dto.terminated = historicCaseActivityInstance.isTerminated();

    return dto;
  }
 
Example #23
Source File: HistoricCaseActivityInstanceRestServiceImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private List<HistoricCaseActivityInstance> executePaginatedQuery(HistoricCaseActivityInstanceQuery query, Integer firstResult, Integer maxResults) {
  if (firstResult == null) {
    firstResult = 0;
  }
  if (maxResults == null) {
    maxResults = Integer.MAX_VALUE;
  }
  return query.listPage(firstResult, maxResults);
}
 
Example #24
Source File: HistoricCaseActivityInstanceRestServiceQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnfinishedHistoricCaseActivityQuery() {
  List<HistoricCaseActivityInstance> mockedHistoricCaseActivityInstances = MockProvider.createMockRunningHistoricCaseActivityInstances();
  HistoricCaseActivityInstanceQuery mockedHistoricCaseActivityInstanceQuery = mock(HistoricCaseActivityInstanceQuery.class);
  when(mockedHistoricCaseActivityInstanceQuery.list()).thenReturn(mockedHistoricCaseActivityInstances);
  when(processEngine.getHistoryService().createHistoricCaseActivityInstanceQuery()).thenReturn(mockedHistoricCaseActivityInstanceQuery);

  Response response = given()
      .queryParam("unfinished", true)
    .then().expect()
      .statusCode(Status.OK.getStatusCode())
    .when()
      .get(HISTORIC_CASE_ACTIVITY_INSTANCE_RESOURCE_URL);

  InOrder inOrder = inOrder(mockedHistoricCaseActivityInstanceQuery);
  inOrder.verify(mockedHistoricCaseActivityInstanceQuery).notEnded();
  inOrder.verify(mockedHistoricCaseActivityInstanceQuery).list();

  String content = response.asString();
  List<String> instances = from(content).getList("");
  Assert.assertEquals(1, instances.size());
  Assert.assertNotNull(instances.get(0));

  String returnedCaseDefinitionId = from(content).getString("[0].caseDefinitionId");
  String returnedActivityEndTime = from(content).getString("[0].endTime");

  Assert.assertEquals(MockProvider.EXAMPLE_CASE_DEFINITION_ID, returnedCaseDefinitionId);
  Assert.assertNull(returnedActivityEndTime);
}
 
Example #25
Source File: HistoricCaseActivityInstanceRestServiceQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected HistoricCaseActivityInstanceQuery setUpMockHistoricCaseActivityInstanceQuery(List<HistoricCaseActivityInstance> mockedHistoricCaseActivityInstances) {
  HistoricCaseActivityInstanceQuery mockedHistoricCaseActivityInstanceQuery = mock(HistoricCaseActivityInstanceQuery.class);
  when(mockedHistoricCaseActivityInstanceQuery.list()).thenReturn(mockedHistoricCaseActivityInstances);
  when(mockedHistoricCaseActivityInstanceQuery.count()).thenReturn((long) mockedHistoricCaseActivityInstances.size());

  when(processEngine.getHistoryService().createHistoricCaseActivityInstanceQuery()).thenReturn(mockedHistoricCaseActivityInstanceQuery);

  return mockedHistoricCaseActivityInstanceQuery;
}
 
Example #26
Source File: MockProvider.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static HistoricCaseActivityInstance createMockRunningHistoricCaseActivityInstance() {
  HistoricCaseActivityInstance mock = createMockHistoricCaseActivityInstance();

  when(mock.getEndTime()).thenReturn(null);
  when(mock.getDurationInMillis()).thenReturn(null);
  when(mock.isAvailable()).thenReturn(false);
  when(mock.isEnabled()).thenReturn(false);
  when(mock.isDisabled()).thenReturn(false);
  when(mock.isActive()).thenReturn(true);
  when(mock.isCompleted()).thenReturn(false);
  when(mock.isTerminated()).thenReturn(false);

  return mock;
}
 
Example #27
Source File: MultiTenancyHistoricCaseActivityInstanceQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldQuerySortingAsc() {
  // when
  List<HistoricCaseActivityInstance> historicCaseActivityInstances = historyService
      .createHistoricCaseActivityInstanceQuery()
      .orderByTenantId()
      .asc()
      .list();

  // then
  assertThat(historicCaseActivityInstances.size()).isEqualTo(3);
  verifySorting(historicCaseActivityInstances, historicCaseActivityInstanceByTenantId());
}
 
Example #28
Source File: MultiTenancyHistoricCaseActivityInstanceQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldQuerySortingDesc() {
  // when
  List<HistoricCaseActivityInstance> historicCaseActivityInstances = historyService.createHistoricCaseActivityInstanceQuery()
      .orderByTenantId()
      .desc()
      .list();

  // then
  assertThat(historicCaseActivityInstances.size()).isEqualTo(3);
  verifySorting(historicCaseActivityInstances, inverted(historicCaseActivityInstanceByTenantId()));
}
 
Example #29
Source File: MultiTenancyCaseInstanceCmdsTenantCheckTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void disableCaseExecutionDisabledTenantCheck() {
  identityService.setAuthentication("user", null, null);
  processEngineConfiguration.setTenantCheckEnabled(false);

  caseService.disableCaseExecution(caseExecutionId);

  identityService.clearAuthentication();

  HistoricCaseActivityInstance historicCaseActivityInstance = getHistoricCaseActivityInstance();

  assertThat(historicCaseActivityInstance, notNullValue());
  assertThat(historicCaseActivityInstance.isDisabled(), is(true));
}
 
Example #30
Source File: MockProvider.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static HistoricCaseActivityInstance createMockHistoricCaseActivityInstance(String tenantId) {
  HistoricCaseActivityInstance mock = mock(HistoricCaseActivityInstance.class);

  when(mock.getId()).thenReturn(EXAMPLE_HISTORIC_CASE_ACTIVITY_INSTANCE_ID);
  when(mock.getParentCaseActivityInstanceId()).thenReturn(EXAMPLE_HISTORIC_CASE_ACTIVITY_INSTANCE_PARENT_CASE_ACTIVITY_INSTANCE_ID);
  when(mock.getCaseActivityId()).thenReturn(EXAMPLE_HISTORIC_CASE_ACTIVITY_ID);
  when(mock.getCaseActivityName()).thenReturn(EXAMPLE_HISTORIC_CASE_ACTIVITY_NAME);
  when(mock.getCaseActivityType()).thenReturn(EXAMPLE_HISTORIC_CASE_ACTIVITY_TYPE);
  when(mock.getCaseDefinitionId()).thenReturn(EXAMPLE_CASE_DEFINITION_ID);
  when(mock.getCaseInstanceId()).thenReturn(EXAMPLE_CASE_INSTANCE_ID);
  when(mock.getCaseExecutionId()).thenReturn(EXAMPLE_CASE_EXECUTION_ID);
  when(mock.getTaskId()).thenReturn(EXAMPLE_TASK_ID);
  when(mock.getCalledProcessInstanceId()).thenReturn(EXAMPLE_HISTORIC_CASE_ACTIVITY_INSTANCE_CALLED_PROCESS_INSTANCE_ID);
  when(mock.getCalledCaseInstanceId()).thenReturn(EXAMPLE_HISTORIC_CASE_ACTIVITY_INSTANCE_CALLED_CASE_INSTANCE_ID);
  when(mock.getCreateTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_CASE_ACTIVITY_INSTANCE_CREATE_TIME));
  when(mock.getEndTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_CASE_ACTIVITY_INSTANCE_END_TIME));
  when(mock.getTenantId()).thenReturn(tenantId);
  when(mock.getDurationInMillis()).thenReturn(EXAMPLE_HISTORIC_CASE_ACTIVITY_INSTANCE_DURATION);
  when(mock.isRequired()).thenReturn(EXAMPLE_HISTORIC_CASE_ACTIVITY_INSTANCE_IS_REQUIRED);
  when(mock.isAvailable()).thenReturn(EXAMPLE_HISTORIC_CASE_ACTIVITY_INSTANCE_IS_AVAILABLE);
  when(mock.isEnabled()).thenReturn(EXAMPLE_HISTORIC_CASE_ACTIVITY_INSTANCE_IS_ENABLED);
  when(mock.isDisabled()).thenReturn(EXAMPLE_HISTORIC_CASE_ACTIVITY_INSTANCE_IS_DISABLED);
  when(mock.isActive()).thenReturn(EXAMPLE_HISTORIC_CASE_ACTIVITY_INSTANCE_IS_ACTIVE);
  when(mock.isCompleted()).thenReturn(EXAMPLE_HISTORIC_CASE_ACTIVITY_INSTANCE_IS_COMPLETED);
  when(mock.isTerminated()).thenReturn(EXAMPLE_HISTORIC_CASE_ACTIVITY_INSTANCE_IS_TERMINATED);

  return mock;
}