Search in sources :

Example 21 with ScenarioSimulationModel

use of org.drools.scenariosimulation.api.model.ScenarioSimulationModel 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)

Example 22 with ScenarioSimulationModel

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

the class ScenarioSimulationServiceImplTest method saveAndRename.

@Test
public void saveAndRename() {
    final Metadata metadata = mock(Metadata.class);
    final ScenarioSimulationModel model = new ScenarioSimulationModel();
    service.saveAndRename(path, "newName.scesim", metadata, model, "comment");
    verify(saveAndRenameServiceMock).saveAndRename(path, "newName.scesim", metadata, model, "comment");
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) Test(org.junit.Test)

Example 23 with ScenarioSimulationModel

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

the class ScenarioSimulationEditorBusinessCentralWrapper method getModelSuccessCallbackMethod.

protected void getModelSuccessCallbackMethod(ScenarioSimulationModelContent content) {
    // Path is set to null when the Editor is closed (which can happen before async calls complete).
    if (versionRecordManager.getCurrentPath() == null) {
        return;
    }
    scenarioSimulationEditorPresenter.setPackageName(content.getDataModel().getPackageName());
    resetEditorPages(content.getOverview());
    DataManagementStrategy dataManagementStrategy;
    if (ScenarioSimulationModel.Type.RULE.equals(content.getModel().getSettings().getType())) {
        dataManagementStrategy = new BusinessCentralDMODataManagementStrategy(oracleFactory);
    } else {
        dataManagementStrategy = new BusinessCentralDMNDataManagementStrategy(dmnTypeService, scenarioSimulationEditorPresenter.getEventBus());
    }
    dataManagementStrategy.manageScenarioSimulationModelContent(versionRecordManager.getCurrentPath(), content);
    ScenarioSimulationModel model = content.getModel();
    if (dataManagementStrategy instanceof BusinessCentralDMODataManagementStrategy) {
        importsWidget.setContent(((BusinessCentralDMODataManagementStrategy) dataManagementStrategy).getOracle(), model.getImports(), isReadOnly);
        addImportsTab(importsWidget);
    }
    baseView.hideBusyIndicator();
    scenarioSimulationEditorPresenter.getModelSuccessCallbackMethod(dataManagementStrategy, model);
    setOriginalHash(scenarioSimulationEditorPresenter.getJsonModel(model).hashCode());
}
Also used : AbstractDMODataManagementStrategy(org.drools.workbench.screens.scenariosimulation.client.editor.strategies.AbstractDMODataManagementStrategy) BusinessCentralDMODataManagementStrategy(org.drools.workbench.screens.scenariosimulation.businesscentral.client.editor.strategies.BusinessCentralDMODataManagementStrategy) DataManagementStrategy(org.drools.workbench.screens.scenariosimulation.client.editor.strategies.DataManagementStrategy) BusinessCentralDMNDataManagementStrategy(org.drools.workbench.screens.scenariosimulation.businesscentral.client.editor.strategies.BusinessCentralDMNDataManagementStrategy) BusinessCentralDMNDataManagementStrategy(org.drools.workbench.screens.scenariosimulation.businesscentral.client.editor.strategies.BusinessCentralDMNDataManagementStrategy) BusinessCentralDMODataManagementStrategy(org.drools.workbench.screens.scenariosimulation.businesscentral.client.editor.strategies.BusinessCentralDMODataManagementStrategy) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel)

Example 24 with ScenarioSimulationModel

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

the class AbstractDataManagementStrategyTest method setModel.

@Test
public void setModel() {
    abstractDataManagementStrategySpy.model = null;
    ScenarioSimulationModel modelMock = mock(ScenarioSimulationModel.class);
    abstractDataManagementStrategySpy.setModel(modelMock);
    assertEquals(modelMock, abstractDataManagementStrategySpy.model);
}
Also used : ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) AbstractScenarioSimulationEditorTest(org.drools.workbench.screens.scenariosimulation.client.editor.AbstractScenarioSimulationEditorTest) 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