Search in sources :

Example 16 with ProcessDefinitionQuery

use of org.camunda.bpm.engine.repository.ProcessDefinitionQuery in project camunda-bpm-platform by camunda.

the class ProcessDefinitionAuthorizationTest method testQueryWithGroupAuthorizationRevokedReadPermission.

public void testQueryWithGroupAuthorizationRevokedReadPermission() {
    // given
    // given user gets all permissions on any process definition
    Authorization authorization = createGrantAuthorization(PROCESS_DEFINITION, ANY);
    authorization.setGroupId(groupId);
    authorization.addPermission(ALL);
    saveAuthorization(authorization);
    authorization = createRevokeAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY);
    authorization.setGroupId(groupId);
    authorization.removePermission(READ);
    saveAuthorization(authorization);
    // when
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
    // then
    verifyQueryResults(query, 1);
    ProcessDefinition definition = query.singleResult();
    assertNotNull(definition);
    assertEquals(TWO_TASKS_PROCESS_KEY, definition.getKey());
}
Also used : Authorization(org.camunda.bpm.engine.authorization.Authorization) ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) ReadOnlyProcessDefinition(org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition)

Example 17 with ProcessDefinitionQuery

use of org.camunda.bpm.engine.repository.ProcessDefinitionQuery in project camunda-bpm-platform by camunda.

the class ProcessDefinitionQueryTest method testQueryByLatestAndNameLike_NotFound.

public void testQueryByLatestAndNameLike_NotFound() {
    String firstDeployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/repository/first-process.bpmn20.xml").deploy().getId();
    String secondDeployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/repository/second-process.bpmn20.xml").deploy().getId();
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
    query.processDefinitionNameLike("First%").latestVersion();
    verifyQueryResults(query, 0);
    repositoryService.deleteDeployment(firstDeployment, true);
    repositoryService.deleteDeployment(secondDeployment, true);
}
Also used : ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery)

Example 18 with ProcessDefinitionQuery

use of org.camunda.bpm.engine.repository.ProcessDefinitionQuery in project camunda-bpm-platform by camunda.

the class ProcessDefinitionQueryTest method testQueryByKey.

public void testQueryByKey() {
    // process one
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().processDefinitionKey("one");
    verifyQueryResults(query, 2);
    // process two
    query = repositoryService.createProcessDefinitionQuery().processDefinitionKey("two");
    verifyQueryResults(query, 1);
}
Also used : ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery)

Example 19 with ProcessDefinitionQuery

use of org.camunda.bpm.engine.repository.ProcessDefinitionQuery in project camunda-bpm-platform by camunda.

the class ProcessDefinitionQueryTest method testQueryByInvalidName.

public void testQueryByInvalidName() {
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().processDefinitionName("invalid");
    verifyQueryResults(query, 0);
    try {
        repositoryService.createProcessDefinitionQuery().processDefinitionName(null);
        fail();
    } catch (ProcessEngineException e) {
    // Expected Exception
    }
}
Also used : ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 20 with ProcessDefinitionQuery

use of org.camunda.bpm.engine.repository.ProcessDefinitionQuery in project camunda-bpm-platform by camunda.

the class ProcessDefinitionQueryTest method testQueryByLatestAndName.

public void testQueryByLatestAndName() {
    String firstDeployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/repository/first-process.bpmn20.xml").deploy().getId();
    String secondDeployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/repository/first-process.bpmn20.xml").deploy().getId();
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
    query.processDefinitionName("First Test Process").latestVersion();
    verifyQueryResults(query, 1);
    ProcessDefinition result = query.singleResult();
    assertEquals("First Test Process", result.getName());
    assertEquals(2, result.getVersion());
    repositoryService.deleteDeployment(firstDeployment, true);
    repositoryService.deleteDeployment(secondDeployment, true);
}
Also used : ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition)

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