use of org.drools.scenariosimulation.api.model.Settings 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);
}
}
use of org.drools.scenariosimulation.api.model.Settings in project drools-wb by kiegroup.
the class ScenarioValidationServiceTest method validateSimulationStructure.
@Test
public void validateSimulationStructure() {
Simulation simulation = new Simulation();
Settings settings = new Settings();
ScenarioValidationService scenarioValidationServiceSpy = spy(new ScenarioValidationService() {
@Override
protected List<FactMappingValidationError> validateDMN(Simulation simulation, Settings settings, KieContainer kieContainer) {
return Collections.emptyList();
}
@Override
protected List<FactMappingValidationError> validateRULE(Simulation simulation, Settings settings, KieContainer kieContainer) {
return Collections.emptyList();
}
@Override
protected KieContainer getKieContainer(Path path) {
return kieContainerMock;
}
});
settings.setType(ScenarioSimulationModel.Type.DMN);
scenarioValidationServiceSpy.validateSimulationStructure(simulation, settings, pathMock);
verify(scenarioValidationServiceSpy, never()).validateDMN(eq(simulation), eq(settings), eq(kieContainerMock));
verify(scenarioValidationServiceSpy, never()).validateRULE(eq(simulation), eq(settings), eq(kieContainerMock));
reset(scenarioValidationServiceSpy);
FactMapping sampleFactMapping = simulation.getScesimModelDescriptor().addFactMapping(FactIdentifier.create("sample", String.class.getCanonicalName()), ExpressionIdentifier.create("sample", FactMappingType.GIVEN));
sampleFactMapping.addExpressionElement("sample", String.class.getCanonicalName());
settings.setType(ScenarioSimulationModel.Type.DMN);
scenarioValidationServiceSpy.validateSimulationStructure(simulation, settings, pathMock);
verify(scenarioValidationServiceSpy, timeout(1)).validateDMN(eq(simulation), eq(settings), eq(kieContainerMock));
reset(scenarioValidationServiceSpy);
settings.setType(ScenarioSimulationModel.Type.RULE);
scenarioValidationServiceSpy.validateSimulationStructure(simulation, settings, pathMock);
verify(scenarioValidationServiceSpy, timeout(1)).validateRULE(eq(simulation), eq(settings), eq(kieContainerMock));
settings.setType(null);
assertThatThrownBy(() -> scenarioValidationServiceSpy.validateSimulationStructure(simulation, settings, pathMock)).isInstanceOf(IllegalArgumentException.class);
}
use of org.drools.scenariosimulation.api.model.Settings in project drools-wb by kiegroup.
the class DMNScenarioValidationTest method init.
@Before
public void init() {
settingsLocal = new Settings();
settingsLocal.setType(ScenarioSimulationModel.Type.DMN);
when(dmnModelMock.getDecisionByName(anyString())).thenAnswer(invocation -> mapOfMockDecisions.get(invocation.getArguments()[0]));
}
use of org.drools.scenariosimulation.api.model.Settings in project drools-wb by kiegroup.
the class RULESimulationSettingsCreationStrategy method createSettings.
@Override
public Settings createSettings(Path context, String dmoSession) {
Settings toReturn = new Settings();
toReturn.setType(ScenarioSimulationModel.Type.RULE);
toReturn.setDmoSession(dmoSession);
return toReturn;
}
use of org.drools.scenariosimulation.api.model.Settings in project drools-wb by kiegroup.
the class DMNTypeServiceImplTest method initializeNameAndNamespace.
@Test
public void initializeNameAndNamespace() {
Settings settings = new Settings();
dmnTypeServiceImpl.initializeNameAndNamespace(settings, mock(Path.class), "");
assertEquals(NAMESPACE, settings.getDmnNamespace());
assertEquals(MODEL_NAME, settings.getDmnName());
}
Aggregations