use of org.activiti.engine.repository.Model in project Activiti by Activiti.
the class ModelResourceSourceTest method testSetModelEditorSource.
public void testSetModelEditorSource() throws Exception {
Model model = null;
try {
model = repositoryService.newModel();
model.setName("Model name");
repositoryService.saveModel(model);
HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_MODEL_SOURCE, model.getId()));
httpPut.setEntity(HttpMultipartHelper.getMultiPartEntity("sourcefile", "application/octet-stream", new ByteArrayInputStream("This is the new editor source".getBytes()), null));
closeResponse(executeBinaryRequest(httpPut, HttpStatus.SC_NO_CONTENT));
assertEquals("This is the new editor source", new String(repositoryService.getModelEditorSource(model.getId())));
} finally {
try {
repositoryService.deleteModel(model.getId());
} catch (Throwable ignore) {
// Ignore, model might not be created
}
}
}
use of org.activiti.engine.repository.Model in project Activiti by Activiti.
the class ModelQueryEscapeClauseTest method setUp.
@Override
protected void setUp() throws Exception {
Model model = repositoryService.newModel();
model.setTenantId("mytenant%");
model.setName("my model%");
model.setKey("someKey1");
model.setCategory("test%");
repositoryService.saveModel(model);
modelOneId = model.getId();
model = repositoryService.newModel();
model.setTenantId("mytenant_");
model.setName("my model_");
model.setKey("someKey2");
model.setCategory("test_");
repositoryService.saveModel(model);
modelTwoId = model.getId();
repositoryService.addModelEditorSource(modelOneId, "bytes".getBytes("utf-8"));
repositoryService.addModelEditorSource(modelTwoId, "bytes".getBytes("utf-8"));
super.setUp();
}
use of org.activiti.engine.repository.Model in project Activiti by Activiti.
the class ModelQueryEscapeClauseTest method testQueryByCategoryLike.
public void testQueryByCategoryLike() throws Exception {
ModelQuery query = repositoryService.createModelQuery().modelCategoryLike("%\\%%");
Model model = query.singleResult();
assertNotNull(model);
assertEquals("someKey1", model.getKey());
assertEquals("bytes", new String(repositoryService.getModelEditorSource(model.getId()), "utf-8"));
assertEquals(1, query.list().size());
assertEquals(1, query.count());
query = repositoryService.createModelQuery().modelCategoryLike("%\\_%");
model = query.singleResult();
assertNotNull(model);
assertEquals("someKey2", model.getKey());
assertEquals("bytes", new String(repositoryService.getModelEditorSource(model.getId()), "utf-8"));
assertEquals(1, query.list().size());
assertEquals(1, query.count());
}
use of org.activiti.engine.repository.Model in project Activiti by Activiti.
the class ModelQueryEscapeClauseTest method testQueryByTenantIdLike.
public void testQueryByTenantIdLike() throws Exception {
ModelQuery query = repositoryService.createModelQuery().modelTenantIdLike("%\\%%");
Model model = query.singleResult();
assertNotNull(model);
assertEquals("someKey1", model.getKey());
assertEquals("bytes", new String(repositoryService.getModelEditorSource(model.getId()), "utf-8"));
assertEquals(1, query.list().size());
assertEquals(1, query.count());
query = repositoryService.createModelQuery().modelTenantIdLike("%\\_%");
model = query.singleResult();
assertNotNull(model);
assertEquals("someKey2", model.getKey());
assertEquals("bytes", new String(repositoryService.getModelEditorSource(model.getId()), "utf-8"));
assertEquals(1, query.list().size());
assertEquals(1, query.count());
}
use of org.activiti.engine.repository.Model in project Activiti by Activiti.
the class ModelEventsTest method testModelEvents.
/**
* Test create, update and delete events of model entities.
*/
public void testModelEvents() throws Exception {
Model model = null;
try {
model = repositoryService.newModel();
model.setName("My model");
model.setKey("key");
repositoryService.saveModel(model);
// Check create event
assertEquals(2, listener.getEventsReceived().size());
assertEquals(ActivitiEventType.ENTITY_CREATED, listener.getEventsReceived().get(0).getType());
assertEquals(model.getId(), ((Model) ((ActivitiEntityEvent) listener.getEventsReceived().get(0)).getEntity()).getId());
assertEquals(ActivitiEventType.ENTITY_INITIALIZED, listener.getEventsReceived().get(1).getType());
assertEquals(model.getId(), ((Model) ((ActivitiEntityEvent) listener.getEventsReceived().get(1)).getEntity()).getId());
listener.clearEventsReceived();
// Update model
model = repositoryService.getModel(model.getId());
model.setName("Updated");
repositoryService.saveModel(model);
assertEquals(1, listener.getEventsReceived().size());
assertEquals(ActivitiEventType.ENTITY_UPDATED, listener.getEventsReceived().get(0).getType());
assertEquals(model.getId(), ((Model) ((ActivitiEntityEvent) listener.getEventsReceived().get(0)).getEntity()).getId());
listener.clearEventsReceived();
// Test additional update-methods (source and extra-source)
repositoryService.addModelEditorSource(model.getId(), "test".getBytes());
repositoryService.addModelEditorSourceExtra(model.getId(), "test extra".getBytes());
assertEquals(2, listener.getEventsReceived().size());
assertEquals(ActivitiEventType.ENTITY_UPDATED, listener.getEventsReceived().get(0).getType());
assertEquals(ActivitiEventType.ENTITY_UPDATED, listener.getEventsReceived().get(1).getType());
listener.clearEventsReceived();
// Delete model events
repositoryService.deleteModel(model.getId());
assertEquals(1, listener.getEventsReceived().size());
assertEquals(ActivitiEventType.ENTITY_DELETED, listener.getEventsReceived().get(0).getType());
assertEquals(model.getId(), ((Model) ((ActivitiEntityEvent) listener.getEventsReceived().get(0)).getEntity()).getId());
listener.clearEventsReceived();
} finally {
if (model != null && repositoryService.getModel(model.getId()) != null) {
repositoryService.deleteModel(model.getId());
}
}
}
Aggregations