use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class RepositoryServiceTest method testUpdateHistoryTimeToLiveInCache.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testUpdateHistoryTimeToLiveInCache() {
// given
// there exists a deployment containing a case definition with key "oneTaskCase"
CaseDefinition caseDefinition = findOnlyCaseDefinition();
// assume
assertNull(caseDefinition.getHistoryTimeToLive());
// when
repositoryService.updateCaseDefinitionHistoryTimeToLive(caseDefinition.getId(), 10);
CaseDefinition definition = repositoryService.getCaseDefinition(caseDefinition.getId());
assertEquals(Integer.valueOf(10), definition.getHistoryTimeToLive());
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class RepositoryServiceTest method testUpdateHistoryTimeToLiveNull.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testUpdateHistoryTimeToLiveNull() {
// given
// there exists a deployment containing a case definition with key "oneTaskCase"
CaseDefinition caseDefinition = findOnlyCaseDefinition();
// when
repositoryService.updateCaseDefinitionHistoryTimeToLive(caseDefinition.getId(), null);
// then
caseDefinition = findOnlyCaseDefinition();
assertEquals(null, caseDefinition.getHistoryTimeToLive());
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class RepositoryServiceTest method testUpdateHistoryTimeToLive.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testUpdateHistoryTimeToLive() {
// given
// there exists a deployment containing a case definition with key "oneTaskCase"
CaseDefinition caseDefinition = findOnlyCaseDefinition();
// when
repositoryService.updateCaseDefinitionHistoryTimeToLive(caseDefinition.getId(), 6);
// then
caseDefinition = findOnlyCaseDefinition();
assertEquals(6, caseDefinition.getHistoryTimeToLive().intValue());
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class CaseDefinitionQueryTest method testQueryByCaseDefinitionIds.
public void testQueryByCaseDefinitionIds() {
// empty list
assertTrue(repositoryService.createCaseDefinitionQuery().caseDefinitionIdIn("a", "b").list().isEmpty());
// collect all ids
List<CaseDefinition> caseDefinitions = repositoryService.createCaseDefinitionQuery().list();
// no point of the test if the caseDefinitions is empty
assertFalse(caseDefinitions.isEmpty());
List<String> ids = new ArrayList<String>();
for (CaseDefinition caseDefinition : caseDefinitions) {
ids.add(caseDefinition.getId());
}
caseDefinitions = repositoryService.createCaseDefinitionQuery().caseDefinitionIdIn(ids.toArray(new String[ids.size()])).list();
assertEquals(ids.size(), caseDefinitions.size());
for (CaseDefinition caseDefinition : caseDefinitions) {
if (!ids.contains(caseDefinition.getId())) {
fail("Expected to find case definition " + caseDefinition);
}
}
assertEquals(0, repositoryService.createCaseDefinitionQuery().caseDefinitionIdIn(ids.toArray(new String[ids.size()])).caseDefinitionId("nonExistent").count());
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class CaseDefinitionQueryTest method testQuerySorting.
public void testQuerySorting() {
CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery();
// asc
query.orderByCaseDefinitionId().asc();
verifyQueryResults(query, 4);
query = repositoryService.createCaseDefinitionQuery();
query.orderByDeploymentId().asc();
verifyQueryResults(query, 4);
query = repositoryService.createCaseDefinitionQuery();
query.orderByCaseDefinitionKey().asc();
verifyQueryResults(query, 4);
query = repositoryService.createCaseDefinitionQuery();
query.orderByCaseDefinitionVersion().asc();
verifyQueryResults(query, 4);
// desc
query = repositoryService.createCaseDefinitionQuery();
query.orderByCaseDefinitionId().desc();
verifyQueryResults(query, 4);
query = repositoryService.createCaseDefinitionQuery();
query.orderByDeploymentId().desc();
verifyQueryResults(query, 4);
query = repositoryService.createCaseDefinitionQuery();
query.orderByCaseDefinitionKey().desc();
verifyQueryResults(query, 4);
query = repositoryService.createCaseDefinitionQuery();
query.orderByCaseDefinitionVersion().desc();
verifyQueryResults(query, 4);
query = repositoryService.createCaseDefinitionQuery();
// Typical use case
query.orderByCaseDefinitionKey().asc().orderByCaseDefinitionVersion().desc();
List<CaseDefinition> caseDefinitions = query.list();
assertEquals(4, caseDefinitions.size());
assertEquals("one", caseDefinitions.get(0).getKey());
assertEquals(2, caseDefinitions.get(0).getVersion());
assertEquals("one", caseDefinitions.get(1).getKey());
assertEquals(1, caseDefinitions.get(1).getVersion());
assertEquals("two", caseDefinitions.get(2).getKey());
assertEquals(1, caseDefinitions.get(2).getVersion());
}
Aggregations