Search in sources :

Example 1 with GridWidget

use of org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget in project drools-wb by kiegroup.

the class ScenarioGridTest method getGridWidget.

@Test
public void getGridWidget() {
    final GridWidget retrieved = scenarioGridSpy.getGridWidget();
    assertNotNull(retrieved);
    assertEquals(GridWidget.SIMULATION, retrieved);
    verify(scenarioGridSpy.getModel(), times(1)).getGridWidget();
}
Also used : GridWidget(org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget) Test(org.junit.Test)

Example 2 with GridWidget

use of org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget in project drools-wb by kiegroup.

the class AbstractScenarioGridCommandTest method commonUndoRedoPreExecutionDifferentGridCheckSwitch.

@Test
public void commonUndoRedoPreExecutionDifferentGridCheckSwitch() {
    // Test to verify there are not new, un-managed, GridWidget
    for (GridWidget gridWidget : GridWidget.values()) {
        when(scenarioGridWidgetSpy.isSelected()).thenReturn(GridWidget.BACKGROUND.equals(gridWidget));
        when(backgroundGridWidgetSpy.isSelected()).thenReturn(GridWidget.SIMULATION.equals(gridWidget));
        commandSpy.gridWidget = gridWidget;
        commandSpy.commonUndoRedoPreExecution(scenarioSimulationContextLocal);
        if (GridWidget.SIMULATION.equals(gridWidget)) {
            verify(scenarioSimulationEditorPresenterMock, times(1)).selectSimulationTab();
            verify(scenarioGridPanelMock, times(1)).onResize();
            verify(scenarioGridPanelMock, times(1)).select();
        } else {
            verify(scenarioSimulationEditorPresenterMock, times(1)).selectBackgroundTab();
            verify(backgroundGridPanelMock, times(1)).onResize();
            verify(backgroundGridPanelMock, times(1)).select();
        }
    }
}
Also used : GridWidget(org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget) AbstractScenarioSimulationTest(org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest) Test(org.junit.Test)

Example 3 with GridWidget

use of org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget in project drools-wb by kiegroup.

the class TestToolsPresenter method onModifyColumn.

@Override
public void onModifyColumn() {
    if (editingColumnEnabled) {
        if (selectedListGroupItemView != null) {
            String className = selectedListGroupItemView.getActualClassName();
            getFactModelTreeFromMaps(className).ifPresent(factModelTree -> eventBus.fireEvent(new SetPropertyHeaderEvent(gridWidget, factModelTree.getFullPackage(), factModelTree.getTypeName(), Collections.unmodifiableList(Arrays.asList(className)), factModelTree.getFullTypeName(), FactMappingValueType.EXPRESSION, factModelTree.getImportPrefix())));
        } else if (selectedFieldItemView != null) {
            String baseClass = selectedFieldItemView.getFullPath().get(0);
            List<String> propertyNameElements = new ArrayList<>(selectedFieldItemView.getFullPath());
            if (!isSimple(baseClass)) {
                propertyNameElements.add(selectedFieldItemView.getFieldName());
            }
            getFactModelTreeFromMaps(baseClass).ifPresent(factModelTree -> eventBus.fireEvent(new SetPropertyHeaderEvent(gridWidget, factModelTree.getFullPackage(), factModelTree.getTypeName(), Collections.unmodifiableList(propertyNameElements), selectedFieldItemView.getClassName(), FactMappingValueType.NOT_EXPRESSION, factModelTree.getImportPrefix())));
        }
    }
}
Also used : IDENTIFIER(org.drools.workbench.screens.scenariosimulation.client.rightpanel.TestToolsPresenter.IDENTIFIER) Arrays(java.util.Arrays) EventBus(com.google.gwt.event.shared.EventBus) FactModelTree(org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree) GridWidget(org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget) FactMappingValueType(org.drools.scenariosimulation.api.model.FactMappingValueType) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) List(java.util.List) TreeMap(java.util.TreeMap) SetPropertyHeaderEvent(org.drools.workbench.screens.scenariosimulation.client.events.SetPropertyHeaderEvent) Map(java.util.Map) Optional(java.util.Optional) ScenarioSimulationEditorConstants(org.drools.workbench.screens.scenariosimulation.client.resources.i18n.ScenarioSimulationEditorConstants) ApplicationScoped(javax.enterprise.context.ApplicationScoped) WorkbenchScreen(org.uberfire.client.annotations.WorkbenchScreen) Collections(java.util.Collections) SortedMap(java.util.SortedMap) DEFAULT_PREFERRED_WIDHT(org.drools.workbench.screens.scenariosimulation.client.rightpanel.TestToolsPresenter.DEFAULT_PREFERRED_WIDHT) SetPropertyHeaderEvent(org.drools.workbench.screens.scenariosimulation.client.events.SetPropertyHeaderEvent) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with GridWidget

use of org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget 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 5 with GridWidget

use of org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget in project drools-wb by kiegroup.

the class ScenarioSimulationEditorPresenterTest method onImportCheckSwitch.

@Test
public void onImportCheckSwitch() {
    // Test to verify there are not new, un-managed, GridWidget
    String FILE_CONTENT = "FILE_CONTENT";
    for (GridWidget gridWidget : GridWidget.values()) {
        presenterSpy.onImport(FILE_CONTENT, gridWidget);
    }
    verify(scenarioSimulationEditorWrapperMock, times(1)).onImport(eq(FILE_CONTENT), isA(RemoteCallback.class), isA(ErrorCallback.class), eq(simulationMock));
    verify(scenarioSimulationEditorWrapperMock, times(1)).onImport(eq(FILE_CONTENT), isA(RemoteCallback.class), isA(ErrorCallback.class), eq(backgroundMock));
}
Also used : GridWidget(org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget) ScenarioSimulationHasBusyIndicatorDefaultErrorCallback(org.drools.workbench.screens.scenariosimulation.client.handlers.ScenarioSimulationHasBusyIndicatorDefaultErrorCallback) ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) Matchers.anyString(org.mockito.Matchers.anyString) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) Test(org.junit.Test)

Aggregations

GridWidget (org.drools.workbench.screens.scenariosimulation.client.enums.GridWidget)8 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 SortedMap (java.util.SortedMap)3 TreeMap (java.util.TreeMap)3 ScenarioSimulationContext (org.drools.workbench.screens.scenariosimulation.client.commands.ScenarioSimulationContext)3 FactModelTuple (org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTuple)3 Test (org.junit.Test)3 EventBus (com.google.gwt.event.shared.EventBus)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 FactModelTree (org.drools.workbench.screens.scenariosimulation.model.typedescriptor.FactModelTree)2 Before (org.junit.Before)2 Arrays (java.util.Arrays)1 HashSet (java.util.HashSet)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1