use of org.activiti.engine.repository.ModelQuery in project Activiti by Activiti.
the class ModelQueryTest method testQueryByInvalidKey.
public void testQueryByInvalidKey() {
ModelQuery query = repositoryService.createModelQuery().modelKey("invalid");
assertThat(query.singleResult()).isNull();
assertThat(query.list()).hasSize(0);
assertThat(query.count()).isEqualTo(0);
}
use of org.activiti.engine.repository.ModelQuery in project Activiti by Activiti.
the class ModelQueryTest method testQueryByCategory.
public void testQueryByCategory() {
ModelQuery query = repositoryService.createModelQuery().modelCategory("test");
assertThat(query.list()).hasSize(1);
assertThat(query.count()).isEqualTo(1);
}
use of org.activiti.engine.repository.ModelQuery in project Activiti by Activiti.
the class ModelQueryTest method testByLatestVersion.
public void testByLatestVersion() {
ModelQuery query = repositoryService.createModelQuery().latestVersion().modelKey("someKey");
Model model = query.singleResult();
assertThat(model).isNotNull();
// Add a new version of the model
Model newVersion = repositoryService.newModel();
newVersion.setName("my model");
newVersion.setKey("someKey");
newVersion.setCategory("test");
newVersion.setVersion(model.getVersion() + 1);
repositoryService.saveModel(newVersion);
// Verify query
model = query.singleResult();
assertThat(model).isNotNull();
assertThat(model.getVersion() == 2).isTrue();
// Cleanup
repositoryService.deleteModel(model.getId());
}
use of org.activiti.engine.repository.ModelQuery in project Activiti by Activiti.
the class ModelQueryTest method testOrderBy.
public void testOrderBy() {
ModelQuery query = repositoryService.createModelQuery();
assertThat(query.orderByCreateTime().asc().count()).isEqualTo(1);
assertThat(query.orderByLastUpdateTime().asc().count()).isEqualTo(1);
assertThat(query.orderByModelCategory().asc().count()).isEqualTo(1);
assertThat(query.orderByModelId().desc().count()).isEqualTo(1);
assertThat(query.orderByModelName().desc().count()).isEqualTo(1);
assertThat(query.orderByModelVersion().desc().count()).isEqualTo(1);
assertThat(query.orderByModelKey().desc().count()).isEqualTo(1);
}
use of org.activiti.engine.repository.ModelQuery in project Activiti by Activiti.
the class ModelQueryTest method testQueryByCategoryNotEquals.
public void testQueryByCategoryNotEquals() {
ModelQuery query = repositoryService.createModelQuery().modelCategoryNotEquals("aap");
assertThat(query.list()).hasSize(1);
assertThat(query.count()).isEqualTo(1);
}
Aggregations