ScenarioGrid extends BaseGridWidget { protected void setHeaderColumn(int columnIndex, FactMapping factMapping, boolean editableHeaders) { final FactIdentifier factIdentifier = factMapping.getFactIdentifier(); String columnId = factMapping.getExpressionIdentifier().getName(); String instanceTitle = factMapping.getFactAlias(); String propertyTitle = factMapping.getExpressionAlias(); String columnGroup = factMapping.getExpressionIdentifier().getType().name(); boolean isInstanceAssigned = isInstanceAssigned(factIdentifier); boolean isPropertyAssigned = isPropertyAssigned(isInstanceAssigned, factMapping); String placeHolder = getPlaceHolder(isInstanceAssigned, isPropertyAssigned, factMapping.getFactMappingValueType(), factMapping.getClassName()); ScenarioGridColumn scenarioGridColumn = getScenarioGridColumnLocal(instanceTitle, propertyTitle, columnId, columnGroup, factMapping.getExpressionIdentifier().getType(), placeHolder); scenarioGridColumn.setInstanceAssigned(isInstanceAssigned); scenarioGridColumn.setPropertyAssigned(isPropertyAssigned); scenarioGridColumn.setFactIdentifier(factIdentifier); scenarioGridColumn.setEditableHeaders(editableHeaders); if (FactMappingType.OTHER.equals(factMapping.getExpressionIdentifier().getType())) { scenarioGridColumn.setColumnWidthMode(ColumnWidthMode.FIXED); scenarioGridColumn.setMinimumWidth(scenarioGridColumn.getWidth()); } if (isPropertyAssigned) { BaseSingletonDOMElementFactory factory = ((AbstractScesimGridModel) model).getDOMElementFactory( factMapping.getClassName(), type, factMapping.getFactMappingValueType()); scenarioGridColumn.setFactory(factory); } ((AbstractScesimGridModel) model).insertColumnGridOnly(columnIndex, scenarioGridColumn); } ScenarioGrid(AbstractScesimGridModel model,
                        ScenarioGridLayer scenarioGridLayer,
                        ScenarioGridRenderer renderer,
                        ScenarioContextMenuRegistry scenarioContextMenuRegistry); void setContent(AbstractScesimModel abstractScesimModel, ScenarioSimulationModel.Type type); GridWidget getGridWidget(); EventBus getEventBus(); void setEventBus(EventBus eventBus); void setDefaultSelectedDataCell(int cellX, int cellY); ScenarioSimulationContext getScenarioSimulationContext(); void setScenarioSimulationContext(ScenarioSimulationContext scenarioSimulationContext); @Override AbstractScesimGridModel getModel(); ScenarioSimulationModel.Type getType(); void clearSelections(); void setSelectedColumn(int columnIndex); void setSelectedColumnAndHeader(int headerRowIndex, int columnIndex); void ensureCellIsSelected(); void setSelectedCell(int rowIndex, int columnIndex); @Override boolean adjustSelection(final SelectionExtension direction, final boolean isShiftKeyDown);  }
@Test public void setHeaderColumn() { String columnId = factMappingDescription.getExpressionIdentifier().getName(); FactMappingType type = factMappingDescription.getExpressionIdentifier().getType(); String columnGroup = type.name(); scenarioGridSpy.setType(ScenarioSimulationModel.Type.RULE); scenarioGridSpy.setHeaderColumn(1, factMappingDescription, true); verify(scenarioGridSpy, times(1)).isPropertyAssigned(eq(true), eq(factMappingDescription)); verify(scenarioGridSpy, times(1)).getPlaceHolder(eq(true), eq(true), isA(FactMappingValueType.class), anyString()); verify(scenarioGridSpy, times(1)).getScenarioGridColumnLocal(eq(EXPRESSION_ALIAS_DESCRIPTION), any(), eq(columnId), eq(columnGroup), eq(type), anyString()); verify(scenarioGridColumnMock, times(1)).setColumnWidthMode(ColumnWidthMode.FIXED); verify(scenarioGridModelMock, times(1)).getDOMElementFactory(anyString(), eq(ScenarioSimulationModel.Type.RULE), eq(FactMappingValueType.NOT_EXPRESSION)); reset(scenarioGridSpy); reset(scenarioGridColumnMock); reset(scenarioGridModelMock); columnId = factMappingGiven.getExpressionIdentifier().getName(); type = factMappingGiven.getExpressionIdentifier().getType(); columnGroup = type.name(); scenarioGridSpy.setHeaderColumn(1, factMappingGiven, true); verify(scenarioGridSpy, times(1)).isPropertyAssigned(eq(true), eq(factMappingGiven)); verify(scenarioGridSpy, times(1)).getPlaceHolder(eq(true), eq(false), eq(FactMappingValueType.NOT_EXPRESSION), anyString()); verify(scenarioGridSpy, times(1)).getScenarioGridColumnLocal(eq(EXPRESSION_ALIAS_GIVEN), any(), eq(columnId), eq(columnGroup), eq(type), anyString()); verify(scenarioGridColumnMock, never()).setColumnWidthMode(any()); verify(scenarioGridModelMock, never()).getDOMElementFactory(any(), any(), any()); }