use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class CleanableHistoricCaseInstanceReportTest method testReportByInvalidCaseDefinitionKey.
@Test
public void testReportByInvalidCaseDefinitionKey() {
CleanableHistoricCaseInstanceReport report = historyService.createCleanableHistoricCaseInstanceReport();
try {
report.caseDefinitionKeyIn(null);
fail("Expected NotValidException");
} catch (NotValidException e) {
// expected
}
try {
report.caseDefinitionKeyIn("abc", null, "def");
fail("Expected NotValidException");
} catch (NotValidException e) {
// expected
}
}
use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class CleanableHistoricCaseInstanceReportTest method testReportByInvalidCaseDefinitionId.
@Test
public void testReportByInvalidCaseDefinitionId() {
CleanableHistoricCaseInstanceReport report = historyService.createCleanableHistoricCaseInstanceReport();
try {
report.caseDefinitionIdIn(null);
fail("Expected NotValidException");
} catch (NotValidException e) {
// expected
}
try {
report.caseDefinitionIdIn("abc", null, "def");
fail("Expected NotValidException");
} catch (NotValidException e) {
// expected
}
}
use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class CleanableHistoricProcessInstanceReportTest method testReportByInvalidProcessDefinitionId.
@Test
public void testReportByInvalidProcessDefinitionId() {
CleanableHistoricProcessInstanceReport report = historyService.createCleanableHistoricProcessInstanceReport();
try {
report.processDefinitionIdIn(null);
fail("Expected NotValidException");
} catch (NotValidException e) {
// expected
}
try {
report.processDefinitionIdIn("abc", null, "def");
fail("Expected NotValidException");
} catch (NotValidException e) {
// expected
}
}
use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class HistoricCaseInstanceTest method testHistoricCaseInstanceQuery.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn", "org/camunda/bpm/engine/test/api/repository/three_.cmmn" })
public void testHistoricCaseInstanceQuery() {
CaseInstance oneTaskCase = createCaseInstanceByKey("oneTaskCase", "oneBusiness");
CaseInstance twoTaskCase = createCaseInstanceByKey("twoTaskCase", "twoBusiness");
createCaseInstanceByKey("xyz_", "xyz_");
assertCount(1, historicQuery().caseInstanceId(oneTaskCase.getId()));
assertCount(1, historicQuery().caseInstanceId(twoTaskCase.getId()));
Set<String> caseInstanceIds = new HashSet<String>();
caseInstanceIds.add(oneTaskCase.getId());
caseInstanceIds.add("unknown1");
caseInstanceIds.add(twoTaskCase.getId());
caseInstanceIds.add("unknown2");
assertCount(2, historicQuery().caseInstanceIds(caseInstanceIds));
assertCount(0, historicQuery().caseInstanceIds(caseInstanceIds).caseInstanceId("someOtherId"));
assertCount(1, historicQuery().caseDefinitionId(oneTaskCase.getCaseDefinitionId()));
assertCount(1, historicQuery().caseDefinitionKey("oneTaskCase"));
assertCount(3, historicQuery().caseDefinitionKeyNotIn(Arrays.asList("unknown")));
assertCount(2, historicQuery().caseDefinitionKeyNotIn(Arrays.asList("oneTaskCase")));
assertCount(1, historicQuery().caseDefinitionKeyNotIn(Arrays.asList("oneTaskCase", "twoTaskCase")));
assertCount(0, historicQuery().caseDefinitionKeyNotIn(Arrays.asList("oneTaskCase")).caseDefinitionKey("oneTaskCase"));
try {
// oracle handles empty string like null which seems to lead to undefined behavior of the LIKE comparison
historicQuery().caseDefinitionKeyNotIn(Arrays.asList(""));
fail("Exception expected");
} catch (NotValidException e) {
// expected
}
assertCount(1, historicQuery().caseDefinitionName("One Task Case"));
assertCount(2, historicQuery().caseDefinitionNameLike("%T%"));
assertCount(1, historicQuery().caseDefinitionNameLike("One%"));
assertCount(0, historicQuery().caseDefinitionNameLike("%Process%"));
assertCount(1, historicQuery().caseDefinitionNameLike("%z\\_"));
assertCount(1, historicQuery().caseInstanceBusinessKey("oneBusiness"));
assertCount(2, historicQuery().caseInstanceBusinessKeyLike("%Business"));
assertCount(1, historicQuery().caseInstanceBusinessKeyLike("one%"));
assertCount(0, historicQuery().caseInstanceBusinessKeyLike("%unknown%"));
assertCount(1, historicQuery().caseInstanceBusinessKeyLike("%z\\_"));
}
use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testHistoricProcessInstanceQuery.
@Deployment(resources = { "org/camunda/bpm/engine/test/history/oneAsyncTaskProcess.bpmn20.xml" })
public void testHistoricProcessInstanceQuery() {
Calendar startTime = Calendar.getInstance();
ClockUtil.setCurrentTime(startTime.getTime());
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", "businessKey_123");
Job job = managementService.createJobQuery().singleResult();
managementService.executeJob(job.getId());
Calendar hourAgo = Calendar.getInstance();
hourAgo.add(Calendar.HOUR_OF_DAY, -1);
Calendar hourFromNow = Calendar.getInstance();
hourFromNow.add(Calendar.HOUR_OF_DAY, 1);
// Start/end dates
assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishedBefore(hourAgo.getTime()).count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishedBefore(hourFromNow.getTime()).count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishedAfter(hourAgo.getTime()).count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishedAfter(hourFromNow.getTime()).count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().startedBefore(hourFromNow.getTime()).count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().startedBefore(hourAgo.getTime()).count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().startedAfter(hourAgo.getTime()).count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().startedAfter(hourFromNow.getTime()).count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().startedAfter(hourFromNow.getTime()).startedBefore(hourAgo.getTime()).count());
// General fields
assertEquals(0, historyService.createHistoricProcessInstanceQuery().finished().count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId()).count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKey("businessKey_123").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKeyLike("business%").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKeyLike("%sinessKey\\_123").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKeyLike("%siness%").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionName("The One Task_Process").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionNameLike("The One Task%").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionNameLike("%One Task\\_Process").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionNameLike("%One Task%").count());
List<String> exludeIds = new ArrayList<String>();
exludeIds.add("unexistingProcessDefinition");
assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionKeyNotIn(exludeIds).count());
exludeIds.add("oneTaskProcess");
assertEquals(0, historyService.createHistoricProcessInstanceQuery().processDefinitionKey("oneTaskProcess").processDefinitionKeyNotIn(exludeIds).count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().processDefinitionKeyNotIn(exludeIds).count());
try {
// oracle handles empty string like null which seems to lead to undefined behavior of the LIKE comparison
historyService.createHistoricProcessInstanceQuery().processDefinitionKeyNotIn(Arrays.asList(""));
fail("Exception expected");
} catch (NotValidException e) {
// expected
}
// After finishing process
taskService.complete(taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult().getId());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().finished().count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishedBefore(hourAgo.getTime()).count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().finishedBefore(hourFromNow.getTime()).count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().finishedAfter(hourAgo.getTime()).count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishedAfter(hourFromNow.getTime()).count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().finishedAfter(hourFromNow.getTime()).finishedBefore(hourAgo.getTime()).count());
// No incidents should are created
assertEquals(0, historyService.createHistoricProcessInstanceQuery().withIncidents().count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().incidentMessageLike("Unknown property used%").count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().incidentMessage("Unknown property used in expression: #{failing}. Cause: Cannot resolve identifier 'failing'").count());
// execute activities
assertEquals(1, historyService.createHistoricProcessInstanceQuery().executedActivityAfter(hourAgo.getTime()).count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourAgo.getTime()).count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourFromNow.getTime()).count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().executedActivityAfter(hourFromNow.getTime()).count());
// execute jobs
if (processEngineConfiguration.getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_FULL)) {
assertEquals(1, historyService.createHistoricProcessInstanceQuery().executedJobAfter(hourAgo.getTime()).count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourAgo.getTime()).count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().executedActivityBefore(hourFromNow.getTime()).count());
assertEquals(0, historyService.createHistoricProcessInstanceQuery().executedActivityAfter(hourFromNow.getTime()).count());
}
}
Aggregations