use of org.camunda.bpm.engine.history.HistoricCaseInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseInstanceTest method testCreateUser.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/emptyStageCase.cmmn" })
public void testCreateUser() {
String userId = "test";
identityService.setAuthenticatedUserId(userId);
String caseInstanceId = createCaseInstance().getId();
HistoricCaseInstance historicCaseInstance = queryHistoricCaseInstance(caseInstanceId);
assertEquals(userId, historicCaseInstance.getCreateUserId());
assertCount(1, historicQuery().createdBy(userId));
identityService.setAuthenticatedUserId(null);
}
use of org.camunda.bpm.engine.history.HistoricCaseInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseInstanceTest method testCaseInstanceStates.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/emptyStageWithManualActivationCase.cmmn" })
public void testCaseInstanceStates() {
String caseInstanceId = createCaseInstance().getId();
HistoricCaseInstance historicCaseInstance = queryHistoricCaseInstance(caseInstanceId);
assertTrue(historicCaseInstance.isActive());
assertCount(1, historicQuery().active());
assertCount(1, historicQuery().notClosed());
// start empty stage to complete case instance
String stageExecutionId = queryCaseExecutionByActivityId("PI_Stage_1").getId();
manualStart(stageExecutionId);
historicCaseInstance = queryHistoricCaseInstance(caseInstanceId);
assertTrue(historicCaseInstance.isCompleted());
assertCount(1, historicQuery().completed());
assertCount(1, historicQuery().notClosed());
// reactive and terminate case instance
reactivate(caseInstanceId);
terminate(caseInstanceId);
historicCaseInstance = queryHistoricCaseInstance(caseInstanceId);
assertTrue(historicCaseInstance.isTerminated());
assertCount(1, historicQuery().terminated());
assertCount(1, historicQuery().notClosed());
// reactive and suspend case instance
reactivate(caseInstanceId);
suspend(caseInstanceId);
historicCaseInstance = queryHistoricCaseInstance(caseInstanceId);
// not public API
assertTrue(((HistoricCaseInstanceEntity) historicCaseInstance).isSuspended());
// assertCount(1, historicQuery().suspended());
assertCount(1, historicQuery().notClosed());
// close case instance
close(caseInstanceId);
historicCaseInstance = queryHistoricCaseInstance(caseInstanceId);
assertTrue(historicCaseInstance.isClosed());
assertCount(1, historicQuery().closed());
assertCount(0, historicQuery().notClosed());
}
use of org.camunda.bpm.engine.history.HistoricCaseInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseInstanceTest method testHistoricCaseInstanceDates.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/emptyStageWithManualActivationCase.cmmn" })
public void testHistoricCaseInstanceDates() {
// create test dates
long duration = 72 * 3600 * 1000;
Date created = ClockUtil.getCurrentTime();
Date closed = new Date(created.getTime() + duration);
// create instance
ClockUtil.setCurrentTime(created);
String caseInstanceId = createCaseInstance().getId();
terminate(caseInstanceId);
// close instance
ClockUtil.setCurrentTime(closed);
close(caseInstanceId);
HistoricCaseInstance historicCaseInstance = queryHistoricCaseInstance(caseInstanceId);
// read historic dates ignoring milliseconds
Date createTime = historicCaseInstance.getCreateTime();
Date closeTime = historicCaseInstance.getCloseTime();
Long durationInMillis = historicCaseInstance.getDurationInMillis();
assertDateSimilar(created, createTime);
assertDateSimilar(closed, closeTime);
// test that duration is as expected with a maximal difference of one second
assertTrue(durationInMillis >= duration);
assertTrue(durationInMillis < duration + 1000);
// test queries
Date beforeCreate = new Date(created.getTime() - 3600 * 1000);
Date afterClose = new Date(closed.getTime() + 3600 * 1000);
assertCount(1, historicQuery().createdAfter(beforeCreate));
assertCount(0, historicQuery().createdAfter(closed));
assertCount(0, historicQuery().createdBefore(beforeCreate));
assertCount(1, historicQuery().createdBefore(closed));
assertCount(0, historicQuery().createdBefore(beforeCreate).createdAfter(closed));
assertCount(1, historicQuery().closedAfter(created));
assertCount(0, historicQuery().closedAfter(afterClose));
assertCount(0, historicQuery().closedBefore(created));
assertCount(1, historicQuery().closedBefore(afterClose));
assertCount(0, historicQuery().closedBefore(created).closedAfter(afterClose));
assertCount(1, historicQuery().closedBefore(afterClose).closedAfter(created));
}
use of org.camunda.bpm.engine.history.HistoricCaseInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseInstanceTest method testRetrieveCaseDefinitionName.
@Deployment(resources = "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn")
public void testRetrieveCaseDefinitionName() {
// given
String id = createCaseInstance("oneTaskCase").getId();
// when
HistoricCaseInstance caseInstance = historyService.createHistoricCaseInstanceQuery().caseInstanceId(id).singleResult();
// then
assertEquals("One Task Case", caseInstance.getCaseDefinitionName());
}
use of org.camunda.bpm.engine.history.HistoricCaseInstance in project camunda-bpm-platform by camunda.
the class HistoricCaseInstanceTest method queryHistoricCaseInstance.
protected HistoricCaseInstance queryHistoricCaseInstance(String caseInstanceId) {
HistoricCaseInstance historicCaseInstance = historicQuery().caseInstanceId(caseInstanceId).singleResult();
assertNotNull(historicCaseInstance);
return historicCaseInstance;
}
Aggregations