use of org.drools.scenariosimulation.backend.fluent.RuleScenarioExecutableBuilder in project drools by kiegroup.
the class RuleScenarioRunnerHelper method executeScenario.
@Override
protected Map<String, Object> executeScenario(KieContainer kieContainer, ScenarioRunnerData scenarioRunnerData, ExpressionEvaluatorFactory expressionEvaluatorFactory, ScesimModelDescriptor scesimModelDescriptor, Settings settings) {
if (!Type.RULE.equals(settings.getType())) {
throw new ScenarioException("Impossible to run a not-RULE simulation with RULE runner");
}
RuleScenarioExecutableBuilder ruleScenarioExecutableBuilder = createBuilderWrapper(kieContainer, settings);
if (settings.getRuleFlowGroup() != null) {
ruleScenarioExecutableBuilder.setActiveRuleFlowGroup(settings.getRuleFlowGroup());
}
loadInputData(scenarioRunnerData.getBackgrounds(), ruleScenarioExecutableBuilder);
loadInputData(scenarioRunnerData.getGivens(), ruleScenarioExecutableBuilder);
// all new facts should be verified internally to the working memory
scenarioRunnerData.getExpects().stream().filter(ScenarioExpect::isNewFact).flatMap(output -> output.getExpectedResult().stream().map(ScenarioResult::new)).forEach(scenarioResult -> {
Class<?> clazz = ScenarioBeanUtil.loadClass(scenarioResult.getFactIdentifier().getClassName(), kieContainer.getClassLoader());
ExpressionEvaluator expressionEvaluator = expressionEvaluatorFactory.getOrCreate(scenarioResult.getFactMappingValue());
scenarioRunnerData.addResult(scenarioResult);
ruleScenarioExecutableBuilder.addInternalCondition(clazz, createExtractorFunction(expressionEvaluator, scenarioResult.getFactMappingValue(), scesimModelDescriptor), scenarioResult);
});
return ruleScenarioExecutableBuilder.run();
}
Aggregations