Search in sources :

Example 1 with ScenarioSimulationModelContent

use of org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent in project drools-wb by kiegroup.

the class ScenarioSimulationServiceImpl method constructContent.

@Override
protected ScenarioSimulationModelContent constructContent(final Path path, final Overview overview) {
    final PackageDataModelOracle oracle = dataModelService.getDataModel(path);
    final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
    final Set<String> consumedFQCNs = new HashSet<>();
    // Get FQCN's used by Globals
    consumedFQCNs.addAll(oracle.getPackageGlobals().values());
    // Get FQCN's of collections defined in project settings
    // they can be used in From Collect expressions
    consumedFQCNs.addAll(oracle.getModuleCollectionTypes().entrySet().stream().filter(Map.Entry::getValue).map(Map.Entry::getKey).collect(Collectors.toSet()));
    DataModelOracleUtilities.populateDataModel(oracle, dataModel, consumedFQCNs);
    // Signal opening to interested parties
    resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
    return new ScenarioSimulationModelContent(load(path), overview, dataModel);
}
Also used : PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) PackageDataModelOracle(org.kie.soup.project.datamodel.oracle.PackageDataModelOracle) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) Map(java.util.Map) ScenarioSimulationModelContent(org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent) HashSet(java.util.HashSet)

Example 2 with ScenarioSimulationModelContent

use of org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent in project drools-wb by kiegroup.

the class ScenarioSimulationServiceImplLoadContentTest method loadContent.

@Test
public void loadContent() {
    final ScenarioSimulationModelContent scenarioSimulationModelContent = serviceSpy.loadContent(path);
    assertNotNull(scenarioSimulationModelContent);
    assertNotNull(scenarioSimulationModelContent.getDataModel());
    assertNotNull(scenarioSimulationModelContent.getModel());
    assertNotNull(scenarioSimulationModelContent.getOverview());
    verify(serviceSpy, times(1)).constructContent(eq(path), isA(Overview.class));
    verify(dmnTypeServiceMock, times(1)).initializeNameAndNamespace(isA(Settings.class), eq(path), any());
    verify(resourceOpenedEvent).fire(any(ResourceOpenedEvent.class));
}
Also used : Overview(org.guvnor.common.services.shared.metadata.model.Overview) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) ScenarioSimulationModelContent(org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent) Settings(org.drools.scenariosimulation.api.model.Settings) Test(org.junit.Test)

Example 3 with ScenarioSimulationModelContent

use of org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent in project drools-wb by kiegroup.

the class AbstractDMODataManagementStrategyTest method setup.

