Search in sources :

Example 1 with WorkItemHandlerConfig

use of org.kie.kogito.process.WorkItemHandlerConfig in project kogito-runtimes by kiegroup.

the class JsonSchemaUtilTest method testJsonSchemaPhases.

@Test
<T> void testJsonSchemaPhases() throws IOException {
    InputStream in = new ByteArrayInputStream(example.getBytes());
    Policy<T>[] policies = new Policy[0];
    Map<String, Object> schemaMap = JsonSchemaUtil.load(in);
    in.close();
    Process<T> process = mock(Process.class);
    ProcessInstances<T> processInstances = mock(ProcessInstances.class);
    when(process.instances()).thenReturn(processInstances);
    ProcessInstance<T> processInstance = mock(ProcessInstance.class);
    when(processInstances.findById("pepe", ProcessInstanceReadMode.READ_ONLY)).thenReturn((Optional) Optional.of(processInstance));
    WorkItem task = mock(WorkItem.class);
    when(processInstance.workItem("task", policies)).thenReturn(task);
    when(task.getPhase()).thenReturn("active");
    Config config = mock(Config.class);
    ProcessConfig processConfig = mock(ProcessConfig.class);
    when(config.get(any())).thenReturn(processConfig);
    WorkItemHandlerConfig workItemHandlerConfig = mock(WorkItemHandlerConfig.class);
    when(processConfig.workItemHandlers()).thenReturn(workItemHandlerConfig);
    KogitoWorkItemHandler workItemHandler = new HumanTaskWorkItemHandler();
    when(workItemHandlerConfig.forName("Human Task")).thenReturn(workItemHandler);
    schemaMap = JsonSchemaUtil.addPhases(process, workItemHandler, "pepe", "task", policies, schemaMap);
    assertFalse(((Collection) schemaMap.get("phases")).isEmpty());
}
Also used : Policy(org.kie.kogito.process.workitem.Policy) HumanTaskWorkItemHandler(org.jbpm.process.instance.impl.humantask.HumanTaskWorkItemHandler) ProcessConfig(org.kie.kogito.process.ProcessConfig) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Config(org.kie.kogito.Config) ProcessConfig(org.kie.kogito.process.ProcessConfig) WorkItemHandlerConfig(org.kie.kogito.process.WorkItemHandlerConfig) KogitoWorkItemHandler(org.kie.kogito.internal.process.runtime.KogitoWorkItemHandler) WorkItem(org.kie.kogito.process.WorkItem) WorkItemHandlerConfig(org.kie.kogito.process.WorkItemHandlerConfig) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.jupiter.api.Test)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 HumanTaskWorkItemHandler (org.jbpm.process.instance.impl.humantask.HumanTaskWorkItemHandler)1 Test (org.junit.jupiter.api.Test)1 Config (org.kie.kogito.Config)1 KogitoWorkItemHandler (org.kie.kogito.internal.process.runtime.KogitoWorkItemHandler)1 ProcessConfig (org.kie.kogito.process.ProcessConfig)1 WorkItem (org.kie.kogito.process.WorkItem)1 WorkItemHandlerConfig (org.kie.kogito.process.WorkItemHandlerConfig)1 Policy (org.kie.kogito.process.workitem.Policy)1