Search in sources :

Example 16 with ClassPathResource

use of io.automatiko.engine.services.io.ClassPathResource in project automatiko-engine by automatiko-io.

the class FileSystemProcessInstancesTest method createProcess.

private BpmnProcess createProcess(ProcessConfig config, String fileName) {
    BpmnProcess process = BpmnProcess.from(config, new ClassPathResource(fileName)).get(0);
    process.setProcessInstancesFactory(new FileSystemProcessInstancesFactory());
    process.configure();
    process.instances().values(ProcessInstanceReadMode.MUTABLE, 1, 10).forEach(p -> p.abort());
    return process;
}
Also used : BpmnProcess(io.automatiko.engine.workflow.bpmn2.BpmnProcess) ClassPathResource(io.automatiko.engine.services.io.ClassPathResource)

Example 17 with ClassPathResource

use of io.automatiko.engine.services.io.ClassPathResource in project automatiko-engine by automatiko-io.

the class PredictionAwareHumanTaskLifeCycleTest method testUserTaskWithPredictionService.

@Test
public void testUserTaskWithPredictionService() {
    predictNow.set(true);
    BpmnProcess process = (BpmnProcess) BpmnProcess.from(config, new ClassPathResource("BPMN2-UserTask.bpmn2")).get(0);
    process.configure();
    ProcessInstance<BpmnVariables> processInstance = process.createInstance(BpmnVariables.create(Collections.singletonMap("test", "test")));
    processInstance.start();
    assertEquals(STATE_COMPLETED, processInstance.status());
    Model result = (Model) processInstance.variables();
    assertEquals(2, result.toMap().size());
    assertEquals("predicted value", result.toMap().get("s"));
    assertEquals(0, trainedTasks.size());
}
Also used : BpmnProcess(io.automatiko.engine.workflow.bpmn2.BpmnProcess) Model(io.automatiko.engine.api.Model) ClassPathResource(io.automatiko.engine.services.io.ClassPathResource) BpmnVariables(io.automatiko.engine.workflow.bpmn2.BpmnVariables) Test(org.junit.jupiter.api.Test)

Example 18 with ClassPathResource

use of io.automatiko.engine.services.io.ClassPathResource in project automatiko-engine by automatiko-io.

the class SmileRandomForestPredictionTest method testUserTaskWithPredictionService.

@Test
public void testUserTaskWithPredictionService() {
    BpmnProcess process = (BpmnProcess) BpmnProcess.from(config, new ClassPathResource("BPMN2-UserTask.bpmn2")).get(0);
    process.configure();
    ProcessInstance<BpmnVariables> processInstance = process.createInstance(BpmnVariables.create(Collections.singletonMap("test", "test")));
    processInstance.start();
    assertEquals(STATE_COMPLETED, processInstance.status());
    Model result = (Model) processInstance.variables();
    assertEquals(2, result.toMap().size());
    assertEquals("predicted value", result.toMap().get("s"));
}
Also used : BpmnProcess(io.automatiko.engine.workflow.bpmn2.BpmnProcess) Model(io.automatiko.engine.api.Model) ClassPathResource(io.automatiko.engine.services.io.ClassPathResource) BpmnVariables(io.automatiko.engine.workflow.bpmn2.BpmnVariables) Test(org.junit.jupiter.api.Test)

Aggregations

ClassPathResource (io.automatiko.engine.services.io.ClassPathResource)18 Test (org.junit.jupiter.api.Test)16 TextNode (com.fasterxml.jackson.databind.node.TextNode)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 BpmnProcess (io.automatiko.engine.workflow.bpmn2.BpmnProcess)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 WorkItem (io.automatiko.engine.api.runtime.process.WorkItem)5 WorkItemHandler (io.automatiko.engine.api.runtime.process.WorkItemHandler)5 WorkItemManager (io.automatiko.engine.api.runtime.process.WorkItemManager)5 ProcessConfig (io.automatiko.engine.api.workflow.ProcessConfig)5 DefaultWorkItemHandlerConfig (io.automatiko.engine.workflow.DefaultWorkItemHandlerConfig)5 BpmnVariables (io.automatiko.engine.workflow.bpmn2.BpmnVariables)4 Model (io.automatiko.engine.api.Model)3 IntNode (com.fasterxml.jackson.databind.node.IntNode)2 WorkItem (io.automatiko.engine.api.workflow.WorkItem)2 Address (io.automatiko.engine.addons.persistence.data.Address)1 Person (io.automatiko.engine.addons.persistence.data.Person)1 SvgBpmnProcessImageGenerator (io.automatiko.engine.codegen.process.image.SvgBpmnProcessImageGenerator)1 BpmnProcessCompiler (io.automatiko.engine.workflow.bpmn2.BpmnProcessCompiler)1