Search in sources :

Example 16 with ScenarioSimulationModel

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

the class ScenarioSimulationXMLPersistenceTest method unmarshalRULE.

@Test
public void unmarshalRULE() throws Exception {
    String toUnmarshal = getFileContent("scesim-rule.scesim");
    final ScenarioSimulationModel retrieved = ScenarioSimulationXMLPersistence.getInstance().unmarshal(toUnmarshal);
    assertEquals(ScenarioSimulationModel.Type.RULE, retrieved.getSettings().getType());
    commonCheckSimulation(retrieved);
}
Also used : ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) Test(org.junit.Test)

Example 17 with ScenarioSimulationModel

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

the class ScenarioRunnerServiceImplTest method makeScenarioSimulationModel.

private ScenarioSimulationModel makeScenarioSimulationModel(boolean toSkip) {
    Simulation simulation = new Simulation();
    Settings settings = new Settings();
    settings.setType(Type.RULE);
    settings.setSkipFromBuild(toSkip);
    ScenarioSimulationModel scenarioSimulationModel = new ScenarioSimulationModel();
    scenarioSimulationModel.setSimulation(simulation);
    scenarioSimulationModel.setSettings(settings);
    scenarioSimulationModel.setBackground(new Background());
    return scenarioSimulationModel;
}
Also used : Simulation(org.drools.scenariosimulation.api.model.Simulation) Background(org.drools.scenariosimulation.api.model.Background) Settings(org.drools.scenariosimulation.api.model.Settings) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel)

Example 18 with ScenarioSimulationModel

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

the class ScenarioSimulationServiceImplTest method createRULEScenario.

@Test
public void createRULEScenario() {
    doReturn(false).when(ioServiceMock).exists(any());
    ScenarioSimulationModel model = new ScenarioSimulationModel();
    assertNull(model.getSimulation());
    assertNull(model.getBackground());
    assertNull(model.getSettings());
    final Path returnPath = service.create(this.path, "test.scesim", model, "Commit comment", Type.RULE, null);
    assertNotNull(returnPath);
    assertNotNull(model.getSimulation());
    assertNotNull(model.getBackground());
    assertNotNull(model.getSettings());
    verify(ioServiceMock, times(2)).write(any(org.uberfire.java.nio.file.Path.class), anyString(), any());
}
Also used : Path(org.uberfire.backend.vfs.Path) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) Test(org.junit.Test)

Example 19 with ScenarioSimulationModel

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

the class ScenarioSimulationServiceImpl method load.

@Override
public ScenarioSimulationModel load(final Path path) {
    try {
        final String content = ioService.readAllString(Paths.convert(path));
        final ScenarioSimulationModel scenarioSimulationModel = unmarshalInternal(content);
        final Settings settings = scenarioSimulationModel.getSettings();
        if (settings != null && DMN.equals(settings.getType())) {
            try {
                dmnTypeService.initializeNameAndNamespace(settings, path, settings.getDmnFilePath());
            } catch (ImpossibleToFindDMNException e) {
                // this error is not thrown so user can fix the file path manually
                logger.error(e.getMessage(), e);
            }
        }
        return scenarioSimulationModel;
    } catch (Exception e) {
        throw ExceptionUtilities.handleException(e);
    }
}
Also used : ImpossibleToFindDMNException(org.drools.scenariosimulation.backend.util.ImpossibleToFindDMNException) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) Settings(org.drools.scenariosimulation.api.model.Settings) ImpossibleToFindDMNException(org.drools.scenariosimulation.backend.util.ImpossibleToFindDMNException) IOException(java.io.IOException) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException)

Example 20 with ScenarioSimulationModel

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

the class ScenarioSimulationServiceImplTest method createFileExists.

@Test(expected = FileAlreadyExistsException.class)
public void createFileExists() throws Exception {
    doReturn(true).when(ioServiceMock).exists(any());
    ScenarioSimulationModel model = new ScenarioSimulationModel();
    service.create(this.path, "test.scesim", model, "Commit comment");
}
Also used : 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