Search in sources :

Example 21 with ProcessRuntime

use of io.automatiko.engine.api.runtime.process.ProcessRuntime in project automatiko-engine by automatiko-io.

the class DmnDecisionInProcessTest method createProcessRuntime.

protected InternalProcessRuntime createProcessRuntime(Process... process) {
    Map<String, Process> mappedProcesses = Stream.of(process).collect(Collectors.toMap(Process::getId, p -> p));
    InternalProcessRuntime processRuntime = new ProcessRuntimeImpl(mappedProcesses);
    return processRuntime;
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) HashMap(java.util.HashMap) ProcessRuntime(io.automatiko.engine.api.runtime.process.ProcessRuntime) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) ArrayList(java.util.ArrayList) BooleanDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance) Map(java.util.Map) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Process(io.automatiko.engine.api.definition.process.Process) Node(io.automatiko.engine.workflow.process.core.Node) DmnRuntimeProvider(io.automatiko.engine.decision.dmn.DmnRuntimeProvider) ConnectionImpl(io.automatiko.engine.workflow.process.core.impl.ConnectionImpl) ProcessRuntimeImpl(io.automatiko.engine.workflow.base.instance.ProcessRuntimeImpl) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) List(java.util.List) Stream(java.util.stream.Stream) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) DmnDecisionModel(io.automatiko.engine.decision.dmn.DmnDecisionModel) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) ProcessRuntimeImpl(io.automatiko.engine.workflow.base.instance.ProcessRuntimeImpl) Process(io.automatiko.engine.api.definition.process.Process) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime)

Example 22 with ProcessRuntime

use of io.automatiko.engine.api.runtime.process.ProcessRuntime in project automatiko-engine by automatiko-io.

the class DmnDecisionInProcessTest method testDmn.

@Test
public void testDmn() {
    String namespace = "https://kiegroup.org/dmn/_52CEF9FD-9943-4A89-96D5-6F66810CA4C1";
    String modelName = "PersonDecisions";
    String decisionName = "isAdult";
    ExecutableProcess process = createProcess(namespace, modelName, decisionName);
    Map<String, Object> parameters = new HashMap<>();
    Person person = new Person("John", 25);
    parameters.put("person", person);
    parameters.put("isAdult", false);
    ProcessRuntime runtime = createProcessRuntime(process);
    ProcessInstance pi = runtime.startProcess("process", parameters);
    assertEquals(ProcessInstance.STATE_COMPLETED, pi.getState());
    boolean result = (boolean) pi.getVariables().get("isAdult");
    assertEquals(true, result);
}
Also used : ProcessRuntime(io.automatiko.engine.api.runtime.process.ProcessRuntime) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime) HashMap(java.util.HashMap) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessRuntime (io.automatiko.engine.api.runtime.process.ProcessRuntime)22 ProcessInstance (io.automatiko.engine.api.runtime.process.ProcessInstance)21 ArrayList (java.util.ArrayList)21 List (java.util.List)20 DelayedExecution (io.automatiko.engine.api.event.process.DelayedExecution)19 ProcessCompletedEvent (io.automatiko.engine.api.event.process.ProcessCompletedEvent)19 ProcessEventListener (io.automatiko.engine.api.event.process.ProcessEventListener)19 ProcessNodeInstanceFailedEvent (io.automatiko.engine.api.event.process.ProcessNodeInstanceFailedEvent)19 ProcessNodeLeftEvent (io.automatiko.engine.api.event.process.ProcessNodeLeftEvent)19 ProcessNodeTriggeredEvent (io.automatiko.engine.api.event.process.ProcessNodeTriggeredEvent)19 ProcessSignaledEvent (io.automatiko.engine.api.event.process.ProcessSignaledEvent)19 ProcessStartedEvent (io.automatiko.engine.api.event.process.ProcessStartedEvent)19 ProcessVariableChangedEvent (io.automatiko.engine.api.event.process.ProcessVariableChangedEvent)19 ProcessWorkItemTransitionEvent (io.automatiko.engine.api.event.process.ProcessWorkItemTransitionEvent)19 SLAViolatedEvent (io.automatiko.engine.api.event.process.SLAViolatedEvent)19 NodeInstance (io.automatiko.engine.api.runtime.process.NodeInstance)19 WorkItem (io.automatiko.engine.api.runtime.process.WorkItem)19 UnitOfWorkManager (io.automatiko.engine.api.uow.UnitOfWorkManager)19 WorkUnit (io.automatiko.engine.api.uow.WorkUnit)19 Transition (io.automatiko.engine.api.workflow.workitem.Transition)19