Search in sources :

Example 51 with Model

use of org.activiti.engine.repository.Model in project Activiti by Activiti.

the class ModelQueryTest method testByDeploymentId.

public void testByDeploymentId() {
    Deployment deployment = repositoryService.createDeployment().addString("test", "test").deploy();
    assertThat(repositoryService.createModelQuery().deploymentId(deployment.getId()).count()).isEqualTo(0);
    assertThat(repositoryService.createModelQuery().deployed().count()).isEqualTo(0);
    assertThat(repositoryService.createModelQuery().notDeployed().count()).isEqualTo(1);
    Model model = repositoryService.createModelQuery().singleResult();
    model.setDeploymentId(deployment.getId());
    repositoryService.saveModel(model);
    assertThat(repositoryService.createModelQuery().deploymentId(deployment.getId()).count()).isEqualTo(1);
    assertThat(repositoryService.createModelQuery().deployed().count()).isEqualTo(1);
    assertThat(repositoryService.createModelQuery().notDeployed().count()).isEqualTo(0);
    // Cleanup
    repositoryService.deleteDeployment(deployment.getId(), true);
    // After cleanup the model should still exist
    assertThat(repositoryService.createDeploymentQuery().count()).isEqualTo(0);
    assertThat(repositoryService.createModelQuery().deploymentId(deployment.getId()).count()).isEqualTo(0);
    assertThat(repositoryService.createModelQuery().notDeployed().count()).isEqualTo(1);
    assertThat(repositoryService.createModelQuery().count()).isEqualTo(1);
}
Also used : Model(org.activiti.engine.repository.Model) Deployment(org.activiti.engine.repository.Deployment)

Example 52 with Model

use of org.activiti.engine.repository.Model in project Activiti by Activiti.

the class ModelQueryTest method testQueryByNameLike.

public void testQueryByNameLike() throws Exception {
    ModelQuery query = repositoryService.createModelQuery().modelNameLike("%model%");
    Model model = query.singleResult();
    assertThat(model).isNotNull();
    assertThat(new String(repositoryService.getModelEditorSource(model.getId()), "utf-8")).isEqualTo("bytes");
    assertThat(query.list()).hasSize(1);
    assertThat(query.count()).isEqualTo(1);
}
Also used : Model(org.activiti.engine.repository.Model) ModelQuery(org.activiti.engine.repository.ModelQuery)

Example 53 with Model

use of org.activiti.engine.repository.Model in project Activiti by Activiti.

the class ModelQueryTest method setUp.

@Override
protected void setUp() throws Exception {
    Model model = repositoryService.newModel();
    model.setName("my model");
    model.setKey("someKey");
    model.setCategory("test");
    repositoryService.saveModel(model);
    modelOneId = model.getId();
    repositoryService.addModelEditorSource(modelOneId, "bytes".getBytes("utf-8"));
    super.setUp();
}
Also used : Model(org.activiti.engine.repository.Model)

Example 54 with Model

use of org.activiti.engine.repository.Model in project Activiti by Activiti.

the class ModelQueryTest method testQueryByKey.

public void testQueryByKey() {
    ModelQuery query = repositoryService.createModelQuery().modelName("my model").modelKey("someKey");
    Model model = query.singleResult();
    assertThat(model).isNotNull();
    assertThat(query.list()).hasSize(1);
    assertThat(query.count()).isEqualTo(1);
}
Also used : Model(org.activiti.engine.repository.Model) ModelQuery(org.activiti.engine.repository.ModelQuery)

Example 55 with Model

use of org.activiti.engine.repository.Model in project Activiti by Activiti.

the class ModelQueryTest method testModelProperties.

public void testModelProperties() {
    ModelQuery query = repositoryService.createModelQuery();
    Model model = query.singleResult();
    assertThat(model.getId()).isNotNull();
    assertThat(model.getCategory()).isNotNull();
    assertThat(model.getKey()).isNotNull();
    assertThat(model.getName()).isNotNull();
    assertThat(model.getVersion()).isNotNull();
    assertThat(model.getCreateTime()).isNotNull();
    assertThat(model.getLastUpdateTime()).isNotNull();
}
Also used : Model(org.activiti.engine.repository.Model) ModelQuery(org.activiti.engine.repository.ModelQuery)

Aggregations

Model (org.activiti.engine.repository.Model)60 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)20 BpmnModel (org.activiti.bpmn.model.BpmnModel)13 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)12 ModelQuery (org.activiti.engine.repository.ModelQuery)9 InputStream (java.io.InputStream)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 ActivitiException (org.activiti.engine.ActivitiException)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 ByteArrayInputStream (java.io.ByteArrayInputStream)6 Calendar (java.util.Calendar)6 Deployment (org.activiti.engine.test.Deployment)6 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)6 BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)5 BpmnJsonConverter (org.activiti.editor.language.json.converter.BpmnJsonConverter)5 HttpGet (org.apache.http.client.methods.HttpGet)5 Before (com.jfinal.aop.Before)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 HttpPut (org.apache.http.client.methods.HttpPut)4 StringEntity (org.apache.http.entity.StringEntity)4