use of org.kie.pmml.api.runtime.PMMLContext in project drools by kiegroup.
the class DMNKiePMMLTrustyInvocationEvaluator method getPMML4Result.
@Override
protected PMML4Result getPMML4Result(DMNRuntimeEventManager eventManager, DMNResult dmnr) {
PMMLContext pmmlContext = getPMMLPMMLContext(UUID.randomUUID().toString(), model, dmnr);
PMMLRuntime pmmlRuntime = getPMMLRuntime(eventManager);
return pmmlRuntime.evaluate(model, pmmlContext);
}
use of org.kie.pmml.api.runtime.PMMLContext in project drools by kiegroup.
the class PMMLListenerUtilsTest method getPMMLContext.
private PMMLContext getPMMLContext(int size, Map<Integer, PMMLStep> listenerFeedback) {
PMMLContext toReturn = new PMMLContextImpl(new PMMLRequestData());
IntStream.range(0, size).forEach(i -> toReturn.addPMMLListener(getPMMLListener(i, listenerFeedback)));
return toReturn;
}
use of org.kie.pmml.api.runtime.PMMLContext in project drools by kiegroup.
the class PMMLListenerUtilsTest method stepExecuted.
@Test
public void stepExecuted() {
final Map<Integer, PMMLStep> listenerFeedback = new HashMap<>();
int size = 3;
PMMLContext pmmlContext = getPMMLContext(size, listenerFeedback);
AtomicBoolean invoked = new AtomicBoolean(false);
PMMLListenerUtils.stepExecuted(() -> new PMMLStepTest(invoked), pmmlContext);
assertTrue(invoked.get());
assertEquals(size, listenerFeedback.size());
final PMMLStep retrieved = listenerFeedback.get(0);
IntStream.range(1, size).forEach(i -> assertEquals(retrieved, listenerFeedback.get(i)));
}
use of org.kie.pmml.api.runtime.PMMLContext in project drools by kiegroup.
the class PMMLRuntimeInternalImplTest method evaluateWithPmmlRuntimeListeners.
@Test
public void evaluateWithPmmlRuntimeListeners() {
final PMMLRequestData requestData = getPMMLRequestData();
final List<PMMLStep> pmmlSteps = new ArrayList<>();
final PMMLContext pmmlContext = new PMMLContextImpl(requestData);
pmmlRuntime.addPMMLListener(getPMMLListener(pmmlSteps));
pmmlRuntime.evaluate(modelMock, pmmlContext);
Arrays.stream(PMML_STEP.values()).forEach(pmml_step -> {
Optional<PMMLStep> retrieved = pmmlSteps.stream().filter(pmmlStep -> pmml_step.equals(((PMMLRuntimeStep) pmmlStep).getPmmlStep())).findFirst();
assertTrue(retrieved.isPresent());
commonValuateStep(retrieved.get(), pmml_step, modelMock, requestData);
});
}
use of org.kie.pmml.api.runtime.PMMLContext in project drools by kiegroup.
the class PMMLCommandExecutorImpl method evaluate.
private PMML4Result evaluate(final PMMLRequestData pmmlRequestData, final PMMLRuntime pmmlRuntime) {
String modelName = pmmlRequestData.getModelName();
final PMMLContext pmmlContext = new PMMLContextImpl(pmmlRequestData);
return pmmlRuntime.evaluate(modelName, pmmlContext);
}
Aggregations