Search in sources :

Example 11 with ScenarioHeaderMetaData

use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.

the class ScenarioGridTest method setup.

@Before
public void setup() {
    simulation = getSimulation();
    when(scenarioGridColumnMock.getPropertyHeaderMetaData()).thenReturn(propertyHeaderMetadataMock);
    when(scenarioGridModelMock.getAbstractScesimModel()).thenReturn(Optional.of(simulation));
    when(scenarioGridModelMock.getGridWidget()).thenReturn(GridWidget.SIMULATION);
    when(scenarioGridModelMock.getScenarioExpressionCellTextAreaSingletonDOMElementFactory()).thenReturn(expressionCellTextAreaSingletonDOMElementFactoryMock);
    when(scenarioGridModelMock.getCollectionEditorSingletonDOMElementFactory()).thenReturn(collectionEditorSingletonDOMElementFactory);
    factIdentifierGiven = FactIdentifier.create("GIVEN", "GIVEN");
    factIdentifierInteger = FactIdentifier.create("Integer", "java.lang.Integer");
    factMappingDescription = new FactMapping(EXPRESSION_ALIAS_DESCRIPTION, FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION);
    factMappingGiven = new FactMapping(EXPRESSION_ALIAS_GIVEN, factIdentifierGiven, new ExpressionIdentifier("GIVEN", FactMappingType.GIVEN));
    factMappingInteger = new FactMapping(EXPRESSION_ALIAS_INTEGER, factIdentifierInteger, new ExpressionIdentifier("GIVEN", FactMappingType.GIVEN));
    scenarioGridSpy = spy(new ScenarioGrid(scenarioGridModelMock, scenarioGridLayerMock, scenarioGridRendererMock, scenarioContextMenuRegistryMock) {

        @Override
        protected <T extends AbstractScesimData> void appendRow(int rowIndex, T scesimData) {
        // do nothing
        }

        @Override
        protected ScenarioSimulationBuilders.HeaderBuilder getHeaderBuilderLocal(String instanceTitle, String propertyTitle, String columnId, String columnGroup, FactMappingType factMappingType) {
            return headerBuilderMock;
        }

        @Override
        protected ScenarioGridColumn getScenarioGridColumnLocal(ScenarioSimulationBuilders.HeaderBuilder headerBuilder, String placeHolder) {
            return scenarioGridColumnMock;
        }

        @Override
        protected BaseGridRendererHelper getBaseGridRendererHelper() {
            return rendererHelperMock;
        }

        @Override
        public Viewport getViewport() {
            return viewportMock;
        }

        @Override
        protected ScenarioHeaderMetaData getColumnScenarioHeaderMetaData(final ScenarioGridColumn scenarioGridColumn, final int rowIndex) {
            return propertyHeaderMetadataMock;
        }

        @Override
        protected EnableTestToolsEvent getEnableTestToolsEvent(final ScenarioGrid scenarioGrid, final ScenarioGridColumn scenarioGridColumn, final ScenarioHeaderMetaData scenarioHeaderMetaData, int uiColumnIndex, String group) {
            return new EnableTestToolsEvent();
        }

        @Override
        public Layer getLayer() {
            return scenarioGridLayerMock;
        }
    });
    when(rendererHelperMock.getRenderingInformation()).thenReturn(renderingInformationMock);
    when(renderingInformationMock.getHeaderRowsHeight()).thenReturn(HEADER_ROWS_HEIGHT);
    when(renderingInformationMock.getFloatingBlockInformation()).thenReturn(floatingBlockInformationMock);
    when(propertyHeaderMetadataMock.getColumnGroup()).thenReturn(GRID_COLUMN_GROUP);
    scenarioGridSpy.setEventBus(eventBusMock);
}
Also used : FactMapping(org.drools.scenariosimulation.api.model.FactMapping) ScenarioSimulationBuilders(org.drools.workbench.screens.scenariosimulation.client.utils.ScenarioSimulationBuilders) HEADER_ROWS_HEIGHT(org.drools.workbench.screens.scenariosimulation.client.TestProperties.HEADER_ROWS_HEIGHT) TEST(org.drools.workbench.screens.scenariosimulation.client.TestProperties.TEST) ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData) AbstractScesimData(org.drools.scenariosimulation.api.model.AbstractScesimData) ExpressionIdentifier(org.drools.scenariosimulation.api.model.ExpressionIdentifier) FactMappingType(org.drools.scenariosimulation.api.model.FactMappingType) EnableTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Before(org.junit.Before)

Example 12 with ScenarioHeaderMetaData

use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.

the class ScenarioSimulationGridHeaderUtilitiesTest method testIsHeaderEditableInstanceAndPropertyAssignedAndPropertySelected.

