215216217218219220221222223224225
public void testQueryByKey() { CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery(); // case one query .caseDefinitionKey("one"); verifyQueryResults(query, 2); // case two
221222223224225226227228229230231
.caseDefinitionKey("one"); verifyQueryResults(query, 2); // case two query .caseDefinitionKey("two"); verifyQueryResults(query, 1); }
230231232233234235236237238239240
} public void testQueryByInvalidKey() { CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery(); query .caseDefinitionKey("invalid"); verifyQueryResults(query, 0); try {
236237238239240241242243244245246
.caseDefinitionKey("invalid"); verifyQueryResults(query, 0); try { query.caseDefinitionKey(null); fail(); } catch (NotValidException e) {} } public void testQueryByKeyLike() {
356357358359360361362363364365366
query .latestVersion(); verifyQueryResults(query, 2); query .caseDefinitionKey("one") .latestVersion(); verifyQueryResults(query, 1);
362363364365366367368369370371372
.caseDefinitionKey("one") .latestVersion(); verifyQueryResults(query, 1); query .caseDefinitionKey("two").latestVersion(); verifyQueryResults(query, 1); } public void testInvalidUsageOfLatest() {
5051525354555657585960
ProcessEngine engine = getProcessEngine(); RepositoryService repositoryService = engine.getRepositoryService(); CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery(); query .caseDefinitionKey(caseDefinitionKey) .latestVersion(); CaseDefinition caseDefinition = query.singleResult();