Search in sources :

Example 41 with ProcessDefinition

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

the class BPMN2DataServicesTest method testObjectVariable.

@Test
public void testObjectVariable() throws IOException {
    assertNotNull(deploymentService);
    DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    String processId = "ObjectVariableProcess";
    ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentUnit.getIdentifier(), processId);
    assertNotNull(procDef);
    assertEquals(procDef.getId(), "ObjectVariableProcess");
    assertEquals(procDef.getName(), "ObjectVariableProcess");
    assertEquals(procDef.getKnowledgeType(), "PROCESS");
    assertEquals(procDef.getPackageName(), "defaultPackage");
    assertEquals(procDef.getType(), "RuleFlow");
    assertEquals(procDef.getVersion(), "1");
    Map<String, String> processData = bpmn2Service.getProcessVariables(deploymentUnit.getIdentifier(), processId);
    assertEquals("String", processData.get("type"));
    assertEquals("Object", processData.get("myobject"));
    assertEquals(2, processData.keySet().size());
}
Also used : ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) 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 42 with ProcessDefinition

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

the class BPMN2DataServicesTest method testHumanTaskProcess.

@Test
public void testHumanTaskProcess() throws IOException {
    assertNotNull(deploymentService);
    DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    String processId = "org.jbpm.writedocument";
    ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentUnit.getIdentifier(), processId);
    assertNotNull(procDef);
    assertEquals(procDef.getId(), "org.jbpm.writedocument");
    assertEquals(procDef.getName(), "humanTaskSample");
    assertEquals(procDef.getKnowledgeType(), "PROCESS");
    assertEquals(procDef.getPackageName(), "defaultPackage");
    assertEquals(procDef.getType(), "RuleFlow");
    assertEquals(procDef.getVersion(), "3");
    Map<String, String> processData = bpmn2Service.getProcessVariables(deploymentUnit.getIdentifier(), processId);
    assertEquals("String", processData.get("approval_document"));
    assertEquals("String", processData.get("approval_translatedDocument"));
    assertEquals("String", processData.get("approval_reviewComment"));
    assertEquals(3, processData.keySet().size());
    Collection<UserTaskDefinition> userTasks = bpmn2Service.getTasksDefinitions(deploymentUnit.getIdentifier(), processId);
    assertNotNull(userTasks);
    assertEquals(3, userTasks.size());
    Map<String, UserTaskDefinition> tasksByName = new HashMap<String, UserTaskDefinition>();
    for (UserTaskDefinition userTask : userTasks) {
        tasksByName.put(userTask.getName(), userTask);
    }
    assertTrue(tasksByName.containsKey("Write a Document"));
    assertTrue(tasksByName.containsKey("Translate Document"));
    assertTrue(tasksByName.containsKey("Review Document"));
    UserTaskDefinition task = tasksByName.get("Write a Document");
    assertEquals(true, task.isSkippable());
    assertEquals("Write a Document", task.getName());
    assertEquals(9, task.getPriority().intValue());
    assertEquals("Write a Document", task.getComment());
    assertEquals("Write a Document", task.getFormName());
    assertEquals("2", task.getId());
    task = tasksByName.get("Translate Document");
    assertEquals(true, task.isSkippable());
    assertEquals("Translate Document", task.getName());
    assertEquals(0, task.getPriority().intValue());
    assertEquals("", task.getComment());
    assertEquals("Translate Document", task.getFormName());
    assertEquals("4", task.getId());
    task = tasksByName.get("Review Document");
    assertEquals(false, task.isSkippable());
    assertEquals("Review Document", task.getName());
    assertEquals(0, task.getPriority().intValue());
    assertEquals("", task.getComment());
    assertEquals("Review Document", task.getFormName());
    assertEquals("5", task.getId());
    Map<String, String> taskInputMappings = bpmn2Service.getTaskInputMappings(deploymentUnit.getIdentifier(), processId, "Write a Document");
    assertEquals(4, taskInputMappings.keySet().size());
    Map<String, String> taskOutputMappings = bpmn2Service.getTaskOutputMappings(deploymentUnit.getIdentifier(), processId, "Write a Document");
    assertEquals(1, taskOutputMappings.keySet().size());
    Map<String, Collection<String>> associatedEntities = bpmn2Service.getAssociatedEntities(deploymentUnit.getIdentifier(), processId);
    assertEquals(3, associatedEntities.keySet().size());
}
Also used : HashMap(java.util.HashMap) UserTaskDefinition(org.jbpm.services.api.model.UserTaskDefinition) Collection(java.util.Collection) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) 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 43 with ProcessDefinition

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

