use of org.jbpm.services.api.model.ProcessDefinition 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.services.api.model.ProcessDefinition 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.services.api.model.ProcessDefinition 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.services.api.model.ProcessDefinition 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);
}
use of org.jbpm.services.api.model.ProcessDefinition 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());
}
}
Aggregations