Search in sources :

Example 1 with PMMLRuntimeStep

use of org.kie.pmml.evaluator.core.implementations.PMMLRuntimeStep 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);
    });
}
Also used : IntStream(java.util.stream.IntStream) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) OK(org.kie.pmml.api.enums.ResultCode.OK) Arrays(java.util.Arrays) PMML4Result(org.kie.api.pmml.PMML4Result) PMML_STEP(org.kie.pmml.api.enums.PMML_STEP) ArrayList(java.util.ArrayList) MiningField(org.kie.pmml.api.models.MiningField) PMML_MODEL(org.kie.pmml.api.enums.PMML_MODEL) TestCase.assertNotNull(junit.framework.TestCase.assertNotNull) Map(java.util.Map) KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) KieBase(org.kie.api.KieBase) Before(org.junit.Before) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE) PMMLModelEvaluator(org.kie.pmml.evaluator.core.executor.PMMLModelEvaluator) Mockito.verify(org.mockito.Mockito.verify) PMMLContextImpl(org.kie.pmml.evaluator.core.PMMLContextImpl) PMMLContext(org.kie.pmml.api.runtime.PMMLContext) List(java.util.List) Mockito.never(org.mockito.Mockito.never) PMMLRuntimeStep(org.kie.pmml.evaluator.core.implementations.PMMLRuntimeStep) PMMLRequestData(org.kie.api.pmml.PMMLRequestData) PMMLListener(org.kie.pmml.api.runtime.PMMLListener) PMMLModelEvaluatorFinderImpl(org.kie.pmml.evaluator.core.executor.PMMLModelEvaluatorFinderImpl) Optional(java.util.Optional) Collections(java.util.Collections) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException) Mockito.reset(org.mockito.Mockito.reset) PMMLStep(org.kie.pmml.api.models.PMMLStep) TestCase.assertEquals(junit.framework.TestCase.assertEquals) Mockito.mock(org.mockito.Mockito.mock) PMMLRequestData(org.kie.api.pmml.PMMLRequestData) PMMLStep(org.kie.pmml.api.models.PMMLStep) PMMLContextImpl(org.kie.pmml.evaluator.core.PMMLContextImpl) ArrayList(java.util.ArrayList) PMMLContext(org.kie.pmml.api.runtime.PMMLContext) Test(org.junit.Test)

Example 2 with PMMLRuntimeStep

use of org.kie.pmml.evaluator.core.implementations.PMMLRuntimeStep 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;
}
Also used : PMMLStep(org.kie.pmml.api.models.PMMLStep) PMMLRuntimeStep(org.kie.pmml.evaluator.core.implementations.PMMLRuntimeStep)

Example 3 with PMMLRuntimeStep

use of org.kie.pmml.evaluator.core.implementations.PMMLRuntimeStep 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);
    });
}
Also used : IntStream(java.util.stream.IntStream) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) OK(org.kie.pmml.api.enums.ResultCode.OK) Arrays(java.util.Arrays) PMML4Result(org.kie.api.pmml.PMML4Result) PMML_STEP(org.kie.pmml.api.enums.PMML_STEP) ArrayList(java.util.ArrayList) MiningField(org.kie.pmml.api.models.MiningField) PMML_MODEL(org.kie.pmml.api.enums.PMML_MODEL) TestCase.assertNotNull(junit.framework.TestCase.assertNotNull) Map(java.util.Map) KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) KieBase(org.kie.api.KieBase) Before(org.junit.Before) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE) PMMLModelEvaluator(org.kie.pmml.evaluator.core.executor.PMMLModelEvaluator) Mockito.verify(org.mockito.Mockito.verify) PMMLContextImpl(org.kie.pmml.evaluator.core.PMMLContextImpl) PMMLContext(org.kie.pmml.api.runtime.PMMLContext) List(java.util.List) Mockito.never(org.mockito.Mockito.never) PMMLRuntimeStep(org.kie.pmml.evaluator.core.implementations.PMMLRuntimeStep) PMMLRequestData(org.kie.api.pmml.PMMLRequestData) PMMLListener(org.kie.pmml.api.runtime.PMMLListener) PMMLModelEvaluatorFinderImpl(org.kie.pmml.evaluator.core.executor.PMMLModelEvaluatorFinderImpl) Optional(java.util.Optional) Collections(java.util.Collections) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException) Mockito.reset(org.mockito.Mockito.reset) PMMLStep(org.kie.pmml.api.models.PMMLStep) TestCase.assertEquals(junit.framework.TestCase.assertEquals) Mockito.mock(org.mockito.Mockito.mock) PMMLRequestData(org.kie.api.pmml.PMMLRequestData) PMMLStep(org.kie.pmml.api.models.PMMLStep) PMMLContextImpl(org.kie.pmml.evaluator.core.PMMLContextImpl) ArrayList(java.util.ArrayList) PMMLContext(org.kie.pmml.api.runtime.PMMLContext) Test(org.junit.Test)

Aggregations

PMMLStep (org.kie.pmml.api.models.PMMLStep)3 PMMLRuntimeStep (org.kie.pmml.evaluator.core.implementations.PMMLRuntimeStep)3 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 IntStream (java.util.stream.IntStream)2 TestCase.assertEquals (junit.framework.TestCase.assertEquals)2 TestCase.assertNotNull (junit.framework.TestCase.assertNotNull)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 Before (org.junit.Before)2 Test (org.junit.Test)2 KieBase (org.kie.api.KieBase)2 PMML4Result (org.kie.api.pmml.PMML4Result)2 PMMLRequestData (org.kie.api.pmml.PMMLRequestData)2 DATA_TYPE (org.kie.pmml.api.enums.DATA_TYPE)2 PMML_MODEL (org.kie.pmml.api.enums.PMML_MODEL)2 PMML_STEP (org.kie.pmml.api.enums.PMML_STEP)2