Search in sources :

Example 41 with ProcessDefinitionQuery

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);
}
Also used : DeploymentQuery(org.camunda.bpm.engine.repository.DeploymentQuery) ProcessApplicationDeployment(org.camunda.bpm.engine.repository.ProcessApplicationDeployment) ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Example 42 with ProcessDefinitionQuery

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);
}
Also used : DeploymentQuery(org.camunda.bpm.engine.repository.DeploymentQuery) ProcessApplicationDeployment(org.camunda.bpm.engine.repository.ProcessApplicationDeployment) ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Example 43 with ProcessDefinitionQuery

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));
}
Also used : ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 44 with ProcessDefinitionQuery

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));
}
Also used : Deployment(org.camunda.bpm.engine.repository.Deployment) ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Example 45 with ProcessDefinitionQuery

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());
}
Also used : ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) RepositoryService(org.camunda.bpm.engine.RepositoryService) Test(org.junit.Test) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)

Aggregations

ProcessDefinitionQuery (org.camunda.bpm.engine.repository.ProcessDefinitionQuery)112 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)27 ProcessApplicationDeployment (org.camunda.bpm.engine.repository.ProcessApplicationDeployment)25 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)23 Test (org.junit.Test)23 Deployment (org.camunda.bpm.engine.repository.Deployment)19 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)14 Resource (org.camunda.bpm.engine.repository.Resource)9 DeploymentQuery (org.camunda.bpm.engine.repository.DeploymentQuery)8 Job (org.camunda.bpm.engine.runtime.Job)6 RepositoryService (org.camunda.bpm.engine.RepositoryService)5 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)4 Incident (org.camunda.bpm.engine.runtime.Incident)4 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)4 Map (java.util.Map)3 ReadOnlyProcessDefinition (org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition)3 Response (com.jayway.restassured.response.Response)2 HashMap (java.util.HashMap)2 Authorization (org.camunda.bpm.engine.authorization.Authorization)2 Group (org.camunda.bpm.engine.identity.Group)2