Search in sources :

Example 6 with ModelQuery

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);
}
Also used : ModelQuery(org.activiti.engine.repository.ModelQuery)

Example 7 with ModelQuery

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);
}
Also used : ModelQuery(org.activiti.engine.repository.ModelQuery)

Example 8 with ModelQuery

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());
}
Also used : Model(org.activiti.engine.repository.Model) ModelQuery(org.activiti.engine.repository.ModelQuery)

Example 9 with ModelQuery

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);
}
Also used : ModelQuery(org.activiti.engine.repository.ModelQuery)

Example 10 with ModelQuery

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);
}
Also used : ModelQuery(org.activiti.engine.repository.ModelQuery)

Aggregations

ModelQuery (org.activiti.engine.repository.ModelQuery)23 Model (org.activiti.engine.repository.Model)9 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 RepositoryService (org.activiti.engine.RepositoryService)1 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)1 DataResponse (org.wso2.carbon.bpmn.rest.model.common.DataResponse)1 ModelResponse (org.wso2.carbon.bpmn.rest.model.repository.ModelResponse)1 ModelsPaginateList (org.wso2.carbon.bpmn.rest.model.repository.ModelsPaginateList)1