Search in sources :

Example 6 with Person

use of org.jbpm.kie.test.objects.Person in project jbpm by kiegroup.

the class BPMN2DataServicesReferencesTest method runScriptTest.

private void runScriptTest(String processId) {
    Assume.assumeTrue("Skip script/expr tests", loadJavaMvelScriptProcesses);
    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);
    Map<String, Object> params = new HashMap<String, Object>(1);
    params.put("person", person);
    Long procId = startProcess(deploymentId, processId, params);
    assertNull("Process instance did not complete", processService.getProcessInstance(procId));
    assertTrue("Script did not modify variable!", person.getLog().startsWith("Hello"));
    Collection<String> javaClasses = bpmn2Service.getJavaClasses(deploymentId, processId);
    assertNotNull("Null set of java classes", javaClasses);
    assertFalse("Empty set of java classes", javaClasses.isEmpty());
    assertEquals("Number java classes", 4, javaClasses.size());
    String[] expected = { "java.lang.Object", Person.class.getCanonicalName(), OtherPerson.class.getCanonicalName(), Thing.class.getCanonicalName() };
    Set<String> expectedClasses = new HashSet<String>(Arrays.asList(expected));
    for (String className : javaClasses) {
        assertTrue("Class name is not qualified: " + className, className.contains("."));
        assertTrue("Unexpected class: " + className, expectedClasses.remove(className));
    }
    if (!expectedClasses.isEmpty()) {
        fail("Expected class not found to be referenced: " + expectedClasses.iterator().next());
    }
}
Also used : HashMap(java.util.HashMap) OtherPerson(org.jbpm.kie.test.objects.OtherPerson) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) Person(org.jbpm.kie.test.objects.Person) OtherPerson(org.jbpm.kie.test.objects.OtherPerson) Thing(org.jbpm.kie.test.objects.Thing) HashSet(java.util.HashSet)

Aggregations

OtherPerson (org.jbpm.kie.test.objects.OtherPerson)6 Person (org.jbpm.kie.test.objects.Person)6 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)6 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)5 Test (org.junit.Test)5 KieSession (org.kie.api.runtime.KieSession)4 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Thing (org.jbpm.kie.test.objects.Thing)2 ArrayList (java.util.ArrayList)1 SystemOutWorkItemHandler (org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler)1 Ignore (org.junit.Ignore)1