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());
}
Aggregations