use of org.camunda.bpm.engine.history.HistoricCaseActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceRestServiceImpl method queryHistoricCaseActivityInstances.
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;
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstance in project camunda-bpm-platform by camunda.
the class MockProvider method createMockHistoricCaseActivityInstance.
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;
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstance in project camunda-bpm-platform by camunda.
the class MockProvider method createMockRunningHistoricCaseActivityInstance.
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;
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceRestServiceQueryTest method testUnfinishedHistoricCaseActivityQuery.
@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);
}
use of org.camunda.bpm.engine.history.HistoricCaseActivityInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseActivityInstanceTest method testHistoricCaseActivityInstanceProperties.
@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());
}
Aggregations