ColumnFunctionEditor implements IsWidget { public void init(DataSetMetadata metadata, GroupFunction groupFunction, ColumnType targetType, String columnTitle, boolean functionsEnabled, boolean canDelete) { this.groupFunction = groupFunction; this.targetType = targetType; this.metadata = metadata; this.functionsEnabled = functionsEnabled; columnDetailsEditor.init(metadata, this.groupFunction); view.setColumnSelectorTitle(columnTitle); view.setDeleteOptionEnabled(canDelete); initColumnListBox(); if (functionsEnabled && (targetType == null || isColumnNumeric())) { view.setFunctionSelectorEnabled(true); initFunctionListBox(); } else { view.setFunctionSelectorEnabled(false); } } @Inject  ColumnFunctionEditor(View view,
                                ColumnDetailsEditor columnDetailsEditor,
                                Event<GroupFunctionChangedEvent> changeEvent,
                                Event<GroupFunctionDeletedEvent> deleteEvent); @Override Widget asWidget(); GroupFunction getGroupFunction(); ColumnType getTargetType(); ColumnDetailsEditor getColumnDetailsEditor(); void init(DataSetMetadata metadata,
                     GroupFunction groupFunction,
                     ColumnType targetType,
                     String columnTitle,
                     boolean functionsEnabled,
                     boolean canDelete); void delete(); List<AggregateFunctionType> getSupportedFunctionTypes(); List<AggregateFunctionType> getSupportedFunctionTypes(ColumnType columnType);  }
@Test public void testViewInitialization() { GroupFunction groupFunction = new GroupFunction("column1", "column1", null); presenter.init(metadata, groupFunction, null, "Title", false, false); verify(view).setDeleteOptionEnabled(false); verify(view, never()).setDeleteOptionEnabled(true); verify(view).setColumnSelectorTitle("Title"); verify(view).clearColumnSelector(); verify(view, times(3)).addColumnItem(anyString()); verify(view).setSelectedColumnIndex(0); verify(view).setFunctionSelectorEnabled(false); verify(view, never()).setFunctionSelectorEnabled(true); }
@Test public void testLabelTarget() { GroupFunction groupFunction = new GroupFunction("column1", "column1", null); presenter.init(metadata, groupFunction, ColumnType.LABEL, "Title", true, true); verify(view).clearColumnSelector(); verify(view, times(1)).addColumnItem(anyString()); verify(view).setSelectedColumnIndex(0); verify(view).setFunctionSelectorEnabled(false); verify(view, never()).setFunctionSelectorEnabled(true); }