Search in sources :

Example 31 with ProcessDefinition

use of org.jbpm.services.api.model.ProcessDefinition in project jbpm by kiegroup.

the class FilteredKModuleDeploymentServiceTest method testDeploymentOfProcessesFromCustomerPackageDeafultKBase.

@Test
public void testDeploymentOfProcessesFromCustomerPackageDeafultKBase() {
    prepare("customer.repo.processes.general");
    assertNotNull(deploymentService);
    DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    assertNotNull(deployed);
    assertNotNull(deployed.getDeploymentUnit());
    assertNotNull(deployed.getRuntimeManager());
    assertEquals(GROUP_ID + ":" + ARTIFACT_ID + ":" + VERSION, deployed.getDeploymentUnit().getIdentifier());
    assertNotNull(runtimeDataService);
    Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processes);
    assertEquals(2, processes.size());
    processes = runtimeDataService.getProcessesByFilter("custom", new QueryContext());
    assertNotNull(processes);
    assertEquals(1, processes.size());
    processes = runtimeDataService.getProcessesByDeploymentId(deploymentUnit.getIdentifier(), new QueryContext());
    assertNotNull(processes);
    assertEquals(2, processes.size());
    ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
    assertNotNull(process);
}
Also used : DeployedUnit(org.jbpm.services.api.model.DeployedUnit) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) QueryContext(org.kie.api.runtime.query.QueryContext) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 32 with ProcessDefinition

use of org.jbpm.services.api.model.ProcessDefinition in project jbpm by kiegroup.

the class KModuleDeploymentServiceTest method testDeploymentOfProcessesOnDefaultKbaseAndKsession.

@Test
public void testDeploymentOfProcessesOnDefaultKbaseAndKsession() {
    assertNotNull(deploymentService);
    DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    assertNotNull(deployed);
    assertNotNull(deployed.getDeploymentUnit());
    assertNotNull(deployed.getRuntimeManager());
    assertNull(deployed.getDeployedAssetLocation("customtask"));
    assertEquals(GROUP_ID + ":" + ARTIFACT_ID + ":" + VERSION, deployed.getDeploymentUnit().getIdentifier());
    assertNotNull(runtimeDataService);
    Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processes);
    assertEquals(3, processes.size());
    processes = runtimeDataService.getProcessesByFilter("custom", new QueryContext());
    assertNotNull(processes);
    assertEquals(1, processes.size());
    processes = runtimeDataService.getProcessesByDeploymentId(deploymentUnit.getIdentifier(), new QueryContext());
    assertNotNull(processes);
    assertEquals(3, processes.size());
    ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
    assertNotNull(process);
    RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
    assertNotNull(manager);
    RuntimeEngine engine = manager.getRuntimeEngine(EmptyContext.get());
    assertNotNull(engine);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("id", "test");
    ProcessInstance processInstance = engine.getKieSession().startProcess("customtask", params);
    assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
    checkFormsDeployment(deploymentUnit.getIdentifier());
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) HashMap(java.util.HashMap) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) QueryContext(org.kie.api.runtime.query.QueryContext) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 33 with ProcessDefinition

use of org.jbpm.services.api.model.ProcessDefinition in project jbpm by kiegroup.

the class PostDeploymentServiceTest method testDeploymentOfProcesses.

@Test
public void testDeploymentOfProcesses() {
    assertNotNull(deploymentService);
    DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    assertNotNull(deployed);
    assertNotNull(deployed.getDeploymentUnit());
    assertNotNull(deployed.getRuntimeManager());
    assertNotNull(runtimeDataService);
    Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processes);
    assertEquals(5, processes.size());
    processes = runtimeDataService.getProcessesByFilter("custom", new QueryContext());
    assertNotNull(processes);
    assertEquals(1, processes.size());
    processes = runtimeDataService.getProcessesByDeploymentId(deploymentUnit.getIdentifier(), new QueryContext());
    assertNotNull(processes);
    assertEquals(5, processes.size());
    ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
    assertNotNull(process);
    RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
    assertNotNull(manager);
    RuntimeEngine engine = manager.getRuntimeEngine(EmptyContext.get());
    assertNotNull(engine);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("id", "test");
    ProcessInstance processInstance = engine.getKieSession().startProcess("customtask", params);
    assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) HashMap(java.util.HashMap) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) QueryContext(org.kie.api.runtime.query.QueryContext) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 34 with ProcessDefinition

