Search in sources :

Example 11 with Settings

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

the class ScenarioSimulationServiceImplTest method setup.

@Before
public void setup() {
    Set<Package> testPackages = new HashSet<>();
    Package testPackage = new Package(path, path, path, path, path, "Test", "", "");
    testPackages.add(testPackage);
    when(kieModuleServiceMock.resolveModule(any())).thenReturn(kieModuleMock);
    when(kieModuleServiceMock.resolvePackages(Mockito.<KieModule>any())).thenReturn(testPackages);
    when(kieModuleServiceMock.newPackage(any(), any())).thenReturn(testPackage);
    when(kieModuleServiceMock.resolveDefaultPackage(any())).thenReturn(testPackage);
    when(kieModuleServiceMock.resolveModule(any())).thenReturn(kieModuleMock);
    when(kieModuleMock.getPom()).thenReturn(projectPomMock);
    when(projectPomMock.getGav()).thenReturn(gavMock);
    when(gavMock.getGroupId()).thenReturn("Test");
    when(projectPomMock.getDependencies()).thenReturn(dependenciesMock);
    when(dependenciesMock.iterator()).thenReturn(new Dependencies().iterator());
    when(ioServiceMock.exists(any())).thenReturn(false);
    when(packageMock.getPackageTestSrcPath()).thenReturn(path);
    when(scenarioSimulationBuilderMock.createSimulation(any(), any(), any())).thenReturn(new Simulation());
    when(scenarioSimulationBuilderMock.createBackground(any(), any(), any())).thenReturn(new Background());
    when(scenarioSimulationBuilderMock.createSettings(any(), any(), any())).thenReturn(new Settings());
    service.scenarioSimulationBuilder = scenarioSimulationBuilderMock;
}
Also used : Simulation(org.drools.scenariosimulation.api.model.Simulation) Background(org.drools.scenariosimulation.api.model.Background) Package(org.guvnor.common.services.project.model.Package) Dependencies(org.guvnor.common.services.project.model.Dependencies) Settings(org.drools.scenariosimulation.api.model.Settings) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 12 with Settings

use of org.drools.scenariosimulation.api.model.Settings 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 13 with Settings

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

the class UpdateSettingsDataCommand method setCurrentContext.

protected CommandResult<ScenarioSimulationViolation> setCurrentContext(ScenarioSimulationContext context) {
    try {
        if (restorableStatus == null) {
            throw new IllegalStateException("restorableStatus is null");
        }
        final Settings originalSettings = context.getScenarioSimulationModel().getSettings().cloneSettings();
        context.getScenarioSimulationEditorPresenter().getModel().setSettings(restorableStatus);
        restorableStatus = originalSettings;
        if (dmnPathChanged) {
            context.getScenarioSimulationEditorPresenter().getPopulateTestToolsCommand().execute();
            context.getScenarioSimulationEditorPresenter().validateSimulation();
        }
        context.getScenarioSimulationEditorPresenter().reloadSettingsDock();
        return commonExecution(context);
    } catch (Exception e) {
        return new CommandResultImpl<>(CommandResult.Type.ERROR, Collections.singleton(new ScenarioSimulationViolation(e.getMessage())));
    }
}
Also used : ScenarioSimulationViolation(org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationViolation) Settings(org.drools.scenariosimulation.api.model.Settings)

Example 14 with Settings

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

the class AbstractScenarioRunnerTest method setup.

@Before
public void setup() {
    settingsLocal = new Settings();
    scenarioRunnerDTOLocal = getScenarioRunnerDTO();
    abstractScenarioRunnerLocal = spy(new AbstractScenarioRunner(kieContainerMock, scenarioRunnerDTOLocal, ExpressionEvaluatorFactory.create(this.getClass().getClassLoader(), ScenarioSimulationModel.Type.RULE)) {

        @Override
        protected AbstractRunnerHelper newRunnerHelper() {
            return null;
        }
    });
}
Also used : Settings(org.drools.scenariosimulation.api.model.Settings) Before(org.junit.Before)

Example 15 with Settings

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

the class ScenarioJunitActivatorTest method setup.

@Before
public void setup() throws Exception {
    simulationLocal = new Simulation();
    settingsLocal = new Settings();
    settingsLocal.setSkipFromBuild(true);
    when(xmlReaderMock.unmarshal(any())).thenReturn(scenarioSimulationModelMock);
    when(scenarioSimulationModelMock.getSimulation()).thenReturn(simulationLocal);
    when(scenarioSimulationModelMock.getSettings()).thenReturn(settingsLocal);
}
Also used : Simulation(org.drools.scenariosimulation.api.model.Simulation) Settings(org.drools.scenariosimulation.api.model.Settings) Before(org.junit.Before)

Aggregations

Settings (org.drools.scenariosimulation.api.model.Settings)29 Test (org.junit.Test)11 Before (org.junit.Before)10 Simulation (org.drools.scenariosimulation.api.model.Simulation)9 Background (org.drools.scenariosimulation.api.model.Background)7 Path (org.uberfire.backend.vfs.Path)6 AbstractScenarioSimulationTest (org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest)4 ScenarioSimulationModel (org.drools.scenariosimulation.api.model.ScenarioSimulationModel)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 ExpressionIdentifier (org.drools.scenariosimulation.api.model.ExpressionIdentifier)2 FactMapping (org.drools.scenariosimulation.api.model.FactMapping)2 Scenario (org.drools.scenariosimulation.api.model.Scenario)2 ScenarioWithIndex (org.drools.scenariosimulation.api.model.ScenarioWithIndex)2 ScenarioRunnerData (org.drools.scenariosimulation.backend.runner.model.ScenarioRunnerData)2 ScenarioSimulationViolation (org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationViolation)2 UpdateSettingsDataCommand (org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.UpdateSettingsDataCommand)2 UpdateSettingsDataEvent (org.drools.workbench.screens.scenariosimulation.client.events.UpdateSettingsDataEvent)2 TestResultMessage (org.guvnor.common.services.shared.test.TestResultMessage)2