Search in sources :

Example 6 with ScenarioSimulationModel

use of org.drools.scenariosimulation.api.model.ScenarioSimulationModel in project drools-wb by kiegroup.

the class ScenarioRunnerServiceImpl method runAllTests.

@Override
public List<TestResultMessage> runAllTests(final String identifier, final Path path) {
    final List<TestResultMessage> testResultMessages = new ArrayList<>();
    for (Map.Entry<Path, ScenarioSimulationModel> entry : scenarioLoader.loadScenarios(path).entrySet()) {
        final Simulation simulation = entry.getValue().getSimulation();
        final Settings settings = entry.getValue().getSettings();
        if (!settings.isSkipFromBuild()) {
            testResultMessages.add(runTest(identifier, entry.getKey(), simulation.getScesimModelDescriptor(), simulation.getScenarioWithIndex(), settings, entry.getValue().getBackground()).getTestResultMessage());
        }
    }
    return testResultMessages;
}
Also used : Path(org.uberfire.backend.vfs.Path) Simulation(org.drools.scenariosimulation.api.model.Simulation) TestResultMessage(org.guvnor.common.services.shared.test.TestResultMessage) ArrayList(java.util.ArrayList) Map(java.util.Map) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) Settings(org.drools.scenariosimulation.api.model.Settings)

Example 7 with ScenarioSimulationModel

use of org.drools.scenariosimulation.api.model.ScenarioSimulationModel in project drools-wb by kiegroup.

the class AbstractScenarioSimulationEditorTest method setup.

public void setup() {
    super.setup();
    // Mock FileMenuBuilder usage since we cannot use FileMenuBuilderImpl either
    when(fileMenuBuilderMock.addSave(any(MenuItem.class))).thenReturn(fileMenuBuilderMock);
    when(fileMenuBuilderMock.addCopy(any(ObservablePath.class), any(DefaultFileNameValidator.class))).thenReturn(fileMenuBuilderMock);
    when(fileMenuBuilderMock.addRename(any(Command.class))).thenReturn(fileMenuBuilderMock);
    when(fileMenuBuilderMock.addDelete(any(ObservablePath.class))).thenReturn(fileMenuBuilderMock);
    when(fileMenuBuilderMock.addValidate(any(Command.class))).thenReturn(fileMenuBuilderMock);
    when(fileMenuBuilderMock.addNewTopLevelMenu(any(MenuItem.class))).thenReturn(fileMenuBuilderMock);
    when(versionRecordManagerMock.getCurrentPath()).thenReturn(observablePathMock);
    when(versionRecordManagerMock.getPathToLatest()).thenReturn(observablePathMock);
    when(workbenchContextMock.getActiveWorkspaceProject()).thenReturn(Optional.empty());
    when(gridContextMenuMock.getView()).thenReturn(gridContextMenuViewMock);
    when(headerGivenContextMenuMock.getView()).thenReturn(headerContextMenuViewMock);
    this.modelLocal = new ScenarioSimulationModel();
    modelLocal.setSimulation(getSimulation());
    modelLocal.setSettings(settingsLocal);
    settingsLocal.setType(ScenarioSimulationModel.Type.RULE);
    settingsLocal.setDmoSession(null);
    modelLocal.setBackground(backgroundLocal);
    this.content = new ScenarioSimulationModelContent(modelLocal, overviewMock, packageDataModelOracleBaselinePayload);
    when(packageDataModelOracleBaselinePayload.getPackageName()).thenReturn(TestProperties.FACT_PACKAGE);
    when(scenarioSimulationServiceMock.loadContent(observablePathMock)).thenReturn(content);
}
Also used : Command(org.uberfire.mvp.Command) MenuItem(org.uberfire.workbench.model.menu.MenuItem) ScenarioSimulationModelContent(org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent) ObservablePath(org.uberfire.backend.vfs.ObservablePath) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) DefaultFileNameValidator(org.uberfire.ext.editor.commons.client.validation.DefaultFileNameValidator)

Example 8 with ScenarioSimulationModel

use of org.drools.scenariosimulation.api.model.ScenarioSimulationModel 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");
}
Also used : Simulation(org.drools.scenariosimulation.api.model.Simulation) ScenarioRunnerDTO(org.drools.scenariosimulation.backend.runner.model.ScenarioRunnerDTO) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) Scenario(org.drools.scenariosimulation.api.model.Scenario)

Example 9 with ScenarioSimulationModel

use of org.drools.scenariosimulation.api.model.ScenarioSimulationModel 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);
    }
}
Also used : Scanner(java.util.Scanner) ScenarioRunnerDTO(org.drools.scenariosimulation.backend.runner.model.ScenarioRunnerDTO) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) FileNotFoundException(java.io.FileNotFoundException)

Example 10 with ScenarioSimulationModel

use of org.drools.scenariosimulation.api.model.ScenarioSimulationModel in project drools by kiegroup.

the class ScenarioSimulationXMLPersistenceTest method noFQCNUsed.

@Test
public void noFQCNUsed() {
    final ScenarioSimulationModel simulationModel = new ScenarioSimulationModel();
    simulationModel.getImports().addImport(new Import("org.test.Test"));
    final String xml = instance.marshal(simulationModel);
    assertFalse(xml.contains("org.drools.scenariosimulation.api.model"));
    assertFalse(xml.contains("org.kie.soup.project.datamodel.imports"));
}
Also used : Import(org.drools.scenariosimulation.api.model.imports.Import) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) Test(org.junit.Test)

Aggregations

ScenarioSimulationModel (org.drools.scenariosimulation.api.model.ScenarioSimulationModel)24 Test (org.junit.Test)12 Path (org.uberfire.backend.vfs.Path)5 Settings (org.drools.scenariosimulation.api.model.Settings)3 Simulation (org.drools.scenariosimulation.api.model.Simulation)3 ScenarioRunnerDTO (org.drools.scenariosimulation.backend.runner.model.ScenarioRunnerDTO)2 ImpossibleToFindDMNException (org.drools.scenariosimulation.backend.util.ImpossibleToFindDMNException)2 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)2 ObservablePath (org.uberfire.backend.vfs.ObservablePath)2 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Scanner (java.util.Scanner)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1