use of org.jbpm.services.api.model.ProcessDefinition in project jbpm by kiegroup.

the class RuntimeDataServiceImplTest method testGetProcessesSortByProcessVersion.

@Test
public void testGetProcessesSortByProcessVersion() {
    Collection<ProcessDefinition> definitions = runtimeDataService.getProcesses(new QueryContext("ProcessVersion", true));
    assertNotNull(definitions);
    assertEquals(5, definitions.size());
    List<String> expectedProcessIds = new ArrayList<String>();
    expectedProcessIds.add("UserTask");
    expectedProcessIds.add("org.jboss.qa.bpms.HumanTask");
    expectedProcessIds.add("AdHocSubProcess");
    expectedProcessIds.add("org.jbpm.writedocument.empty");
    expectedProcessIds.add("org.jbpm.writedocument");
    int index = 0;
    for (ProcessDefinition def : definitions) {
        assertEquals(def.getId(), expectedProcessIds.get(index));
        index++;
    }
}
Also used : ArrayList(java.util.ArrayList) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 35 with ProcessDefinition

use of org.jbpm.services.api.model.ProcessDefinition in project jbpm by kiegroup.

the class BPMN2DataServiceImplMultiThreadTest method testBuildProcessDefinitionConcurrent.

@Test
public void testBuildProcessDefinitionConcurrent() throws Exception {
    final List<ProcessDefinition> defs = new ArrayList<ProcessDefinition>();
    byte[] process1 = IoUtils.readBytesFromInputStream(this.getClass().getResourceAsStream("/repo/processes/general/customtask.bpmn"));
    byte[] process2 = IoUtils.readBytesFromInputStream(this.getClass().getResourceAsStream("/repo/processes/general/humanTask.bpmn"));
    final String process1Content = new String(process1, "UTF-8");
    final String process2Content = new String(process2, "UTF-8");
    final CyclicBarrier threadsFinishedBarrier = new CyclicBarrier(3);
    Thread t1 = new Thread(new Runnable() {

        @Override
        public void run() {
            ProcessDefinition def = bpmn2Service.buildProcessDefinition("test", process1Content, null, true);
            defs.add(def);
            waitForTheOtherThreads(threadsFinishedBarrier);
        }
    });
    Thread t2 = new Thread(new Runnable() {

        @Override
        public void run() {
            ProcessDefinition def = bpmn2Service.buildProcessDefinition("test", process2Content, null, true);
            defs.add(def);
            waitForTheOtherThreads(threadsFinishedBarrier);
        }
    });
    t1.start();
    t2.start();
    waitForTheOtherThreads(threadsFinishedBarrier);
    assertEquals(2, defs.size());
}
Also used : ArrayList(java.util.ArrayList) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) CyclicBarrier(java.util.concurrent.CyclicBarrier) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Aggregations

ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)50 Test (org.junit.Test)44 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)29 QueryContext (org.kie.api.runtime.query.QueryContext)27 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)22 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)19 DeploymentUnit (org.jbpm.services.api.model.DeploymentUnit)19 HashMap (java.util.HashMap)14 ArrayList (java.util.ArrayList)12 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)12 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)9 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)7 DeployedUnitImpl (org.jbpm.kie.services.impl.DeployedUnitImpl)6 OtherPerson (org.jbpm.kie.test.objects.OtherPerson)6 Person (org.jbpm.kie.test.objects.Person)6 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)6 KieSession (org.kie.api.runtime.KieSession)4 AbstractEJBServicesTest (org.jbpm.test.container.AbstractEJBServicesTest)3 DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)3 File (java.io.File)2