use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class TenancyTest method testCallActivityWithTenant.
// Bug from http://forums.activiti.org/content/callactiviti-tenant-id
public void testCallActivityWithTenant() {
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
String tenantId = "apache";
//deploying both processes. Process 1 will call Process 2
repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testCallActivityWithTenant-process01.bpmn20.xml").tenantId(tenantId).deploy();
repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testCallActivityWithTenant-process02.bpmn20.xml").tenantId(tenantId).deploy();
//Starting Process 1. Process 1 will be executed successfully but when the call to process 2 is made internally it will throw the exception
ProcessInstance processInstance = runtimeService.startProcessInstanceByKeyAndTenantId("process1", null, CollectionUtil.singletonMap("sendFor", "test"), tenantId);
Assert.assertNotNull(processInstance);
Assert.assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionKey("process2").processInstanceTenantId(tenantId).count());
Assert.assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionKey("process2").count());
// following line if executed will give activiti object not found exception as the process1 is linked to a tenant id.
try {
processInstance = runtimeService.startProcessInstanceByKey("process1");
Assert.fail();
} catch (Exception e) {
}
// Cleanup
for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
repositoryService.deleteDeployment(deployment.getId(), true);
}
}
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class TenancyTest method testSignalAsyncThroughApiTenancy.
public void testSignalAsyncThroughApiTenancy() {
// Deploy process both with and without tenant
repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testMultiTenancySignals.bpmn20.xml").deploy();
repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testMultiTenancySignals.bpmn20.xml").tenantId(TEST_TENANT_ID).deploy();
// Start 4 proc instances for the one with a tenant and 5 for the one without tenant
runtimeService.startProcessInstanceByKeyAndTenantId("testMtSignalCatch", TEST_TENANT_ID);
runtimeService.startProcessInstanceByKeyAndTenantId("testMtSignalCatch", TEST_TENANT_ID);
runtimeService.startProcessInstanceByKeyAndTenantId("testMtSignalCatch", TEST_TENANT_ID);
runtimeService.startProcessInstanceByKeyAndTenantId("testMtSignalCatch", TEST_TENANT_ID);
runtimeService.startProcessInstanceByKey("testMtSignalCatch");
runtimeService.startProcessInstanceByKey("testMtSignalCatch");
runtimeService.startProcessInstanceByKey("testMtSignalCatch");
runtimeService.startProcessInstanceByKey("testMtSignalCatch");
runtimeService.startProcessInstanceByKey("testMtSignalCatch");
// Verify
assertEquals(4, taskService.createTaskQuery().taskName("My task").taskTenantId(TEST_TENANT_ID).count());
assertEquals(5, taskService.createTaskQuery().taskName("My task").taskWithoutTenantId().count());
// Signal through API (with tenant)
runtimeService.signalEventReceivedAsyncWithTenantId("The Signal", TEST_TENANT_ID);
assertEquals(0, taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count());
assertEquals(0, taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count());
for (Job job : managementService.createJobQuery().list()) {
managementService.executeJob(job.getId());
}
assertEquals(4, taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count());
assertEquals(0, taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count());
// Signal through API (without tenant)
runtimeService.signalEventReceivedAsync("The Signal");
assertEquals(4, taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count());
assertEquals(0, taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count());
for (Job job : managementService.createJobQuery().list()) {
managementService.executeJob(job.getId());
}
assertEquals(4, taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count());
assertEquals(5, taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count());
// Cleanup
for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
repositoryService.deleteDeployment(deployment.getId(), true);
}
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class ProcessDefinitionsTest method testDeployments.
@Test
public void testDeployments() {
when(repositoryService.createDeploymentQuery()).thenReturn(deploymentQuery);
DeploymentEntity deployment = new DeploymentEntity();
List<Deployment> deploymentList = new ArrayList<Deployment>();
deployment.setId("testDeploymentId");
deployment.setName("testDeploymentName");
deployment.setTenantId("tenantId");
deploymentList.add(deployment);
when(deploymentQuery.list()).thenReturn(deploymentList);
List<List<String>> result = processDefinitionsMBean.getDeployments();
assertNotNull(result);
assertEquals(1, result.size());
assertEquals(3, result.get(0).size());
assertEquals("testDeploymentId", result.get(0).get(0));
assertEquals("testDeploymentName", result.get(0).get(1));
assertEquals("tenantId", result.get(0).get(2));
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class ProcessDefinitionsMBean method deployProcessDefinition.
@ManagedOperation(description = "Deploy Process Definition")
public void deployProcessDefinition(String resourceName, String processDefinitionFile) throws FileNotFoundException {
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
Deployment deployment = deploymentBuilder.addInputStream(resourceName, new FileInputStream(processDefinitionFile)).deploy();
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class ProcessDefinitionsMBean method getDeployments.
@ManagedAttribute(description = "List of deployed Processes")
public List<List<String>> getDeployments() {
List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
List<List<String>> result = new ArrayList<List<String>>(deployments.size());
for (Deployment deployment : deployments) {
List<String> item = new ArrayList<String>(3);
item.add(deployment.getId());
item.add(deployment.getName());
item.add(deployment.getTenantId());
result.add(item);
}
return result;
}
Aggregations