use of org.camunda.bpm.engine.repository.ProcessDefinitionQuery in project camunda-bpm-platform by camunda.
the class ProcessDefinitionQueryTest method testQueryByNameLike.
public void testQueryByNameLike() {
ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().processDefinitionNameLike("%w%");
verifyQueryResults(query, 1);
query = query.processDefinitionNameLike("%z\\_%");
verifyQueryResults(query, 1);
}
use of org.camunda.bpm.engine.repository.ProcessDefinitionQuery in project camunda-bpm-platform by camunda.
the class ProcessDefinitionQueryTest method testQuerySorting.
public void testQuerySorting() {
// asc
ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionId().asc();
verifyQueryResults(query, 4);
query = repositoryService.createProcessDefinitionQuery().orderByDeploymentId().asc();
verifyQueryResults(query, 4);
query = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionKey().asc();
verifyQueryResults(query, 4);
query = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionVersion().asc();
verifyQueryResults(query, 4);
// desc
query = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionId().desc();
verifyQueryResults(query, 4);
query = repositoryService.createProcessDefinitionQuery().orderByDeploymentId().desc();
verifyQueryResults(query, 4);
query = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionKey().desc();
verifyQueryResults(query, 4);
query = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionVersion().desc();
verifyQueryResults(query, 4);
// Typical use case
query = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionKey().asc().orderByProcessDefinitionVersion().desc();
List<ProcessDefinition> processDefinitions = query.list();
assertEquals(4, processDefinitions.size());
assertEquals("one", processDefinitions.get(0).getKey());
assertEquals(2, processDefinitions.get(0).getVersion());
assertEquals("one", processDefinitions.get(1).getKey());
assertEquals(1, processDefinitions.get(1).getVersion());
assertEquals("two", processDefinitions.get(2).getKey());
assertEquals(1, processDefinitions.get(2).getVersion());
}
use of org.camunda.bpm.engine.repository.ProcessDefinitionQuery in project camunda-bpm-platform by camunda.
the class RedeploymentTest method testRedeployFormDifferentDeploymentsById.
public void testRedeployFormDifferentDeploymentsById() {
// given
ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
BpmnModelInstance model1 = createProcessWithServiceTask(PROCESS_1_KEY);
// first deployment
Deployment deployment1 = repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-1").addModelInstance(RESOURCE_1_NAME, model1).deploy();
assertEquals(1, repositoryService.getDeploymentResources(deployment1.getId()).size());
Resource resource1 = getResourceByName(deployment1.getId(), RESOURCE_1_NAME);
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 1);
// second deployment
BpmnModelInstance model2 = createProcessWithReceiveTask(PROCESS_2_KEY);
Deployment deployment2 = repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-2").addModelInstance(RESOURCE_2_NAME, model2).deploy();
assertEquals(1, repositoryService.getDeploymentResources(deployment2.getId()).size());
Resource resource2 = getResourceByName(deployment2.getId(), RESOURCE_2_NAME);
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 1);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 1);
// when
Deployment deployment3 = repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-3").addDeploymentResourceById(deployment1.getId(), resource1.getId()).addDeploymentResourceById(deployment2.getId(), resource2.getId()).deploy();
assertEquals(2, repositoryService.getDeploymentResources(deployment3.getId()).size());
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 2);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 2);
deleteDeployments(deployment1, deployment2, deployment3);
}
use of org.camunda.bpm.engine.repository.ProcessDefinitionQuery in project camunda-bpm-platform by camunda.
the class RedeploymentTest method testRedeployFormDifferentDeployments.
public void testRedeployFormDifferentDeployments() {
// given
ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
BpmnModelInstance model1 = createProcessWithServiceTask(PROCESS_1_KEY);
// first deployment
Deployment deployment1 = repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-1").addModelInstance(RESOURCE_1_NAME, model1).deploy();
assertEquals(1, repositoryService.getDeploymentResources(deployment1.getId()).size());
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 1);
// second deployment
BpmnModelInstance model2 = createProcessWithReceiveTask(PROCESS_2_KEY);
Deployment deployment2 = repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-2").addModelInstance(RESOURCE_2_NAME, model2).deploy();
assertEquals(1, repositoryService.getDeploymentResources(deployment2.getId()).size());
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 1);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 1);
// when
Deployment deployment3 = repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-3").addDeploymentResources(deployment1.getId()).addDeploymentResources(deployment2.getId()).deploy();
assertEquals(2, repositoryService.getDeploymentResources(deployment3.getId()).size());
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 2);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 2);
deleteDeployments(deployment1, deployment2, deployment3);
}
use of org.camunda.bpm.engine.repository.ProcessDefinitionQuery in project camunda-bpm-platform by camunda.
the class RedeploymentTest method testRedeployAllDeploymentResources.
public void testRedeployAllDeploymentResources() {
// given
ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
BpmnModelInstance model1 = createProcessWithServiceTask(PROCESS_1_KEY);
BpmnModelInstance model2 = createProcessWithUserTask(PROCESS_2_KEY);
// first deployment
Deployment deployment1 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_1_NAME, model1).addModelInstance(RESOURCE_2_NAME, model2).deploy();
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 1);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 1);
// second deployment
Deployment deployment2 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_1_NAME, model2).addModelInstance(RESOURCE_2_NAME, model1).deploy();
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 2);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 2);
// when
Deployment deployment3 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addDeploymentResources(deployment1.getId()).deploy();
// then
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 3);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 3);
deleteDeployments(deployment1, deployment2, deployment3);
}
Aggregations