use of org.camunda.bpm.engine.repository.ProcessDefinitionQuery in project camunda-bpm-platform by camunda.
the class ProcessApplicationDeploymentTest method testProcessApplicationDeploymentSourceAwareDuplicateFilter.
public void testProcessApplicationDeploymentSourceAwareDuplicateFilter() {
// given
String key = "process";
String name = "my-deployment";
BpmnModelInstance model = Bpmn.createExecutableProcess(key).done();
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().processDefinitionKey(key);
DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery().deploymentName(name);
// when
ProcessApplicationDeployment deployment1 = repositoryService.createDeployment(processApplication.getReference()).name(name).addModelInstance("process.bpmn", model).enableDuplicateFiltering(true).deploy();
assertEquals(1, processDefinitionQuery.count());
assertEquals(1, deploymentQuery.count());
ProcessApplicationDeployment deployment2 = repositoryService.createDeployment(processApplication.getReference()).name(name).addModelInstance("process.bpmn", model).enableDuplicateFiltering(true).deploy();
// then
assertEquals(1, processDefinitionQuery.count());
assertEquals(1, deploymentQuery.count());
deleteDeployments(deployment1, deployment2);
}
use of org.camunda.bpm.engine.repository.ProcessDefinitionQuery in project camunda-bpm-platform by camunda.
the class ProcessApplicationDeploymentTest method testNullAndProcessApplicationDeploymentSourceAwareDuplicateFilter.
public void testNullAndProcessApplicationDeploymentSourceAwareDuplicateFilter() {
// given
String key = "process";
String name = "my-deployment";
BpmnModelInstance model = Bpmn.createExecutableProcess(key).done();
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().processDefinitionKey(key);
DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery().deploymentName(name);
// when
ProcessApplicationDeployment deployment1 = repositoryService.createDeployment(processApplication.getReference()).name(name).source(null).addModelInstance("process.bpmn", model).enableDuplicateFiltering(true).deploy();
assertEquals(1, processDefinitionQuery.count());
assertEquals(1, deploymentQuery.count());
ProcessApplicationDeployment deployment2 = repositoryService.createDeployment(processApplication.getReference()).name(name).addModelInstance("process.bpmn", model).enableDuplicateFiltering(true).deploy();
// then
assertEquals(1, processDefinitionQuery.count());
assertEquals(1, deploymentQuery.count());
deleteDeployments(deployment1, deployment2);
}
use of org.camunda.bpm.engine.repository.ProcessDefinitionQuery in project camunda-bpm-platform by camunda.
the class MultiTenancyProcessDefinitionCmdsTenantCheckTest method testDeleteCascadeProcessDefinitionWithAuthenticatedTenant.
@Test
public void testDeleteCascadeProcessDefinitionWithAuthenticatedTenant() {
// given deployment with a process definition and process instance
BpmnModelInstance bpmnModel = Bpmn.createExecutableProcess("process").startEvent().userTask().endEvent().done();
testRule.deployForTenant(TENANT_ONE, bpmnModel);
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
ProcessDefinition processDefinition = processDefinitionQuery.processDefinitionKey("process").singleResult();
engineRule.getRuntimeService().createProcessInstanceByKey("process").executeWithVariablesInReturn();
// and user with tenant authentication
identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
// when the corresponding process definition is cascading deleted from the deployment
repositoryService.deleteProcessDefinition(processDefinition.getId(), true);
// then exist no process instance and one definition
identityService.clearAuthentication();
assertEquals(0, engineRule.getRuntimeService().createProcessInstanceQuery().count());
if (processEngineConfiguration.getHistoryLevel().getId() >= HistoryLevel.HISTORY_LEVEL_ACTIVITY.getId()) {
assertEquals(0, engineRule.getHistoryService().createHistoricActivityInstanceQuery().count());
}
assertThat(repositoryService.createProcessDefinitionQuery().count(), is(1L));
assertThat(repositoryService.createProcessDefinitionQuery().tenantIdIn(TENANT_ONE).count(), is(1L));
}
use of org.camunda.bpm.engine.repository.ProcessDefinitionQuery in project camunda-bpm-platform by camunda.
the class MultiTenancyProcessDefinitionCmdsTenantCheckTest method testDeleteProcessDefinitionDisabledTenantCheck.
@Test
public void testDeleteProcessDefinitionDisabledTenantCheck() {
// given deployment with two process definitions
Deployment deployment = testRule.deployForTenant(TENANT_ONE, "org/camunda/bpm/engine/test/repository/twoProcesses.bpmn20.xml");
// tenant check disabled
processEngineConfiguration.setTenantCheckEnabled(false);
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId());
List<ProcessDefinition> processDefinitions = processDefinitionQuery.list();
// user with no authentication
identityService.setAuthentication("user", null, null);
// when process definition should be deleted without tenant check
repositoryService.deleteProcessDefinition(processDefinitions.get(0).getId());
// then process definition is deleted
identityService.clearAuthentication();
assertThat(processDefinitionQuery.count(), is(1L));
assertThat(processDefinitionQuery.tenantIdIn(TENANT_ONE).count(), is(1L));
}
use of org.camunda.bpm.engine.repository.ProcessDefinitionQuery in project camunda-bpm-platform by camunda.
the class TestResourceName method testResourceName.
@Test
public void testResourceName() {
ProcessEngine processEngine = ProgrammaticBeanLookup.lookup(ProcessEngine.class);
Assert.assertNotNull(processEngine);
RepositoryService repositoryService = processEngine.getRepositoryService();
ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
ProcessDefinition definition = query.processDefinitionKey("process-0").singleResult();
Assert.assertEquals("process0.bpmn", definition.getResourceName());
definition = query.processDefinitionKey("process-1").singleResult();
Assert.assertEquals("processes/process1.bpmn", definition.getResourceName());
definition = query.processDefinitionKey("process-2").singleResult();
Assert.assertEquals("process2.bpmn", definition.getResourceName());
definition = query.processDefinitionKey("process-3").singleResult();
Assert.assertEquals("subDirectory/process3.bpmn", definition.getResourceName());
definition = query.processDefinitionKey("process-4").singleResult();
Assert.assertEquals("process4.bpmn", definition.getResourceName());
definition = query.processDefinitionKey("process-5").singleResult();
Assert.assertEquals("subDirectory/process5.bpmn", definition.getResourceName());
}
Aggregations