Search in sources :

Example 16 with ProcessDefinition

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

the class FormProviderServiceImplTest method testGetFormDisplayTask.

@Test
public void testGetFormDisplayTask() {
    long taskId = 1;
    final TaskImpl task = new TaskImpl();
    task.setId(taskId);
    task.setName("TaskName");
    final TaskDataImpl taskData = new TaskDataImpl();
    final String deploymentId = "org.jbpm";
    taskData.setDeploymentId(deploymentId);
    final String processId = "org.jbpm.evaluation";
    taskData.setProcessId(processId);
    task.setTaskData(taskData);
    when(taskService.getTaskById(taskId)).thenReturn(task);
    final ProcessDefinition processDefinition = mock(ProcessDefinition.class);
    when(dataService.getProcessesByDeploymentIdProcessId(deploymentId, processId)).thenReturn(processDefinition);
    final String form = formProviderService.getFormDisplayTask(1);
    assertEquals("", form);
    verify(dataService).getProcessesByDeploymentIdProcessId(deploymentId, processId);
    verify(formProvider).render(eq(task.getName()), eq(task), eq(processDefinition), anyMap());
}
Also used : TaskImpl(org.jbpm.services.task.impl.model.TaskImpl) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) Matchers.anyString(org.mockito.Matchers.anyString) TaskDataImpl(org.jbpm.services.task.impl.model.TaskDataImpl) Test(org.junit.Test)

Example 17 with ProcessDefinition

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

the class BPMN2DataServicesReferencesTest method testCallActivity.

@Test
public void testCallActivity() throws IOException {
    Assume.assumeTrue("Skip call activity tests", loadCallActivityProcesses);
    String processId = PROC_ID_CALL_ACTIVITY;
    ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentId, processId);
    assertNotNull(procDef);
    // run process (to verify that it works)
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("x", "oldValue");
    Long procId = startProcess(deploymentId, processId, params);
    ProcessInstance procInst = processService.getProcessInstance(procId);
    assertNull(procInst);
    AuditService auditService = deploymentService.getRuntimeManager(deploymentId).getRuntimeEngine(null).getAuditService();
    List<? extends VariableInstanceLog> logs = auditService.findVariableInstances(procId);
    boolean foundY = false;
    for (VariableInstanceLog log : logs) {
        if (log.getVariableId().equals("y") && log.getValue().equals("new value")) {
            foundY = true;
        }
    }
    assertTrue("Parent process did not call sub process", foundY);
    // check information about process
    Collection<String> refProcesses = bpmn2Service.getReusableSubProcesses(deploymentId, processId);
    assertNotNull("Null set of referenced processes", refProcesses);
    assertFalse("Empty set of referenced processes", refProcesses.isEmpty());
    assertEquals("Number referenced processes", 1, refProcesses.size());
    assertEquals("Imported class in processes", PROC_ID_ACTIVITY_CALLED, refProcesses.iterator().next());
}
Also used : VariableInstanceLog(org.kie.api.runtime.manager.audit.VariableInstanceLog) HashMap(java.util.HashMap) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) AuditService(org.kie.api.runtime.manager.audit.AuditService) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 18 with ProcessDefinition

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

the class BPMN2DataServicesReferencesTest method testBusinessRuleTask.

@Test
public void testBusinessRuleTask() throws IOException {
    Assume.assumeTrue("Skip business rule tests", loadBusinesRuleProcesses);
    String processId = PROC_ID_BUSINESS_RULE;
    ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentId, processId);
    assertNotNull(procDef);
    // check that process runs
    Person person = new Person();
    person.setName("Max Rockatansky");
    person.setId(1979l);
    person.setTime(3l);
    KieSession ksession = deploymentService.getRuntimeManager(deploymentId).getRuntimeEngine(null).getKieSession();
    List<String> list = new ArrayList<String>();
    ksession.setGlobal("list", list);
    Long procId = startProcess(deploymentId, processId);
    String ruleOutput = "Executed";
    assertEquals("Global did not contain output from rule!", 1, list.size());
    assertEquals("Global did not contain correct output of rule!", ruleOutput, list.get(0));
    ProcessInstance procInst = processService.getProcessInstance(procId);
    assertNull("Process instance did not complete!", procInst);
    // check information about process
    Collection<String> refRules = bpmn2Service.getRuleSets(deploymentId, processId);
    assertNotNull("Null set of imported rules", refRules);
    assertFalse("Empty set of imported rules", refRules.isEmpty());
    assertEquals("Number imported rules", 1, refRules.size());
    assertEquals("Name of imported ruleset", RULE_BUSINESS_RULE_PROCESS, refRules.iterator().next());
    refRules = procDef.getReferencedRules();
    assertNotNull("Null set of imported rules", refRules);
    assertFalse("Empty set of imported rules", refRules.isEmpty());
    assertEquals("Number imported rules", 1, refRules.size());
    assertEquals("Name of imported ruleset", RULE_BUSINESS_RULE_PROCESS, refRules.iterator().next());
}
Also used : ArrayList(java.util.ArrayList) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Person(org.jbpm.kie.test.objects.Person) OtherPerson(org.jbpm.kie.test.objects.OtherPerson) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 19 with ProcessDefinition

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

the class BPMN2DataServicesReferencesTest method testCallActivityByName.

@Test
public void testCallActivityByName() throws IOException {
    Assume.assumeTrue("Skip call activity tests", loadCallActivityProcesses);
    String processId = PROC_ID_CALL_ACTIVITY_BY_NAME;
    ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentId, processId);
    assertNotNull(procDef);
    // run process (to verify that it works)
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("x", "oldValue");
    Long procId = startProcess(deploymentId, processId, params);
    ProcessInstance procInst = processService.getProcessInstance(procId);
    assertNull(procInst);
    AuditService auditService = deploymentService.getRuntimeManager(deploymentId).getRuntimeEngine(null).getAuditService();
    List<? extends VariableInstanceLog> logs = auditService.findVariableInstances(procId);
    boolean foundY = false;
    for (VariableInstanceLog log : logs) {
        if (log.getVariableId().equals("y") && log.getValue().equals("new value")) {
            foundY = true;
        }
    }
    assertTrue("Parent process did not call sub process", foundY);
    // check information about process
    Collection<String> refProcesses = bpmn2Service.getReusableSubProcesses(deploymentId, processId);
    assertNotNull("Null set of referenced processes", refProcesses);
    assertFalse("Empty set of referenced processes", refProcesses.isEmpty());
    assertEquals("Number referenced processes", 1, refProcesses.size());
    assertEquals("Imported class in processes", PROC_ID_ACTIVITY_CALLED, refProcesses.iterator().next());
}
Also used : VariableInstanceLog(org.kie.api.runtime.manager.audit.VariableInstanceLog) HashMap(java.util.HashMap) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) AuditService(org.kie.api.runtime.manager.audit.AuditService) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 20 with ProcessDefinition

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

the class BPMN2DataServicesTest method testHumanTaskProcessBeforeAndAfterUndeploy.

@Test
public void testHumanTaskProcessBeforeAndAfterUndeploy() 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");
    // now let's undeploy the unit
    deploymentService.undeploy(deploymentUnit);
    try {
        bpmn2Service.getProcessDefinition(deploymentUnit.getIdentifier(), processId);
        fail("DeploymentNotFoundException was not thrown");
    } catch (DeploymentNotFoundException e) {
    // expected
    }
}
Also used : DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) 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)

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