use of org.jbpm.kie.test.objects.Person 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());
}
use of org.jbpm.kie.test.objects.Person in project jbpm by kiegroup.
the class BPMN2DataServicesReferencesTest method testDroolsScriptWithQualifiedClass.
@Test
// TODO!
@Ignore
public void testDroolsScriptWithQualifiedClass() throws Exception {
Assume.assumeTrue("Skip script/expr tests", loadJavaMvelScriptProcesses);
String processId = PROC_ID_RULE_SCRIPT_QUALIFIED_CLASS;
ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentId, processId);
assertNotNull(procDef);
// check that process runs
Person person = new Person();
person.setName("Max");
person.setId(1979l);
person.setTime(3l);
KieSession ksession = deploymentService.getRuntimeManager(deploymentId).getRuntimeEngine(null).getKieSession();
ksession.insert(person);
ksession.insert(new Thing());
ksession.insert(new OtherPerson(person));
ksession.insert(person.getName());
ksession.insert(person.getId());
Long procId = startProcess(deploymentId, processId);
assertNull("Process instance did not complete:", processService.getProcessInstance(procId));
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());
}
}
use of org.jbpm.kie.test.objects.Person in project jbpm by kiegroup.
the class BPMN2DataServicesReferencesTest method testImport.
@Test
public void testImport() throws IOException {
Assume.assumeTrue("Skip import/global tests", loadGlobalImportProcesses);
String processId = PROC_ID_IMPORT;
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>();
params.put("person", person);
Long procId = startProcess(deploymentId, processId, params);
ProcessInstance procInst = processService.getProcessInstance(procId);
assertNull(procInst);
// verify process information
Collection<String> refClasses = bpmn2Service.getJavaClasses(deploymentId, processId);
assertNotNull("Null set of referenced classes", refClasses);
assertFalse("Empty set of referenced classes", refClasses.isEmpty());
assertEquals("Number referenced classes", 1, refClasses.size());
assertEquals("Imported class in process", refClasses.iterator().next(), Person.class.getName());
}
use of org.jbpm.kie.test.objects.Person in project jbpm by kiegroup.
the class BPMN2DataServicesReferencesTest method testGlobal.
@Test
public void testGlobal() throws IOException {
Assume.assumeTrue("Skip import/global tests", loadGlobalImportProcesses);
String processId = PROC_ID_GLOBAL;
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();
ksession.setGlobal("person", person);
ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new SystemOutWorkItemHandler());
Long procId = startProcess(deploymentId, processId);
ProcessInstance procInst = processService.getProcessInstance(procId);
assertNull(procInst);
String log = person.getLog();
assertFalse("Empty log", log == null || log.trim().isEmpty());
assertEquals("Empty log", log.split(":").length, 4);
// verify process information
Collection<String> refClasses = bpmn2Service.getJavaClasses(deploymentId, processId);
assertNotNull("Null set of referenced classes", refClasses);
assertFalse("Empty set of referenced classes", refClasses.isEmpty());
assertEquals("Number referenced classes", 1, refClasses.size());
assertEquals("Imported class in process", refClasses.iterator().next(), Person.class.getName());
}
use of org.jbpm.kie.test.objects.Person in project jbpm by kiegroup.
the class BPMN2DataServicesReferencesTest method testSignalsAndGlobals.
@Test
public void testSignalsAndGlobals() throws IOException {
Assume.assumeTrue("Skip signal/global tests", loadSignalGlobalInfoProcess);
String processId = PROC_ID_SIGNAL;
// check that process starts
KieSession ksession = deploymentService.getRuntimeManager(deploymentId).getRuntimeEngine(null).getKieSession();
ksession.setGlobal("person", new Person());
long procInstId = startProcess(deploymentId, processId);
ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentId, processId);
assertNotNull(procDef);
// check information about process
assertNotNull("Null signals list", procDef.getSignals());
assertFalse("Empty signals list", procDef.getSignals().isEmpty());
assertEquals("Unexpected signal", "MySignal", procDef.getSignals().iterator().next());
Collection<String> globalNames = procDef.getGlobals();
assertNotNull("Null globals list", globalNames);
assertFalse("Empty globals list", globalNames.isEmpty());
assertEquals("globals list size", 2, globalNames.size());
for (String globalName : globalNames) {
assertTrue("Unexpected global: " + globalName, "person".equals(globalName) || "name".equals(globalName));
}
// cleanup
processService.abortProcessInstance(procInstId);
}
Aggregations