use of org.kie.pmml.api.models.PMMLStep 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.models.PMMLStep in project drools by kiegroup.
the class PMMLRuntimeInternalImpl method getStep.
PMMLStep getStep(final PMML_STEP pmmlStep, final KiePMMLModel model, final PMMLRequestData requestData) {
final PMMLStep toReturn = new PMMLRuntimeStep(pmmlStep);
toReturn.addInfo("MODEL", model.getName());
toReturn.addInfo("CORRELATION ID", requestData.getCorrelationId());
toReturn.addInfo("REQUEST MODEL", requestData.getModelName());
requestData.getRequestParams().forEach(requestParam -> toReturn.addInfo(requestParam.getName(), requestParam.getValue()));
return toReturn;
}
use of org.kie.pmml.api.models.PMMLStep in project drools by kiegroup.
the class PMMLRuntimeInternalImplTest method evaluateWithPMMLContextListeners.
@Test
public void evaluateWithPMMLContextListeners() {
final PMMLRequestData requestData = getPMMLRequestData();
final List<PMMLStep> pmmlSteps = new ArrayList<>();
final PMMLContext pmmlContext = new PMMLContextImpl(requestData, Collections.singleton(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.models.PMMLStep in project drools by kiegroup.
the class PMMLMiningModelEvaluatorTest method addStep.
@Test
public void addStep() {
PMMLStep step = mock(PMMLStep.class);
Set<PMMLListener> pmmlListenersMock = IntStream.range(0, 3).mapToObj(i -> mock(PMMLListener.class)).collect(Collectors.toSet());
PMMLContext pmmlContextMock = mock(PMMLContext.class);
when(pmmlContextMock.getPMMLListeners()).thenReturn(pmmlListenersMock);
evaluator.addStep(() -> step, pmmlContextMock);
pmmlListenersMock.forEach(pmmlListenerMock -> verify(pmmlListenerMock).stepExecuted(step));
}
Aggregations