Search in sources :

Example 1 with ImpossibleToFindDMNException

use of org.drools.scenariosimulation.backend.util.ImpossibleToFindDMNException 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 2 with ImpossibleToFindDMNException

use of org.drools.scenariosimulation.backend.util.ImpossibleToFindDMNException in project drools-wb by kiegroup.

the class ScenarioSimulationServiceImplTest method load.

@Test
public void load() {
    ScenarioSimulationModel model = service.load(path);
    assertEquals(Type.DMN, model.getSettings().getType());
    verify(dmnTypeServiceMock, times(1)).initializeNameAndNamespace(any(), any(), any());
    doThrow(new ImpossibleToFindDMNException("")).when(dmnTypeServiceMock).initializeNameAndNamespace(any(), any(), any());
    try {
        service.load(path);
    } catch (Exception e) {
        fail();
    }
}
Also used : ImpossibleToFindDMNException(org.drools.scenariosimulation.backend.util.ImpossibleToFindDMNException) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) ImpossibleToFindDMNException(org.drools.scenariosimulation.backend.util.ImpossibleToFindDMNException) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException) Test(org.junit.Test)

Aggregations

ScenarioSimulationModel (org.drools.scenariosimulation.api.model.ScenarioSimulationModel)2 ImpossibleToFindDMNException (org.drools.scenariosimulation.backend.util.ImpossibleToFindDMNException)2 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)2 IOException (java.io.IOException)1 Settings (org.drools.scenariosimulation.api.model.Settings)1 Test (org.junit.Test)1