the class DeploymentServiceTest 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());
    assertEquals(0, ((DeployedUnitImpl) deployed).getDeployedClasses().size());
    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) 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) DeployedUnitImpl(org.jbpm.kie.services.impl.DeployedUnitImpl) 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 44 with ProcessDefinition

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

the class DeploymentServiceTest method testDeploymentOfProcessesWithActivation.

@Test
public void testDeploymentOfProcessesWithActivation() {
    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());
    assertTrue(deployed.isActive());
    assertEquals(0, ((DeployedUnitImpl) deployed).getDeployedClasses().size());
    assertNotNull(runtimeDataService);
    Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processes);
    assertEquals(5, processes.size());
    RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
    assertNotNull(manager);
    // then deactivate it
    deploymentService.deactivate(deploymentUnit.getIdentifier());
    deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    assertNotNull(deployed);
    assertNotNull(deployed.getDeploymentUnit());
    assertNotNull(deployed.getRuntimeManager());
    assertFalse(deployed.isActive());
    processes = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processes);
    assertEquals(0, processes.size());
    // and not activate it again
    deploymentService.activate(deploymentUnit.getIdentifier());
    deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    assertNotNull(deployed);
    assertNotNull(deployed.getDeploymentUnit());
    assertNotNull(deployed.getRuntimeManager());
    assertTrue(deployed.isActive());
    processes = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processes);
    assertEquals(5, processes.size());
}
Also used : 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) DeployedUnitImpl(org.jbpm.kie.services.impl.DeployedUnitImpl) 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 45 with ProcessDefinition

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

the class DeploymentServiceTest method testDeploymentOfMultipleVersions.

@Test
public void testDeploymentOfMultipleVersions() {
    assertNotNull(deploymentService);
    DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    DeploymentUnit deploymentUnit3 = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, "1.1.0-SNAPSHOT");
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    deploymentService.deploy(deploymentUnit3);
    units.add(deploymentUnit3);
    DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    assertNotNull(deployed);
    assertNotNull(deployed.getDeploymentUnit());
    assertNotNull(deployed.getRuntimeManager());
    assertEquals(0, ((DeployedUnitImpl) deployed).getDeployedClasses().size());
    DeployedUnit deployed3 = deploymentService.getDeployedUnit(deploymentUnit3.getIdentifier());
    assertNotNull(deployed3);
    assertNotNull(deployed3.getDeploymentUnit());
    assertNotNull(deployed3.getRuntimeManager());
    assertEquals(1, ((DeployedUnitImpl) deployed3).getDeployedClasses().size());
    assertNotNull(runtimeDataService);
    Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processes);
    assertEquals(10, processes.size());
    DeployedUnit deployedLatest = deploymentService.getDeployedUnit(GROUP_ID + ":" + ARTIFACT_ID + ":LATEST");
    assertNotNull(deployedLatest);
    assertNotNull(deployedLatest.getDeploymentUnit());
    assertNotNull(deployedLatest.getRuntimeManager());
    assertEquals(deploymentUnit3.getIdentifier(), deployedLatest.getDeploymentUnit().getIdentifier());
}
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) DeployedUnitImpl(org.jbpm.kie.services.impl.DeployedUnitImpl) 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)

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