Search in sources :

Example 11 with ProcessDefinition

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

the class RuntimeDataServiceImplTest method testGetProcessByDeploymentIdAndProcessId.

@Test
public void testGetProcessByDeploymentIdAndProcessId() {
    ProcessDefinition definition = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(definition);
    assertEquals("org.jbpm.writedocument", definition.getId());
    String origVer = deploymentUnit.getVersion();
    deploymentUnit.setVersion("LATEST");
    definition = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(definition);
    assertEquals("org.jbpm.writedocument", definition.getId());
    deploymentUnit.setVersion(origVer);
}
Also used : ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 12 with ProcessDefinition

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

the class FilteredKModuleDeploymentServiceTest method testDeploymentOfProcessesWildcardPackage.

@Test
public void testDeploymentOfProcessesWildcardPackage() {
    prepare("customer.*");
    assertNotNull(deploymentService);
    DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION, "KBase-test", "ksession-test");
    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 + ":" + "KBase-test" + ":" + "ksession-test", 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 13 with ProcessDefinition

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

the class IdentityProviderAwareProcessListenerTest method init.

@Before
public void init() {
    configureServices();
    final KieServices ks = KieServices.Factory.get();
    ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
    final List<String> processes = Collections.singletonList("repo/processes/general/humanTask.bpmn");
    final InternalKieModule kJar1 = createKieJar(ks, releaseId, processes);
    final File pom = new File("target/kmodule", "pom.xml");
    pom.getParentFile().mkdir();
    try (FileOutputStream fs = new FileOutputStream(pom)) {
        fs.write(getPom(releaseId).getBytes());
    } catch (Exception e) {
        e.printStackTrace();
    }
    getKieMavenRepository().deployArtifact(releaseId, kJar1, pom);
    deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    final DeploymentDescriptor descriptor = new DeploymentDescriptorImpl();
    descriptor.getBuilder().addEventListener(new NamedObjectModel("mvel", "processIdentity", "new org.jbpm.kie.services.impl.IdentityProviderAwareProcessListener(ksession)"));
    deploymentUnit.setDeploymentDescriptor(descriptor);
    deploymentService.deploy(deploymentUnit);
    final DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    assertNotNull(deployed);
    assertNotNull(deployed.getDeploymentUnit());
    assertNotNull(runtimeDataService);
    Collection<ProcessDefinition> processDefinitions = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processDefinitions);
    assertEquals(1, processDefinitions.size());
}
Also used : DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) KieServices(org.kie.api.KieServices) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) ReleaseId(org.kie.api.builder.ReleaseId) QueryContext(org.kie.api.runtime.query.QueryContext) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) FileOutputStream(java.io.FileOutputStream) File(java.io.File) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule) Before(org.junit.Before)

Example 14 with ProcessDefinition

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

the class KModuleDeploymentServiceTest method testDeploymentOfProcesses.

@Test
public void testDeploymentOfProcesses() {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION, "KBase-test", "ksession-test");
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    assertNotNull(deploymentUnit.getDeploymentDescriptor());
    DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    assertNotNull(deployed);
    assertNotNull(deployed.getDeploymentUnit());
    assertNotNull(deployed.getRuntimeManager());
    assertNull(deployed.getDeployedAssetLocation("customtask"));
    assertEquals(GROUP_ID + ":" + ARTIFACT_ID + ":" + VERSION + ":" + "KBase-test" + ":" + "ksession-test", 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) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) QueryContext(org.kie.api.runtime.query.QueryContext) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 15 with ProcessDefinition

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

the class KModuleWithDependenciesDeploymentServiceTest method testDeploymentOfProcesses.

@Test
public void testDeploymentOfProcesses() throws Exception {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION, "defaultKieBase", "defaultKieSession");
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    assertNotNull(deployed);
    assertNotNull(deployed.getDeploymentUnit());
    assertNotNull(deployed.getRuntimeManager());
    assertEquals("org.jbpm.test:jbpm-module:1.0.0:defaultKieBase:defaultKieSession", deployed.getDeploymentUnit().getIdentifier());
    assertTrue(deployed instanceof DeployedUnitImpl);
    assertEquals(2, ((DeployedUnitImpl) deployed).getDeployedClasses().size());
    List<String> classnames = new ArrayList<String>();
    for (Class<?> clazz : ((DeployedUnitImpl) deployed).getDeployedClasses()) {
        classnames.add(clazz.getName());
    }
    assertTrue(classnames.contains("org.jbpm.data.rest.CustomDataObject"));
    assertTrue(classnames.contains("org.jbpm.test.Person"));
    assertNotNull(runtimeDataService);
    Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processes);
    assertEquals(1, processes.size());
    RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
    assertNotNull(manager);
    RuntimeEngine engine = manager.getRuntimeEngine(EmptyContext.get());
    assertNotNull(engine);
    Class<?> clazz = Class.forName("org.jbpm.test.Person", true, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
    Object instance = clazz.newInstance();
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("person", instance);
    ProcessInstance processInstance = engine.getKieSession().startProcess("testkjar.src.main.resources.process", params);
    assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
    List<TaskSummary> tasks = engine.getTaskService().getTasksOwned("salaboy", "en-UK");
    assertEquals(1, tasks.size());
    long taskId = tasks.get(0).getId();
    Map<String, Object> content = ((InternalTaskService) engine.getTaskService()).getTaskContent(taskId);
    assertTrue(content.containsKey("personIn"));
    Object person = content.get("personIn");
    assertEquals(clazz.getName(), person.getClass().getName());
    engine.getTaskService().start(taskId, "salaboy");
    Map<String, Object> data = new HashMap<String, Object>();
    data.put("personOut", instance);
    engine.getTaskService().complete(taskId, "salaboy", data);
    processInstance = engine.getKieSession().getProcessInstance(processInstance.getId());
    assertNull(processInstance);
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) HashMap(java.util.HashMap) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) ArrayList(java.util.ArrayList) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) InternalTaskService(org.kie.internal.task.api.InternalTaskService) QueryContext(org.kie.api.runtime.query.QueryContext) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) TaskSummary(org.kie.api.task.model.TaskSummary) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) DeployedUnitImpl(org.jbpm.kie.services.impl.DeployedUnitImpl) 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