@Before
public void setup() {
    super.setup();
    factTypes = new ArrayList<>();
    visibleFactsLocal = new TreeMap<>();
    hiddenFactsLocal = new TreeMap<>();
    factModelTupleLocal = new FactModelTuple(visibleFactsLocal, hiddenFactsLocal);
    factModelTreeHolderlocal = new AbstractDataManagementStrategy.ResultHolder();
    factModelTreeHolderlocal.setFactModelTuple(factModelTupleLocal);
    abstractDMODataManagementStrategySpy = spy(new AbstractDMODataManagementStrategy() {

        @Override
        public void manageScenarioSimulationModelContent(ObservablePath currentPath, ScenarioSimulationModelContent toManage) {
        }

        @Override
        public boolean isADataType(String value) {
            return false;
        }

        @Override
        protected String getFQCNByFactName(String factName) {
            return FULL_CLASS_NAME;
        }

        @Override
        protected String getParametricFieldType(String factName, String propertyName) {
            return PARAMETRIC_FIELD_TYPE;
        }

        @Override
        protected List<String> getFactTypes() {
            return factTypes;
        }

        @Override
        protected void getSuperType(String factType, Callback<String> callback) {
        // Do Nothing
        }

        @Override
        protected boolean skipPopulateTestTools() {
            return false;
        }

        @Override
        protected void manageDataObjects(List<String> dataObjectsTypes, Map<String, String> superTypeMap, TestToolsView.Presenter testToolsPresenter, int expectedElements, SortedMap<String, FactModelTree> dataObjectsFieldsMap, ScenarioSimulationContext context, List<String> simpleJavaTypes, GridWidget gridWidget) {
        }

        {
            this.model = modelLocal;
            this.factModelTreeHolder = factModelTreeHolderlocal;
        }
    });
}
Also used : ScenarioSimulationContext(org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationContext) GridWidget(org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget) FactModelTuple(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple) Callback(org.uberfire.client.callbacks.Callback) SortedMap(java.util.SortedMap) ArrayList(java.util.ArrayList) List(java.util.List) ScenarioSimulationModelContent(org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Before(org.junit.Before)

Example 4 with ScenarioSimulationModelContent

use of org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent in project drools-wb by kiegroup.

the class AbstractScenarioSimulationEditorTest method setup.

public void setup() {
    super.setup();
    // Mock FileMenuBuilder usage since we cannot use FileMenuBuilderImpl either
    when(fileMenuBuilderMock.addSave(any(MenuItem.class))).thenReturn(fileMenuBuilderMock);
    when(fileMenuBuilderMock.addCopy(any(ObservablePath.class), any(DefaultFileNameValidator.class))).thenReturn(fileMenuBuilderMock);
    when(fileMenuBuilderMock.addRename(any(Command.class))).thenReturn(fileMenuBuilderMock);
    when(fileMenuBuilderMock.addDelete(any(ObservablePath.class))).thenReturn(fileMenuBuilderMock);
    when(fileMenuBuilderMock.addValidate(any(Command.class))).thenReturn(fileMenuBuilderMock);
    when(fileMenuBuilderMock.addNewTopLevelMenu(any(MenuItem.class))).thenReturn(fileMenuBuilderMock);
    when(versionRecordManagerMock.getCurrentPath()).thenReturn(observablePathMock);
    when(versionRecordManagerMock.getPathToLatest()).thenReturn(observablePathMock);
    when(workbenchContextMock.getActiveWorkspaceProject()).thenReturn(Optional.empty());
    when(gridContextMenuMock.getView()).thenReturn(gridContextMenuViewMock);
    when(headerGivenContextMenuMock.getView()).thenReturn(headerContextMenuViewMock);
    this.modelLocal = new ScenarioSimulationModel();
    modelLocal.setSimulation(getSimulation());
    modelLocal.setSettings(settingsLocal);
    settingsLocal.setType(ScenarioSimulationModel.Type.RULE);
    settingsLocal.setDmoSession(null);
    modelLocal.setBackground(backgroundLocal);
    this.content = new ScenarioSimulationModelContent(modelLocal, overviewMock, packageDataModelOracleBaselinePayload);
    when(packageDataModelOracleBaselinePayload.getPackageName()).thenReturn(TestProperties.FACT_PACKAGE);
    when(scenarioSimulationServiceMock.loadContent(observablePathMock)).thenReturn(content);
}
Also used : Command(org.uberfire.mvp.Command) MenuItem(org.uberfire.workbench.model.menu.MenuItem) ScenarioSimulationModelContent(org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent) ObservablePath(org.uberfire.backend.vfs.ObservablePath) ScenarioSimulationModel(org.drools.scenariosimulation.api.model.ScenarioSimulationModel) DefaultFileNameValidator(org.uberfire.ext.editor.commons.client.validation.DefaultFileNameValidator)

Example 5 with ScenarioSimulationModelContent

use of org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent in project drools-wb by kiegroup.

the class AbstractDMNDataManagementStrategyTest method manageScenarioSimulationModelContent.

@Test
public void manageScenarioSimulationModelContent() {
    final ScenarioSimulationModelContent contentMock = Mockito.spy(content);
    abstractDMNDataManagementStrategySpy.manageScenarioSimulationModelContent(observablePathMock, contentMock);
    verify(observablePathMock, times(1)).getOriginal();
    verify(contentMock, times(1)).getModel();
}
Also used : ScenarioSimulationModelContent(org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent) AbstractScenarioSimulationEditorTest(org.drools.workbench.screens.scenariosimulation.client.editor.AbstractScenarioSimulationEditorTest) Test(org.junit.Test)

Aggregations

ScenarioSimulationModelContent (org.drools.workbench.screens.scenariosimulation.model.ScenarioSimulationModelContent)5 Map (java.util.Map)2 Test (org.junit.Test)2 ObservablePath (org.uberfire.backend.vfs.ObservablePath)2 ResourceOpenedEvent (org.uberfire.workbench.events.ResourceOpenedEvent)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 ScenarioSimulationModel (org.drools.scenariosimulation.api.model.ScenarioSimulationModel)1 Settings (org.drools.scenariosimulation.api.model.Settings)1 ScenarioSimulationContext (org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationContext)1 AbstractScenarioSimulationEditorTest (org.drools.workbench.screens.scenariosimulation.client.editor.AbstractScenarioSimulationEditorTest)1 GridWidget (org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget)1 FactModelTuple (org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple)1 Overview (org.guvnor.common.services.shared.metadata.model.Overview)1 Before (org.junit.Before)1 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)1