use of org.drools.scenariosimulation.backend.runner.model.ScenarioRunnerDTO in project drools by kiegroup.
the class ScenarioJunitActivator method parseFile.
protected ScenarioRunnerDTO parseFile(String path) {
try (final Scanner scanner = new Scanner(new File(path))) {
String rawFile = scanner.useDelimiter("\\Z").next();
ScenarioSimulationModel scenarioSimulationModel = getXmlReader().unmarshal(rawFile);
return new ScenarioRunnerDTO(scenarioSimulationModel, path);
} catch (FileNotFoundException e) {
throw new ScenarioException("File not found, this should not happen: " + path, e);
} catch (Exception e) {
throw new ScenarioException("Issue on parsing file: " + path, e);
}
}
use of org.drools.scenariosimulation.backend.runner.model.ScenarioRunnerDTO in project drools by kiegroup.
the class AbstractScenarioRunnerTest method getScenarioRunnerDTO.
private ScenarioRunnerDTO getScenarioRunnerDTO() {
Simulation simulation = new Simulation();
IntStream.range(0, SCENARIO_DATA).forEach(index -> {
Scenario scenario = simulation.addData();
scenario.setDescription("INDEX-" + index);
});
ScenarioSimulationModel model = new ScenarioSimulationModel();
model.setSimulation(simulation);
return new ScenarioRunnerDTO(model, "test.scesim");
}
use of org.drools.scenariosimulation.backend.runner.model.ScenarioRunnerDTO in project drools-wb by kiegroup.
the class ScenarioRunnerServiceImpl method runTest.
@Override
public SimulationRunResult runTest(final String identifier, final Path path, final ScesimModelDescriptor simulationDescriptor, final List<ScenarioWithIndex> scenarios, final Settings settings, final Background background) {
final KieContainer kieContainer = getKieContainer(path);
final ScenarioRunnerDTO scenarioRunnerDTO = new ScenarioRunnerDTO(simulationDescriptor, scenarios, null, settings, background);
final AbstractScenarioRunner scenarioRunner = getOrCreateRunnerSupplier(settings.getType()).create(kieContainer, scenarioRunnerDTO);
final List<Failure> failures = new ArrayList<>();
final List<Failure> failureDetails = new ArrayList<>();
final Result result = runWithJunit(path, scenarioRunner, failures, failureDetails);
return new SimulationRunResult(scenarios, background.getBackgroundDataWithIndex(), scenarioRunner.getLastRunResultMetadata().orElseThrow(() -> new IllegalStateException("SimulationRunMetadata should be available after a run")), new TestResultMessage(identifier, result.getRunCount(), result.getRunTime(), failures));
}
Aggregations