Search in sources :

Example 1 with ProcessDefinitionQuery

use of org.activiti.engine.repository.ProcessDefinitionQuery in project Activiti by Activiti.

the class ProcessDefinitionQueryByLatestTest method testQueryByLatestAndVersion.

public void testQueryByLatestAndVersion() throws Exception {
    // Deploy
    List<String> xmlFileNameList = Arrays.asList("version_testProcess1_one.bpmn20.xml", "version_testProcess1_two.bpmn20.xml", "version_testProcess2_one.bpmn20.xml");
    List<String> deploymentIdList = deploy(xmlFileNameList);
    // version
    ProcessDefinitionQuery nameQuery = repositoryService.createProcessDefinitionQuery().processDefinitionVersion(1).latestVersion();
    List<ProcessDefinition> processDefinitions = nameQuery.list();
    assertEquals(1, processDefinitions.size());
    assertEquals("testProcess2", processDefinitions.get(0).getKey());
    // Undeploy
    unDeploy(deploymentIdList);
}
Also used : ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition)

Example 2 with ProcessDefinitionQuery

use of org.activiti.engine.repository.ProcessDefinitionQuery in project Activiti by Activiti.

the class ProcessDefinitionQueryByLatestTest method testQueryByLatestAndId.

public void testQueryByLatestAndId() throws Exception {
    // Deploy
    List<String> xmlFileNameList = Arrays.asList("name_testProcess1_one.bpmn20.xml", "name_testProcess1_two.bpmn20.xml", "name_testProcess2_one.bpmn20.xml");
    List<String> deploymentIdList = deploy(xmlFileNameList);
    List<String> processDefinitionIdList = new ArrayList<String>();
    for (String deploymentId : deploymentIdList) {
        String processDefinitionId = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).list().get(0).getId();
        processDefinitionIdList.add(processDefinitionId);
    }
    ProcessDefinitionQuery idQuery1 = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionIdList.get(0)).latestVersion();
    List<ProcessDefinition> processDefinitions = idQuery1.list();
    assertEquals(0, processDefinitions.size());
    ProcessDefinitionQuery idQuery2 = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionIdList.get(1)).latestVersion();
    processDefinitions = idQuery2.list();
    assertEquals(1, processDefinitions.size());
    assertEquals("testProcess1", processDefinitions.get(0).getKey());
    ProcessDefinitionQuery idQuery3 = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionIdList.get(2)).latestVersion();
    processDefinitions = idQuery3.list();
    assertEquals(1, processDefinitions.size());
    assertEquals("testProcess2", processDefinitions.get(0).getKey());
    // Undeploy
    unDeploy(deploymentIdList);
}
Also used : ArrayList(java.util.ArrayList) ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition)

Example 3 with ProcessDefinitionQuery

use of org.activiti.engine.repository.ProcessDefinitionQuery in project Activiti by Activiti.

the class ProcessDefinitionQueryByLatestTest method testQueryByLatestAndDeploymentId.

public void testQueryByLatestAndDeploymentId() throws Exception {
    // Deploy
    List<String> xmlFileNameList = Arrays.asList("name_testProcess1_one.bpmn20.xml", "name_testProcess1_two.bpmn20.xml", "name_testProcess2_one.bpmn20.xml");
    List<String> deploymentIdList = deploy(xmlFileNameList);
    // deploymentId
    ProcessDefinitionQuery deploymentQuery1 = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentIdList.get(0)).latestVersion();
    List<ProcessDefinition> processDefinitions = deploymentQuery1.list();
    assertEquals(0, processDefinitions.size());
    ProcessDefinitionQuery deploymentQuery2 = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentIdList.get(1)).latestVersion();
    processDefinitions = deploymentQuery2.list();
    assertEquals(1, processDefinitions.size());
    assertEquals("testProcess1", processDefinitions.get(0).getKey());
    // Undeploy
    unDeploy(deploymentIdList);
}
Also used : ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition)

Example 4 with ProcessDefinitionQuery

use of org.activiti.engine.repository.ProcessDefinitionQuery in project Activiti by Activiti.

the class ProcessDefinitionQueryTest method testQueryByInvalidDeploymentId.

public void testQueryByInvalidDeploymentId() {
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().deploymentId("invalid");
    verifyQueryResults(query, 0);
    try {
        repositoryService.createProcessDefinitionQuery().deploymentId(null);
        fail();
    } catch (ActivitiIllegalArgumentException e) {
    }
}
Also used : ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery)

Example 5 with ProcessDefinitionQuery

use of org.activiti.engine.repository.ProcessDefinitionQuery in project Activiti by Activiti.

the class ProcessDefinitionQueryTest method testQueryByName.

public void testQueryByName() {
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().processDefinitionName("Two");
    verifyQueryResults(query, 1);
    query = repositoryService.createProcessDefinitionQuery().processDefinitionName("One");
    verifyQueryResults(query, 2);
}
Also used : ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery)

Aggregations

ProcessDefinitionQuery (org.activiti.engine.repository.ProcessDefinitionQuery)29 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)7 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)5 SysBpmnResourceVO (com.netsteadfast.greenstep.vo.SysBpmnResourceVO)1 ArrayList (java.util.ArrayList)1 RepositoryService (org.activiti.engine.RepositoryService)1 ProcessDefinitionImpl (org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl)1 DeploymentQuery (org.activiti.engine.repository.DeploymentQuery)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1 Task (org.activiti.engine.task.Task)1 Test (org.junit.Test)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1