use of org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_COMPLETED in project kogito-runtimes by kiegroup.
the class MockCacheProcessInstancesTest method testBasicFlowWithError.
private void testBasicFlowWithError(Consumer<ProcessInstance<BpmnVariables>> op) {
BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-UserTask-Script.bpmn2")).get(0);
// workaround as BpmnProcess does not compile the scripts but just reads the xml
for (Node node : ((WorkflowProcess) process.get()).getNodes()) {
if (node instanceof ActionNode) {
DroolsAction a = ((ActionNode) node).getAction();
a.setMetaData("Action", (Action) kcontext -> {
System.out.println("The variable value is " + kcontext.getVariable("s") + " about to call toString on it");
kcontext.getVariable("s").toString();
});
}
}
process.setProcessInstancesFactory(new CacheProcessInstancesFactory(cacheManager));
process.configure();
ProcessInstance<BpmnVariables> processInstance = process.createInstance(BpmnVariables.create());
processInstance.start();
assertThat(processInstance.status()).isEqualTo(STATE_ERROR);
Optional<ProcessError> errorOp = processInstance.error();
assertThat(errorOp).isPresent();
assertThat(errorOp.get().failedNodeId()).isEqualTo("ScriptTask_1");
assertThat(errorOp.get().errorMessage()).isNotNull().contains("java.lang.NullPointerException");
op.accept(processInstance);
assertThat(processInstance.error()).isNotPresent();
WorkItem workItem = processInstance.workItems(SecurityPolicy.of(new StaticIdentityProvider("john"))).get(0);
assertThat(workItem).isNotNull();
assertThat(workItem.getParameters().get("ActorId")).isEqualTo("john");
processInstance.completeWorkItem(workItem.getId(), null, SecurityPolicy.of(new StaticIdentityProvider("john")));
assertThat(processInstance.status()).isEqualTo(STATE_COMPLETED);
}
Aggregations