@Test public void testEnumerations() { ComponentTableModel componentTableModel = Mockito.mock(ComponentTableModel.class); TableCellSettings settings1 = Mockito.mock(TableCellSettings.class); TableCellSettings settings2 = Mockito.mock(TableCellSettings.class); TableCellSettings settings3 = Mockito.mock(TableCellSettings.class); TableCellSettings settings4 = Mockito.mock(TableCellSettings.class); AbstractComponent compWithFeed1 = Mockito.mock(AbstractComponent.class); AbstractComponent compWithFeed2 = Mockito.mock(AbstractComponent.class); AbstractComponent compWithFeed3 = Mockito.mock(AbstractComponent.class); AbstractComponent compWithFeed4 = Mockito.mock(AbstractComponent.class); Mockito.when(compWithFeed1.getComponentId()).thenReturn("comp 1"); Mockito.when(compWithFeed2.getComponentId()).thenReturn("comp 2"); Mockito.when(compWithFeed3.getComponentId()).thenReturn("comp 3"); Mockito.when(compWithFeed4.getComponentId()).thenReturn("comp 4"); AbstractComponent evaluator1 = Mockito.mock(AbstractComponent.class); AbstractComponent evaluator2 = Mockito.mock(AbstractComponent.class); AbstractComponent evaluator3 = Mockito.mock(AbstractComponent.class); AbstractComponent evaluator4 = Mockito.mock(AbstractComponent.class); Mockito.when(evaluator1.getId()).thenReturn("eval 1"); Mockito.when(evaluator2.getId()).thenReturn("eval 2"); Mockito.when(evaluator3.getId()).thenReturn("eval 3"); Mockito.when(evaluator4.getId()).thenReturn("eval 4"); Mockito.when(settings1.getEvaluator()).thenReturn(evaluator1); Mockito.when(settings2.getEvaluator()).thenReturn(null); Mockito.when(settings3.getEvaluator()).thenReturn(evaluator2); Mockito.when(settings4.getEvaluator()).thenReturn(evaluator1); FeedProvider mockFp1 = Mockito.mock(FeedProvider.class); FeedProvider mockFp2 = Mockito.mock(FeedProvider.class); FeedProvider mockFp3 = Mockito.mock(FeedProvider.class); FeedProvider mockFp4 = Mockito.mock(FeedProvider.class); Mockito.when(mockFp1.getSubscriptionId()).thenReturn("sub1"); Mockito.when(mockFp2.getSubscriptionId()).thenReturn("sub2"); Mockito.when(mockFp3.getSubscriptionId()).thenReturn("sub3"); Mockito.when(mockFp4.getSubscriptionId()).thenReturn("sub4"); Mockito.when(compWithFeed1.getCapability(FeedProvider.class)).thenReturn(mockFp1); Mockito.when(compWithFeed2.getCapability(FeedProvider.class)).thenReturn(mockFp2); Mockito.when(compWithFeed3.getCapability(FeedProvider.class)).thenReturn(mockFp3); Mockito.when(compWithFeed4.getCapability(FeedProvider.class)).thenReturn(mockFp4); Mockito.when(componentTableModel.getStoredValueAt(Mockito.anyInt(), Mockito.anyInt())).thenReturn(compWithFeed1); Assert.assertEquals(compWithFeed1.getComponentId(), "comp 1"); Mockito.when(componentTableModel.getKey(compWithFeed1)).thenReturn("sub1"); Mockito.when(componentTableModel.getKey(compWithFeed2)).thenReturn("sub2"); Mockito.when(componentTableModel.getKey(compWithFeed3)).thenReturn("sub3"); Mockito.when(componentTableModel.getKey(compWithFeed4)).thenReturn("sub4"); Mockito.when(componentTableModel.getCellSettings("sub1")).thenReturn(settings1); Mockito.when(componentTableModel.getCellSettings("sub2")).thenReturn(settings2); Mockito.when(componentTableModel.getCellSettings("sub3")).thenReturn(settings3); Mockito.when(componentTableModel.getCellSettings("sub4")).thenReturn(settings4); controller = new TableControlPanelController(manifestation, labeledTable, componentTableModel); Mockito.when(labeledTable.getSelectedRows()).thenReturn(new int[] {0,1,2,3}); Mockito.when(labeledTable.getSelectedColumns()).thenReturn(new int[] {0}); Assert.assertFalse(controller.selectedCellsHaveMixedEnumerations()); Mockito.when(componentTableModel.getStoredValueAt(3, 0)).thenReturn(compWithFeed4); Assert.assertFalse(controller.selectedCellsHaveMixedEnumerations()); Mockito.when(componentTableModel.getStoredValueAt(1, 0)).thenReturn(compWithFeed2); Assert.assertTrue(controller.selectedCellsHaveMixedEnumerations()); }
@Override public boolean selectedCellsHaveMixedEnumerations() { AbstractComponent commonSelectedEvaluator = null; ComponentTableModel tableModel = ComponentTableModel.class.cast(model); boolean firstCell = true; for (int row : table.getSelectedRows()) { for (int column : table.getSelectedColumns()) { AbstractComponent component = (AbstractComponent) model.getStoredValueAt(row, column); if (component == null) { return true; } AbstractComponent referencedComponent = component; TableCellSettings cellSettings = tableModel.getCellSettings(tableModel.getKey(referencedComponent)); AbstractComponent evaluator = cellSettings.getEvaluator(); if (commonSelectedEvaluator != null) if (evaluator != null) { if (!evaluator.getId().equals(commonSelectedEvaluator.getId())) { return true; } } else { return true; } else { if (evaluator != null && !firstCell) { return true; } } commonSelectedEvaluator = evaluator; firstCell = false; } } return false; }
TableControlPanelController extends TableSettingsController { @Override public boolean selectedCellsHaveMixedEnumerations() { AbstractComponent commonSelectedEvaluator = null; ComponentTableModel tableModel = ComponentTableModel.class.cast(model); boolean firstCell = true; for (int row : table.getSelectedRows()) { for (int column : table.getSelectedColumns()) { AbstractComponent component = (AbstractComponent) model.getStoredValueAt(row, column); if (component == null) { return true; } AbstractComponent referencedComponent = component; TableCellSettings cellSettings = tableModel.getCellSettings(tableModel.getKey(referencedComponent)); AbstractComponent evaluator = cellSettings.getEvaluator(); if (commonSelectedEvaluator != null) if (evaluator != null) { if (!evaluator.getId().equals(commonSelectedEvaluator.getId())) { return true; } } else { return true; } else { if (evaluator != null && !firstCell) { return true; } } commonSelectedEvaluator = evaluator; firstCell = false; } } return false; } }
TableControlPanelController extends TableSettingsController { @Override public boolean selectedCellsHaveMixedEnumerations() { AbstractComponent commonSelectedEvaluator = null; ComponentTableModel tableModel = ComponentTableModel.class.cast(model); boolean firstCell = true; for (int row : table.getSelectedRows()) { for (int column : table.getSelectedColumns()) { AbstractComponent component = (AbstractComponent) model.getStoredValueAt(row, column); if (component == null) { return true; } AbstractComponent referencedComponent = component; TableCellSettings cellSettings = tableModel.getCellSettings(tableModel.getKey(referencedComponent)); AbstractComponent evaluator = cellSettings.getEvaluator(); if (commonSelectedEvaluator != null) if (evaluator != null) { if (!evaluator.getId().equals(commonSelectedEvaluator.getId())) { return true; } } else { return true; } else { if (evaluator != null && !firstCell) { return true; } } commonSelectedEvaluator = evaluator; firstCell = false; } } return false; } TableControlPanelController(TableViewManifestation manifestation, LabeledTable table, LabeledTableModel model); }
TableControlPanelController extends TableSettingsController { @Override public boolean selectedCellsHaveMixedEnumerations() { AbstractComponent commonSelectedEvaluator = null; ComponentTableModel tableModel = ComponentTableModel.class.cast(model); boolean firstCell = true; for (int row : table.getSelectedRows()) { for (int column : table.getSelectedColumns()) { AbstractComponent component = (AbstractComponent) model.getStoredValueAt(row, column); if (component == null) { return true; } AbstractComponent referencedComponent = component; TableCellSettings cellSettings = tableModel.getCellSettings(tableModel.getKey(referencedComponent)); AbstractComponent evaluator = cellSettings.getEvaluator(); if (commonSelectedEvaluator != null) if (evaluator != null) { if (!evaluator.getId().equals(commonSelectedEvaluator.getId())) { return true; } } else { return true; } else { if (evaluator != null && !firstCell) { return true; } } commonSelectedEvaluator = evaluator; firstCell = false; } } return false; } TableControlPanelController(TableViewManifestation manifestation, LabeledTable table, LabeledTableModel model); @Override boolean getShowGrid(); @Override TableOrientation getTableOrientation(); @Override void setShowGrid(boolean showGrid); @Override void setTableOrientation(TableOrientation orientation); @Override void transposeTable(); @Override int getSelectedCellCount(); @Override int getSelectedColumnCount(); @Override int getSelectedRowCount(); @Override boolean isCanHideHeaders(); @Override int getColumnWidth(); @Override int getRowHeight(); @Override void setColumnWidth(int newWidth); @Override void setRowHeight(int newHeight); boolean isSingleCellSelection(); @Override ComboBoxModel getEnumerationModel(); @Override boolean selectedCellsHaveMixedEnumerations(); @Override void setEnumeration(ComboBoxModel comboBoxModel); @Override boolean enumerationIsNone(ComboBoxModel model); @Override boolean dateIsNone(ComboBoxModel model); @Override boolean showDecimalPlaces(); @Override Integer getDecimalPlaces(); @Override JVMFontFamily getCellFontName(); @Override Integer getCellFontSize(); @Override Color getCellFontColor(); @Override Color getCellBackgroundColor(); @Override Integer getCellFontStyle(); @Override Integer getCellFontTextAttribute(); @Override void setDecimalPlaces(ComboBoxModel comboBoxModel); @Override void setCellFont(ComboBoxModel comboBoxModel); @Override void setCellFontColor(Color fontColor); @Override void setCellBackgroundColor(Color backgroundColor); @Override void setCellFontSize(int fontSize); @Override void setCellFontStyle(int fontStyle); @Override void setCellFontTextAttribute(int fontStyle); @Override DateFormatItem getDateFormat(); @Override void setDateFormat(ComboBoxModel comboBoxModel); @Override boolean canSetOrientation(); @Override boolean canTranspose(); @Override AbbreviationSettings getRowLabelAbbreviationSettings(); @Override void setRowLabelAbbreviations(AbbreviationSettings settings); @Override AbbreviationSettings getColumnLabelAbbreviationSettings(); @Override void setColumnLabelAbbreviations(AbbreviationSettings settings); @Override AbbreviationSettings getCellLabelAbbreviationSettings(); @Override void setCellLabelAbbreviations(AbbreviationSettings settings); @Override ContentAlignment getRowHeaderAlignment(); @Override void setRowHeaderAlignment(ContentAlignment newAlignment); @Override BorderState getRowHeaderBorderState(); @Override void setRowHeaderBorderState(BorderState newBorderState); @Override void setRowHeaderFontName(ComboBoxModel comboBoxModel); @Override void setRowHeaderFontStyle(int newStyle); @Override void setRowHeaderTextAttribute(int newTextAttribute); @Override void setColumnHeaderTextAttribute(int newTextAttribute); @Override void setColumnHeaderFontName(ComboBoxModel comboBoxModel); @Override void setColumnHeaderFontStyle(int fontStyle); @Override ContentAlignment getColumnHeaderAlignment(); @Override void setColumnHeaderAlignment(ContentAlignment newAlignment); @Override BorderState getColumnHeaderBorderState(); @Override void setColumnHeaderBorderState(BorderState newBorderState); @Override ContentAlignment getCellAlignment(); @Override void setCellAlignment(ContentAlignment newAlignment); @Override int getTableRowCount(); @Override int getTableColumnCount(); @Override BorderState getBorderState(); @Override void mergeCellFontStyle(ButtonModel boldModel, ButtonModel italicModel); @Override void mergeBorderState(BorderState controllerState); @Override void mergeRowHeaderBorderState(BorderState controllerState); @Override void mergeColumnHeaderBorderState(BorderState controllerState); @Override void setRowHeaderFontSize(int fontSize); @Override void setColumnHeaderFontSize(int fontSize); @Override void setRowHeaderFontColor(Color fontColor); @Override void setRowHeaderBorderColor(Color borderColor); @Override void setColumnHeaderFontColor(Color fontColor); @Override void setColumnHeaderBorderColor(Color borderColor); @Override void setRowHeaderBackgroundColor(Color fontColor); @Override void setColumnHeaderBackgroundColor(Color fontColor); @Override Integer getRowFontStyle(); @Override Integer getRowHeaderTextAttribute(); @Override Integer getColumnHeaderTextAttribute(); @Override JVMFontFamily getRowHeaderFontName(); @Override Integer getColumnHeaderFontStyle(); @Override Integer getRowHeaderFontSize(); @Override Integer getColumnHeaderFontSize(); @Override Color getRowHeaderFontColor(); @Override Color getRowHeaderBorderColor(); @Override Color getColumnHeaderFontColor(); @Override Color getColumnHeaderBorderColor(); @Override Color getRowHeaderBackgroundColor(); @Override Color getColumnHeaderBackgroundColor(); @Override JVMFontFamily getColumnHeaderFontName(); }
TableControlPanelController extends TableSettingsController { @Override public boolean selectedCellsHaveMixedEnumerations() { AbstractComponent commonSelectedEvaluator = null; ComponentTableModel tableModel = ComponentTableModel.class.cast(model); boolean firstCell = true; for (int row : table.getSelectedRows()) { for (int column : table.getSelectedColumns()) { AbstractComponent component = (AbstractComponent) model.getStoredValueAt(row, column); if (component == null) { return true; } AbstractComponent referencedComponent = component; TableCellSettings cellSettings = tableModel.getCellSettings(tableModel.getKey(referencedComponent)); AbstractComponent evaluator = cellSettings.getEvaluator(); if (commonSelectedEvaluator != null) if (evaluator != null) { if (!evaluator.getId().equals(commonSelectedEvaluator.getId())) { return true; } } else { return true; } else { if (evaluator != null && !firstCell) { return true; } } commonSelectedEvaluator = evaluator; firstCell = false; } } return false; } TableControlPanelController(TableViewManifestation manifestation, LabeledTable table, LabeledTableModel model); @Override boolean getShowGrid(); @Override TableOrientation getTableOrientation(); @Override void setShowGrid(boolean showGrid); @Override void setTableOrientation(TableOrientation orientation); @Override void transposeTable(); @Override int getSelectedCellCount(); @Override int getSelectedColumnCount(); @Override int getSelectedRowCount(); @Override boolean isCanHideHeaders(); @Override int getColumnWidth(); @Override int getRowHeight(); @Override void setColumnWidth(int newWidth); @Override void setRowHeight(int newHeight); boolean isSingleCellSelection(); @Override ComboBoxModel getEnumerationModel(); @Override boolean selectedCellsHaveMixedEnumerations(); @Override void setEnumeration(ComboBoxModel comboBoxModel); @Override boolean enumerationIsNone(ComboBoxModel model); @Override boolean dateIsNone(ComboBoxModel model); @Override boolean showDecimalPlaces(); @Override Integer getDecimalPlaces(); @Override JVMFontFamily getCellFontName(); @Override Integer getCellFontSize(); @Override Color getCellFontColor(); @Override Color getCellBackgroundColor(); @Override Integer getCellFontStyle(); @Override Integer getCellFontTextAttribute(); @Override void setDecimalPlaces(ComboBoxModel comboBoxModel); @Override void setCellFont(ComboBoxModel comboBoxModel); @Override void setCellFontColor(Color fontColor); @Override void setCellBackgroundColor(Color backgroundColor); @Override void setCellFontSize(int fontSize); @Override void setCellFontStyle(int fontStyle); @Override void setCellFontTextAttribute(int fontStyle); @Override DateFormatItem getDateFormat(); @Override void setDateFormat(ComboBoxModel comboBoxModel); @Override boolean canSetOrientation(); @Override boolean canTranspose(); @Override AbbreviationSettings getRowLabelAbbreviationSettings(); @Override void setRowLabelAbbreviations(AbbreviationSettings settings); @Override AbbreviationSettings getColumnLabelAbbreviationSettings(); @Override void setColumnLabelAbbreviations(AbbreviationSettings settings); @Override AbbreviationSettings getCellLabelAbbreviationSettings(); @Override void setCellLabelAbbreviations(AbbreviationSettings settings); @Override ContentAlignment getRowHeaderAlignment(); @Override void setRowHeaderAlignment(ContentAlignment newAlignment); @Override BorderState getRowHeaderBorderState(); @Override void setRowHeaderBorderState(BorderState newBorderState); @Override void setRowHeaderFontName(ComboBoxModel comboBoxModel); @Override void setRowHeaderFontStyle(int newStyle); @Override void setRowHeaderTextAttribute(int newTextAttribute); @Override void setColumnHeaderTextAttribute(int newTextAttribute); @Override void setColumnHeaderFontName(ComboBoxModel comboBoxModel); @Override void setColumnHeaderFontStyle(int fontStyle); @Override ContentAlignment getColumnHeaderAlignment(); @Override void setColumnHeaderAlignment(ContentAlignment newAlignment); @Override BorderState getColumnHeaderBorderState(); @Override void setColumnHeaderBorderState(BorderState newBorderState); @Override ContentAlignment getCellAlignment(); @Override void setCellAlignment(ContentAlignment newAlignment); @Override int getTableRowCount(); @Override int getTableColumnCount(); @Override BorderState getBorderState(); @Override void mergeCellFontStyle(ButtonModel boldModel, ButtonModel italicModel); @Override void mergeBorderState(BorderState controllerState); @Override void mergeRowHeaderBorderState(BorderState controllerState); @Override void mergeColumnHeaderBorderState(BorderState controllerState); @Override void setRowHeaderFontSize(int fontSize); @Override void setColumnHeaderFontSize(int fontSize); @Override void setRowHeaderFontColor(Color fontColor); @Override void setRowHeaderBorderColor(Color borderColor); @Override void setColumnHeaderFontColor(Color fontColor); @Override void setColumnHeaderBorderColor(Color borderColor); @Override void setRowHeaderBackgroundColor(Color fontColor); @Override void setColumnHeaderBackgroundColor(Color fontColor); @Override Integer getRowFontStyle(); @Override Integer getRowHeaderTextAttribute(); @Override Integer getColumnHeaderTextAttribute(); @Override JVMFontFamily getRowHeaderFontName(); @Override Integer getColumnHeaderFontStyle(); @Override Integer getRowHeaderFontSize(); @Override Integer getColumnHeaderFontSize(); @Override Color getRowHeaderFontColor(); @Override Color getRowHeaderBorderColor(); @Override Color getColumnHeaderFontColor(); @Override Color getColumnHeaderBorderColor(); @Override Color getRowHeaderBackgroundColor(); @Override Color getColumnHeaderBackgroundColor(); @Override JVMFontFamily getColumnHeaderFontName();  }