DataSetEditor implements IsWidget,
                                                                     DataSetDefEditor<T> { void onColumnsChangedEvent(@Observes ColumnsChangedEvent columnsChangedEvent) { checkNotNull("columnsChangedEvent", columnsChangedEvent); if (columnsChangedEvent.getContext().equals(columnsAndFilterEditor.columnListEditor().columns())) { final List<DataColumnDef> cols = columnsChangedEvent.getColumns(); dataSetDef.setColumns(cols); doPreview(true); } } @Inject  DataSetEditor(final DataSetDefBasicAttributesEditor basicAttributesEditor,
                         final IsWidget providerAttributesEditorView,
                         final DataSetDefColumnsFilterEditor columnsAndFilterEditor,
                         final DataSetDefPreviewTable previewTable,
                         final DataSetDefBackendCacheAttributesEditor backendCacheAttributesEditor,
                         final DataSetDefClientCacheAttributesEditor clientCacheAttributesEditor,
                         final DataSetDefRefreshAttributesEditor refreshEditor,
                         final DataSetClientServices clientServices,
                         final LoadingBox loadingBox,
                         final Event<ErrorEvent> errorEvent,
                         final Event<TabChangedEvent> tabChangedEvent,
                         final View view); void init(); @Override Widget asWidget(); void showConfigurationTab(); void showPreviewTab(); void showAdvancedTab(); @Override void setAcceptableValues(final List<DataColumnDef> acceptableValues); @Override void flush(); @Override void onPropertyChange(final String... paths); @Override void setValue(final T value); @Override void setDelegate(final EditorDelegate<T> delegate); @Override org.dashbuilder.dataset.client.editor.DataSetDefBasicAttributesEditor basicAttributesEditor(); @Override org.dashbuilder.dataset.client.editor.DataSetDefColumnsFilterEditor columnsAndFilterEditor(); @Override DataSetDefBackendCacheAttributesEditor backendCacheEditor(); @Override org.dashbuilder.dataset.client.editor.DataSetDefClientCacheAttributesEditor clientCacheEditor(); @Override org.dashbuilder.dataset.client.editor.DataSetDefRefreshAttributesEditor refreshEditor(); static final String TAB_CONFIGURATION; static final String TAB_PREVIEW; static final String TAB_ADVANCED; public View view; }
@Test public void testOnColumnsChangedEvent() { final DataColumnDef col1 = mock(DataColumnDef.class); when(col1.getId()).thenReturn("col1"); when(col1.getColumnType()).thenReturn(ColumnType.LABEL); final DataColumnDef col2 = mock(DataColumnDef.class); when(col2.getId()).thenReturn("col2"); when(col2.getColumnType()).thenReturn(ColumnType.NUMBER); final List<DataColumnDef> cols = new ArrayList<DataColumnDef>(); cols.add(col1); cols.add(col2); final ColumnsChangedEvent event = mock(ColumnsChangedEvent.class); when(event.getContext()).thenReturn(columnListEditor); when(event.getColumns()).thenReturn(cols); presenter.dataSetDef = this.dataSetDef; mockPreviewTableCall(); final Command afterPreviewCommand = mock(Command.class); presenter.afterPreviewCommand = afterPreviewCommand; presenter.onColumnsChangedEvent(event); verify(dataSetDef, times(1)).setColumns(cols); verify(loadingBox, times(1)).show(); verify(loadingBox, times(1)).hide(); verify(view, times(1)).clearErrorNotification(); verify(filterEditor, times(1)).init(any(DataSetMetadata.class)); verify(afterPreviewCommand, times(1)).execute(); verify(view, times(0)).init(any(DataSetEditor.class)); verify(view, times(0)).initWidgets( any(DataSetDefBasicAttributesEditor.View.class), any(IsWidget.class), any(DataSetDefColumnsFilterEditor.View.class), any(DataSetDefPreviewTable.View.class), any(DataSetDefCacheAttributesEditorView.class), any(DataSetDefCacheAttributesEditorView.class), any(DataSetDefRefreshAttributesEditor.View.class) ); verify(view, times(0)).addConfigurationTabItemClickHandler(any(Command.class)); verify(view, times(0)).addPreviewTabItemClickHandler(any(Command.class)); verify(view, times(0)).addAdvancedTabItemClickHandler(any(Command.class)); verify(view, times(0)).showConfigurationTab(); verify(view, times(0)).showPreviewTab(); verify(view, times(0)).showAdvancedTab(); verify(view, times(0)).openColumnsFilterPanel(anyString()); verify(view, times(0)).closeColumnsFilterPanel(anyString()); verify(view, times(0)).showErrorNotification(any(SafeHtml.class)); }