use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class ChineseConverterTest method deployProcess.
protected void deployProcess(BpmnModel bpmnModel) {
byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel);
try {
Deployment deployment = processEngine.getRepositoryService().createDeployment().name("test").addString("test.bpmn20.xml", new String(xml)).deploy();
processEngine.getRepositoryService().deleteDeployment(deployment.getId());
} finally {
processEngine.close();
}
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class TenancyTest method testStartProcessInstanceByMessageTenancyReversed.
public void testStartProcessInstanceByMessageTenancyReversed() {
// same as
// above, but now reversed
// Deploy process both with and without tenant
repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testMessageTenancy.bpmn20.xml").deploy();
repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testMessageTenancy.bpmn20.xml").tenantId(TEST_TENANT_ID).deploy();
// Start a process instance by message with tenant
runtimeService.startProcessInstanceByMessageAndTenantId("My message", TEST_TENANT_ID);
runtimeService.startProcessInstanceByMessageAndTenantId("My message", TEST_TENANT_ID);
runtimeService.startProcessInstanceByMessageAndTenantId("My message", TEST_TENANT_ID);
assertThat(taskService.createTaskQuery().taskName("My task").count()).isEqualTo(3);
assertThat(taskService.createTaskQuery().taskName("My task").taskWithoutTenantId().count()).isEqualTo(0);
assertThat(taskService.createTaskQuery().taskName("My task").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(3);
// Start a process instance by message without tenant
runtimeService.startProcessInstanceByMessage("My message");
runtimeService.startProcessInstanceByMessage("My message");
assertThat(taskService.createTaskQuery().taskName("My task").count()).isEqualTo(5);
assertThat(taskService.createTaskQuery().taskName("My task").taskWithoutTenantId().count()).isEqualTo(2);
assertThat(taskService.createTaskQuery().taskName("My task").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(3);
// 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 testSignalFromProcessTenancy.
public void testSignalFromProcessTenancy() {
// 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 3 proc instances for the one with a tenant and 2 for the one
// without tenant
runtimeService.startProcessInstanceByKeyAndTenantId("testMtSignalCatch", TEST_TENANT_ID);
runtimeService.startProcessInstanceByKeyAndTenantId("testMtSignalCatch", TEST_TENANT_ID);
runtimeService.startProcessInstanceByKeyAndTenantId("testMtSignalCatch", TEST_TENANT_ID);
runtimeService.startProcessInstanceByKey("testMtSignalCatch");
runtimeService.startProcessInstanceByKey("testMtSignalCatch");
// verify
assertThat(taskService.createTaskQuery().taskName("My task").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(3);
assertThat(taskService.createTaskQuery().taskName("My task").taskWithoutTenantId().count()).isEqualTo(2);
// Now, start 1 process instance that fires a signal event (not in tenant context), it should only continue those without tenant
runtimeService.startProcessInstanceByKey("testMtSignalFiring");
assertThat(taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(0);
assertThat(taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count()).isEqualTo(2);
// Start a process instance that is running in tenant context
runtimeService.startProcessInstanceByKeyAndTenantId("testMtSignalFiring", TEST_TENANT_ID);
assertThat(taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(3);
assertThat(taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count()).isEqualTo(2);
// 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 testSignalThroughApiTenancy.
public void testSignalThroughApiTenancy() {
// 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
assertThat(taskService.createTaskQuery().taskName("My task").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(4);
assertThat(taskService.createTaskQuery().taskName("My task").taskWithoutTenantId().count()).isEqualTo(5);
// Signal through API (with tenant)
runtimeService.signalEventReceivedWithTenantId("The Signal", TEST_TENANT_ID);
assertThat(taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(4);
assertThat(taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count()).isEqualTo(0);
// Signal through API (without tenant)
runtimeService.signalEventReceived("The Signal");
assertThat(taskService.createTaskQuery().taskName("Task after signal").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(4);
assertThat(taskService.createTaskQuery().taskName("Task after signal").taskWithoutTenantId().count()).isEqualTo(5);
// 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 testStartProcessInstanceByMessageTenancy.
public void testStartProcessInstanceByMessageTenancy() {
// Deploy process both with and without tenant
repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testMessageTenancy.bpmn20.xml").deploy();
repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testMessageTenancy.bpmn20.xml").tenantId(TEST_TENANT_ID).deploy();
// Verify query
assertThat(repositoryService.createProcessDefinitionQuery().messageEventSubscriptionName("My message").count()).isEqualTo(2);
assertThat(repositoryService.createProcessDefinitionQuery().messageEventSubscriptionName("My message").processDefinitionWithoutTenantId().count()).isEqualTo(1);
assertThat(repositoryService.createProcessDefinitionQuery().messageEventSubscriptionName("My message").processDefinitionTenantId(TEST_TENANT_ID).count()).isEqualTo(1);
// Start a process instance by message without tenant
runtimeService.startProcessInstanceByMessage("My message");
runtimeService.startProcessInstanceByMessage("My message");
assertThat(taskService.createTaskQuery().taskName("My task").count()).isEqualTo(2);
assertThat(taskService.createTaskQuery().taskName("My task").taskWithoutTenantId().count()).isEqualTo(2);
assertThat(taskService.createTaskQuery().taskName("My task").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(0);
// Start a process instance by message with tenant
runtimeService.startProcessInstanceByMessageAndTenantId("My message", TEST_TENANT_ID);
runtimeService.startProcessInstanceByMessageAndTenantId("My message", TEST_TENANT_ID);
runtimeService.startProcessInstanceByMessageAndTenantId("My message", TEST_TENANT_ID);
assertThat(taskService.createTaskQuery().taskName("My task").count()).isEqualTo(5);
assertThat(taskService.createTaskQuery().taskName("My task").taskWithoutTenantId().count()).isEqualTo(2);
assertThat(taskService.createTaskQuery().taskName("My task").taskTenantId(TEST_TENANT_ID).count()).isEqualTo(3);
// Cleanup
for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
repositoryService.deleteDeployment(deployment.getId(), true);
}
}
Aggregations