DataSetDefWizardScreen { void onTabChangedEvent(@Observes TabChangedEvent tabChangedEvent) { checkNotNull("tabChangedEvent", tabChangedEvent); try { if (tabChangedEvent.getContext().equals(((DataSetEditWorkflow) currentWorkflow).getEditor())) { currentWorkflow.clearButtons(); String tabId = tabChangedEvent.getTabId(); if (tabId != null && DataSetEditor.TAB_CONFIGURATION.equals(tabId)) { currentWorkflow.showTestButton(); } else { currentWorkflow.showBackButton().showNextButton(); } } } catch (final ClassCastException e) { } } @Inject  DataSetDefWizardScreen(final SyncBeanManager beanManager,
                                  final DataSetEditorWorkflowFactory workflowFactory,
                                  final Caller<DataSetDefVfsServices> services,
                                  final DataSetClientServices clientServices,
                                  final Event<NotificationEvent> notification,
                                  final PlaceManager placeManager,
                                  final ErrorPopupPresenter errorPopupPresenter,
                                  final SavePopUpPresenter savePopUpPresenter,
                                  final DataSetDefScreenView view); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getView(); @OnStartup void init(PlaceRequest placeRequest); @OnClose void onClose(); void completeEdition(final DataSetDef dataSetDef,
                                final DataSet dataset); public DataSetDefScreenView view; }
@Test public void testOnTabChangedEvent_ConfigurationTab() { when(editWorkflow.getEditor()).thenReturn(dataSetDefEditor); TabChangedEvent event = mock(TabChangedEvent.class); when(event.getContext()).thenReturn(dataSetDefEditor); when(event.getTabId()).thenReturn(DataSetEditor.TAB_CONFIGURATION); presenter.currentWorkflow = editWorkflow; presenter.onTabChangedEvent(event); verify(editWorkflow, times(1)).clearButtons(); verify(editWorkflow, times(1)).showTestButton(); verify(editWorkflow, times(0)).showNextButton(); verify(editWorkflow, times(0)).showBackButton(); verify(editWorkflow, times(0)).edit(any(SQLDataSetDef.class), any(List.class)); verify(errorPopupPresenter, times(0)).showMessage(anyString()); verify(view, times(0)).setWidget(any(IsWidget.class)); }
@Test public void testOnTabChangedEvent_PreviewTab() { when(editWorkflow.getEditor()).thenReturn(dataSetDefEditor); TabChangedEvent event = mock(TabChangedEvent.class); when(event.getContext()).thenReturn(dataSetDefEditor); when(event.getTabId()).thenReturn(DataSetEditor.TAB_PREVIEW); presenter.currentWorkflow = editWorkflow; presenter.onTabChangedEvent(event); verify(editWorkflow, times(1)).clearButtons(); verify(editWorkflow, times(1)).showNextButton(); verify(editWorkflow, times(1)).showBackButton(); verify(editWorkflow, times(0)).showTestButton(); verify(editWorkflow, times(0)).edit(any(SQLDataSetDef.class), any(List.class)); verify(errorPopupPresenter, times(0)).showMessage(anyString()); verify(view, times(0)).setWidget(any(IsWidget.class)); }
@Test public void testOnTabChangedEvent_AdvancedTab() { when(editWorkflow.getEditor()).thenReturn(dataSetDefEditor); TabChangedEvent event = mock(TabChangedEvent.class); when(event.getContext()).thenReturn(dataSetDefEditor); when(event.getTabId()).thenReturn(DataSetEditor.TAB_ADVANCED); presenter.currentWorkflow = editWorkflow; presenter.onTabChangedEvent(event); verify(editWorkflow, times(1)).clearButtons(); verify(editWorkflow, times(1)).showNextButton(); verify(editWorkflow, times(1)).showBackButton(); verify(editWorkflow, times(0)).showTestButton(); verify(editWorkflow, times(0)).edit(any(SQLDataSetDef.class), any(List.class)); verify(errorPopupPresenter, times(0)).showMessage(anyString()); verify(view, times(0)).setWidget(any(IsWidget.class)); }