use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class DeploymentCategoryTest method testDeploymentCategory.
public void testDeploymentCategory() {
String noCategoryDeploymentId = null;
String deploymentOneId = null;
String deploymentTwoV1Id = null;
String deploymentTwoV2Id = null;
String deploymentTwoNoCategory = null;
try {
noCategoryDeploymentId = repositoryService.createDeployment().name("0").addClasspathResource("org/activiti/engine/test/service/oneTaskProcess.bpmn20.xml").deploy().getId();
deploymentOneId = repositoryService.createDeployment().name("1").category("one").addClasspathResource("org/activiti/engine/test/repository/one.bpmn20.xml").deploy().getId();
deploymentTwoV1Id = repositoryService.createDeployment().name("2v1").category("two").addClasspathResource("org/activiti/engine/test/repository/two.bpmn20.xml").deploy().getId();
deploymentTwoV2Id = repositoryService.createDeployment().name("2v2").category("two").addClasspathResource("org/activiti/engine/test/repository/two.bpmn20.xml").deploy().getId();
DeploymentQuery query = repositoryService.createDeploymentQuery();
assertEquals(4, query.list().size());
Set<String> deploymentNames = getDeploymentNames(repositoryService.createDeploymentQuery().deploymentCategory("one").list());
Set<String> expectedDeploymentNames = new HashSet<String>();
expectedDeploymentNames.add("1");
assertEquals(expectedDeploymentNames, deploymentNames);
deploymentNames = getDeploymentNames(repositoryService.createDeploymentQuery().deploymentCategoryNotEquals("two").list());
expectedDeploymentNames.add("0");
assertEquals(expectedDeploymentNames, deploymentNames);
deploymentTwoNoCategory = repositoryService.createDeployment().name("noCategory").addClasspathResource("org/activiti/engine/test/repository/two.bpmn20.xml").deploy().getId();
Deployment deploymentNoCategory = repositoryService.createDeploymentQuery().deploymentId(deploymentTwoNoCategory).singleResult();
assertNull(deploymentNoCategory.getCategory());
repositoryService.setDeploymentCategory(deploymentTwoNoCategory, "newCategory");
deploymentNoCategory = repositoryService.createDeploymentQuery().deploymentId(deploymentTwoNoCategory).singleResult();
assertEquals("newCategory", deploymentNoCategory.getCategory());
} finally {
if (noCategoryDeploymentId != null)
undeploy(noCategoryDeploymentId);
if (deploymentOneId != null)
undeploy(deploymentOneId);
if (deploymentTwoV1Id != null)
undeploy(deploymentTwoV1Id);
if (deploymentTwoV2Id != null)
undeploy(deploymentTwoV2Id);
if (deploymentTwoNoCategory != null)
undeploy(deploymentTwoNoCategory);
}
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class ModelQueryTest method testByDeploymentId.
public void testByDeploymentId() {
Deployment deployment = repositoryService.createDeployment().addString("test", "test").deploy();
assertEquals(0, repositoryService.createModelQuery().deploymentId(deployment.getId()).count());
assertEquals(0, repositoryService.createModelQuery().deployed().count());
assertEquals(1, repositoryService.createModelQuery().notDeployed().count());
Model model = repositoryService.createModelQuery().singleResult();
model.setDeploymentId(deployment.getId());
repositoryService.saveModel(model);
assertEquals(1, repositoryService.createModelQuery().deploymentId(deployment.getId()).count());
assertEquals(1, repositoryService.createModelQuery().deployed().count());
assertEquals(0, repositoryService.createModelQuery().notDeployed().count());
// Cleanup
repositoryService.deleteDeployment(deployment.getId(), true);
// After cleanup the model should still exist
assertEquals(0, repositoryService.createDeploymentQuery().count());
assertEquals(0, repositoryService.createModelQuery().deploymentId(deployment.getId()).count());
assertEquals(1, repositoryService.createModelQuery().notDeployed().count());
assertEquals(1, repositoryService.createModelQuery().count());
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class DeploymentQueryTest method testVerifyDeploymentProperties.
public void testVerifyDeploymentProperties() {
List<Deployment> deployments = repositoryService.createDeploymentQuery().orderByDeploymentName().asc().list();
Deployment deploymentOne = deployments.get(0);
assertEquals("org/activiti/engine/test/repository/one.bpmn20.xml", deploymentOne.getName());
assertEquals(deploymentOneId, deploymentOne.getId());
Deployment deploymentTwo = deployments.get(1);
assertEquals("org/activiti/engine/test/repository/two.bpmn20.xml", deploymentTwo.getName());
assertEquals(deploymentTwoId, deploymentTwo.getId());
deployments = repositoryService.createDeploymentQuery().deploymentNameLike("%one%").orderByDeploymentName().asc().list();
assertEquals("org/activiti/engine/test/repository/one.bpmn20.xml", deployments.get(0).getName());
assertEquals(1, deployments.size());
assertEquals(2, repositoryService.createDeploymentQuery().orderByDeploymentId().asc().list().size());
assertEquals(2, repositoryService.createDeploymentQuery().orderByDeploymenTime().asc().list().size());
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class DeploymentPersistenceTest method testDeploymentPersistence.
public void testDeploymentPersistence() {
Deployment deployment = repositoryService.createDeployment().name("strings").addString("org/activiti/test/HelloWorld.string", "hello world").addString("org/activiti/test/TheAnswer.string", "42").deploy();
List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
assertEquals(1, deployments.size());
deployment = deployments.get(0);
assertEquals("strings", deployment.getName());
assertNotNull(deployment.getDeploymentTime());
String deploymentId = deployment.getId();
List<String> resourceNames = repositoryService.getDeploymentResourceNames(deploymentId);
Set<String> expectedResourceNames = new HashSet<String>();
expectedResourceNames.add("org/activiti/test/HelloWorld.string");
expectedResourceNames.add("org/activiti/test/TheAnswer.string");
assertEquals(expectedResourceNames, new HashSet<String>(resourceNames));
InputStream resourceStream = repositoryService.getResourceAsStream(deploymentId, "org/activiti/test/HelloWorld.string");
assertTrue(Arrays.equals("hello world".getBytes(), IoUtil.readInputStream(resourceStream, "test")));
resourceStream = repositoryService.getResourceAsStream(deploymentId, "org/activiti/test/TheAnswer.string");
assertTrue(Arrays.equals("42".getBytes(), IoUtil.readInputStream(resourceStream, "test")));
repositoryService.deleteDeployment(deploymentId);
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class MultiTenantProcessEngineTest method startProcessInstances.
private void startProcessInstances(String userId) {
System.out.println();
System.out.println("Starting process instance for user " + userId);
tenantInfoHolder.setCurrentUserId(userId);
Deployment deployment = processEngine.getRepositoryService().createDeployment().addClasspathResource("org/activiti/engine/test/cfg/multitenant/oneTaskProcess.bpmn20.xml").addClasspathResource("org/activiti/engine/test/cfg/multitenant/jobTest.bpmn20.xml").deploy();
System.out.println("Process deployed! Deployment id is " + deployment.getId());
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("data", "Hello from " + userId);
ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess", vars);
List<Task> tasks = processEngine.getTaskService().createTaskQuery().processInstanceId(processInstance.getId()).list();
System.out.println("Got " + tasks.size() + " tasks");
System.out.println("Got " + processEngine.getHistoryService().createHistoricProcessInstanceQuery().count() + " process instances in the system");
// Start a process instance with a Job
processEngine.getRuntimeService().startProcessInstanceByKey("jobTest");
tenantInfoHolder.clearCurrentUserId();
tenantInfoHolder.clearCurrentTenantId();
}
Aggregations