@Test
public void testIsHeaderEditableInstanceAndPropertyAssignedAndPropertySelected() {
    when(scenarioGridColumnOne.isInstanceAssigned()).thenReturn(true);
    when(scenarioGridColumnOne.isPropertyAssigned()).thenReturn(true);
    final ScenarioHeaderMetaData metaDataMock = (ScenarioHeaderMetaData) scenarioGridColumnOne.getHeaderMetaData().get(0);
    when(metaDataMock.isPropertyHeader()).thenReturn(true);
    final boolean result = ScenarioSimulationGridHeaderUtilities.isEditableHeader(scenarioGridColumnOne, 0);
    assertThat(result).as("Instance and Property Assigned and Property selected").isTrue();
}
Also used : ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData) AbstractScenarioSimulationTest(org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest) Test(org.junit.Test)

Example 13 with ScenarioHeaderMetaData

use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.

the class ScenarioSimulationGridHeaderUtilitiesTest method mockGridColumn.

private ScenarioGridColumn mockGridColumn(final double width, final List<GridColumn.HeaderMetaData> headerMetaData, final String columnTitle, final String COLUMN_GROUP) {
    final ScenarioGridColumn uiColumn = mock(ScenarioGridColumn.class);
    doReturn(headerMetaData).when(uiColumn).getHeaderMetaData();
    doReturn(width).when(uiColumn).getWidth();
    final ScenarioHeaderMetaData informationHeader = mock(ScenarioHeaderMetaData.class);
    when(informationHeader.getColumnGroup()).thenReturn(COLUMN_GROUP);
    when(informationHeader.getTitle()).thenReturn(columnTitle);
    when(uiColumn.getInformationHeaderMetaData()).thenReturn(informationHeader);
    when(uiColumn.isEditableHeaders()).thenReturn(true);
    return uiColumn;
}
Also used : ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData) ScenarioGridColumn(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn)

Example 14 with ScenarioHeaderMetaData

use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.

the class ScenarioSimulationGridHeaderUtilitiesTest method testIsHeaderEditableInstanceAndPropertyAssignedButNotSelected.

@Test
public void testIsHeaderEditableInstanceAndPropertyAssignedButNotSelected() {
    when(scenarioGridColumnOne.isInstanceAssigned()).thenReturn(true);
    when(scenarioGridColumnOne.isPropertyAssigned()).thenReturn(true);
    final ScenarioHeaderMetaData metaDataMock = (ScenarioHeaderMetaData) scenarioGridColumnOne.getHeaderMetaData().get(0);
    when(metaDataMock.isPropertyHeader()).thenReturn(false);
    when(metaDataMock.isInstanceHeader()).thenReturn(false);
    final boolean result = ScenarioSimulationGridHeaderUtilities.isEditableHeader(scenarioGridColumnOne, 0);
    assertThat(result).as("Instance and Property Assigned but not selected").isFalse();
}
Also used : ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData) AbstractScenarioSimulationTest(org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest) Test(org.junit.Test)

Example 15 with ScenarioHeaderMetaData

use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.

the class ScenarioSimulationGridHeaderUtilitiesTest method testIsHeaderEditableInstanceAssignedAndSelected.

@Test
public void testIsHeaderEditableInstanceAssignedAndSelected() {
    when(scenarioGridColumnOne.isInstanceAssigned()).thenReturn(true);
    final ScenarioHeaderMetaData metaDataMock = (ScenarioHeaderMetaData) scenarioGridColumnOne.getHeaderMetaData().get(0);
    when(metaDataMock.isInstanceHeader()).thenReturn(true);
    final boolean result = ScenarioSimulationGridHeaderUtilities.isEditableHeader(scenarioGridColumnOne, 0);
    assertThat(result).as("Instance Assigned and selected").isTrue();
}
Also used : ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData) AbstractScenarioSimulationTest(org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest) Test(org.junit.Test)

Aggregations

ScenarioHeaderMetaData (org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData)19 ScenarioGridColumn (org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn)6 Test (org.junit.Test)6 AbstractScenarioSimulationTest (org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest)4 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)3 FactMapping (org.drools.scenariosimulation.api.model.FactMapping)2 FactMappingType (org.drools.scenariosimulation.api.model.FactMappingType)2 EnableTestToolsEvent (org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent)2 ReloadTestToolsEvent (org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent)2 Before (org.junit.Before)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 AbstractNodeMouseEvent (com.ait.lienzo.client.core.event.AbstractNodeMouseEvent)1 Viewport (com.ait.lienzo.client.core.shape.Viewport)1 Point2D (com.ait.lienzo.client.core.types.Point2D)1 Date (java.util.Date)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 SortedMap (java.util.SortedMap)1 AbstractScesimData (org.drools.scenariosimulation.api.model.AbstractScesimData)1