use of io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory in project automatiko-engine by automatiko-io.
the class ProcessToExecModelGeneratorTest method testScriptAndWorkItemModelGeneration.
@Test
public void testScriptAndWorkItemModelGeneration() {
ExecutableProcessFactory factory = ExecutableProcessFactory.createProcess("demo.orders");
factory.variable("order", new ObjectDataType(Integer.class)).variable("order", new ObjectDataType(List.class, "java.util.List<String>")).variable("approver", new ObjectDataType(String.class)).name("orders").packageName("com.myspace.demo").dynamic(false).version("1.0").workItemNode(1).name("Log").workName("Log").done().actionNode(2).name("Dump order").action("java", "System.out.println(\"Order has been created \" + order);").done().endNode(3).name("end").terminate(false).done().startNode(4).name("start").done().connection(2, 1).connection(4, 2).connection(1, 3);
Process process = factory.validate().getProcess();
ModelMetaData modelMetadata = ProcessToExecModelGenerator.INSTANCE.generateModel((WorkflowProcess) process);
assertNotNull(modelMetadata, "Dumper should return non null class for process");
logger.debug(modelMetadata.generate());
assertEquals("com.myspace.demo.Orders_1_0Model", modelMetadata.getModelClassName());
}
use of io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory in project automatiko-engine by automatiko-io.
the class FactoryTest method test.
@Test
public void test() {
ExecutableProcessFactory factory = ExecutableProcessFactory.createProcess("ExampleProcess");
factory.variable("x", new ObjectDataType(java.lang.String.class));
factory.variable("y", new ObjectDataType(java.lang.String.class));
factory.variable("list", new ObjectDataType(java.util.List.class, "java.util.List<String>"));
factory.variable("listOut", new ObjectDataType(java.util.List.class, "java.util.List<String>"));
factory.name("Example Process");
factory.packageName("org.company.bpmn2");
factory.dynamic(false);
factory.version("1.0");
factory.visibility("Private");
factory.metaData("TargetNamespace", "http://www.example.org/MinimalExample");
factory.startNode(1).name("StartProcess").done();
factory.dynamicNode(2).metaData("UniqueId", "_2").metaData("MICollectionOutput", "_2_listOutOutput").metaData("x", 96).metaData("y", 16).activationExpression(kcontext -> Objects.equals(kcontext.getVariable("x"), kcontext.getVariable("oldValue"))).variable("x", new ObjectDataType(java.lang.String.class)).exceptionHandler(RuntimeException.class.getName(), "java", "System.out.println(\"Error\");").autoComplete(true).language("java").done();
factory.humanTaskNode(3).name("Task").taskName("Task Name").actorId("Actor").comment("Hey").content("Some content").workParameter("x", "Parameter").inMapping("x", "y").outMapping("y", "x").waitForCompletion(true).timer("1s", null, "java", "").onEntryAction("java", "").onExitAction("java", "").done();
factory.faultNode(4).name("Fault").faultName("Fault Name").faultVariable("x").done();
factory.connection(1, 2, "_1-_2").connection(2, 3, "_2-_3").connection(3, 4, "_3-_4");
factory.validate();
List<String> list = new ArrayList<String>();
list.add("first");
list.add("second");
List<String> listOut = new ArrayList<String>();
Map<String, Object> parameters = new HashMap<>();
parameters.put("x", "oldValue");
parameters.put("list", list);
InternalProcessRuntime ksession = createProcessRuntime(factory.getProcess());
ksession.startProcess("ExampleProcess", parameters);
}
use of io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory in project automatiko-engine by automatiko-io.
the class ForEachTest method test.
@Test
public void test() {
ExecutableProcessFactory factory = ExecutableProcessFactory.createProcess("ParentProcess");
factory.variable("x", new ObjectDataType(java.lang.String.class));
factory.variable("y", new ObjectDataType(java.lang.String.class));
factory.variable("list", new ObjectDataType(java.util.List.class, "java.util.List<String>"));
factory.variable("listOut", new ObjectDataType(java.util.List.class, "java.util.List<String>"));
factory.name("Parent Process");
factory.packageName("org.company.bpmn2");
factory.dynamic(false);
factory.version("1.0");
factory.visibility("Private");
factory.metaData("TargetNamespace", "http://www.example.org/MinimalExample");
io.automatiko.engine.workflow.process.executable.core.factory.StartNodeFactory startNode1 = factory.startNode(1);
startNode1.name("StartProcess");
startNode1.done();
io.automatiko.engine.workflow.process.executable.core.factory.ForEachNodeFactory forEachNode2 = factory.forEachNode(2);
forEachNode2.metaData("UniqueId", "_2");
forEachNode2.metaData("MICollectionOutput", "_2_listOutOutput");
forEachNode2.metaData("x", 96);
forEachNode2.metaData("width", 110);
forEachNode2.metaData("y", 16);
forEachNode2.metaData("MICollectionInput", "_2_input");
forEachNode2.metaData("height", 48);
forEachNode2.collectionExpression("list");
forEachNode2.variable("x", new ObjectDataType(java.lang.String.class));
forEachNode2.outputCollectionExpression("listOut");
forEachNode2.outputVariable("y", new ObjectDataType(java.lang.String.class));
forEachNode2.actionNode(5).action((kcontext) -> System.out.println(kcontext.getVariable("x"))).done();
forEachNode2.linkIncomingConnections(5);
forEachNode2.linkOutgoingConnections(5);
forEachNode2.done();
io.automatiko.engine.workflow.process.executable.core.factory.EndNodeFactory endNode3 = factory.endNode(3);
endNode3.name("EndProcess");
endNode3.terminate(true);
endNode3.done();
factory.connection(1, 2, "_1-_2");
factory.connection(2, 3, "_2-_3");
factory.validate();
List<String> list = new ArrayList<String>();
list.add("first");
list.add("second");
List<String> listOut = new ArrayList<String>();
Map<String, Object> parameters = new HashMap<>();
parameters.put("x", "oldValue");
parameters.put("list", list);
parameters.put("listOut", listOut);
InternalProcessRuntime ksession = createProcessRuntime(factory.getProcess());
ksession.startProcess("ParentProcess", parameters);
}
use of io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory in project automatiko-engine by automatiko-io.
the class ProcessFactoryTest method testProcessFactory.
@Test
public void testProcessFactory() throws Exception {
ExecutableProcessFactory factory = ExecutableProcessFactory.createProcess("org.company.core.process");
factory.name("My process").packageName("org.company").startNode(1).name("Start").done().actionNode(2).name("Action").action("java", "System.out.println(\"Action\");").done().endNode(3).name("End").done().connection(1, 2).connection(2, 3);
factory.validate().getProcess();
}
use of io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory in project automatiko-engine by automatiko-io.
the class ProcessToExecModelGeneratorTest method testScriptAndWorkItemGeneration.
@Test
public void testScriptAndWorkItemGeneration() {
ExecutableProcessFactory factory = ExecutableProcessFactory.createProcess("demo.orders");
factory.variable("order", new ObjectDataType(Integer.class)).variable("approver", new ObjectDataType(String.class)).name("orders").packageName("com.myspace.demo").dynamic(false).version("1.0").workItemNode(1).name("Log").workName("Log").done().actionNode(2).name("Dump order").action("java", "System.out.println(\"Order has been created \" + order);").done().endNode(3).name("end").terminate(false).done().startNode(4).name("start").done().connection(2, 1).connection(4, 2).connection(1, 3);
WorkflowProcess process = factory.validate().getProcess();
ProcessMetaData processMetadata = ProcessToExecModelGenerator.INSTANCE.generate(process);
assertNotNull(processMetadata, "Dumper should return non null class for process");
logger.debug(processMetadata.getGeneratedClassModel().toString());
assertEquals("orders_1_0", processMetadata.getExtractedProcessId());
assertEquals("demo.orders", processMetadata.getProcessId());
assertEquals("orders", processMetadata.getProcessName());
assertEquals("_1_0", processMetadata.getProcessVersion());
assertEquals("com.myspace.demo.Orders_1_0Process", processMetadata.getProcessClassName());
assertNotNull(processMetadata.getGeneratedClassModel());
assertEquals(1, processMetadata.getWorkItems().size());
}
Aggregations