ColumnHeaderPopOverHandler implements NodeMouseMoveHandler { @Override public void onNodeMouseMove( final NodeMouseMoveEvent event ) { columnPopOverPresenter.hide(); for ( GuidedDecisionTableView.Presenter dtPresenter : modellerPresenter.getAvailableDecisionTables() ) { final GuidedDecisionTableView dtView = dtPresenter.getView(); if ( !dtView.isVisible() ) { continue; } final Point2D ap = CoordinateUtilities.convertDOMToGridCoordinate( dtView, new Point2D( event.getX(), event.getY() ) ); if ( !isMouseOverTableHeader( dtView, ap.getY() ) ) { continue; } final Integer uiColumnIndex = getUiColumn( dtView, ap.getX() ); if ( uiColumnIndex == null ) { continue; } columnPopOverPresenter.show( modellerPresenter.getView(), dtPresenter, uiColumnIndex ); } } ColumnHeaderPopOverHandler( final GuidedDecisionTableModellerView.Presenter modellerPresenter,
                                       final ColumnHeaderPopOver columnPopOverPresenter ); @Override void onNodeMouseMove( final NodeMouseMoveEvent event );  }
@Test public void popOverHiddenOnMouseMoveEvent() { handler.onNodeMouseMove(event); verify(columnPopOverPresenter, times(1)).hide(); }
@Test public void noPopOverWhenNoDecisionTables() { handler.onNodeMouseMove(event); verify(columnPopOverPresenter, never()).show(any(GuidedDecisionTableModellerView.class), any(GuidedDecisionTableView.Presenter.class), any(Integer.class)); }
@Test public void noPopOverWhenEventNotOverDecisionTableHeader() { when(modellerPresenter.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {{ add(dtPresenter1); }}); when(event.getX()).thenReturn(50); when(event.getY()).thenReturn(100); when(dtView1.getComputedLocation()).thenReturn(new Point2D(0, 0)); handler.onNodeMouseMove(event); verify(columnPopOverPresenter, never()).show(any(GuidedDecisionTableModellerView.class), any(GuidedDecisionTableView.Presenter.class), any(Integer.class)); }
@Test public void noPopOverWhenEventNotOverDecisionTableColumn() { when(modellerPresenter.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {{ add(dtPresenter1); }}); when(event.getX()).thenReturn(150); when(event.getY()).thenReturn(50); when(dtView1.getComputedLocation()).thenReturn(new Point2D(0, 0)); handler.onNodeMouseMove(event); verify(columnPopOverPresenter, never()).show(any(GuidedDecisionTableModellerView.class), any(GuidedDecisionTableView.Presenter.class), any(Integer.class)); }
@Test public void popOverWhenEventOverDecisionTableHeaderAndColumn() { when(modellerPresenter.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {{ add(dtPresenter1); }}); when(event.getX()).thenReturn(50); when(event.getY()).thenReturn(50); when(dtView1.getComputedLocation()).thenReturn(new Point2D(0, 0)); handler.onNodeMouseMove(event); verify(columnPopOverPresenter, times(1)).show(any(GuidedDecisionTableModellerView.class), eq(dtPresenter1), eq(0)); }
@Test public void popOverWhenEventOverDecisionTableHeaderAndColumnWithMultipleTables() { when(modellerPresenter.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {{ add(dtPresenter1); add(dtPresenter2); }}); when(dtView1.getComputedLocation()).thenReturn(new Point2D(0, 0)); when(dtView2.getComputedLocation()).thenReturn(new Point2D(200, 200)); when(event.getX()).thenReturn(50); when(event.getY()).thenReturn(50); handler.onNodeMouseMove(event); verify(columnPopOverPresenter, times(1)).show(any(GuidedDecisionTableModellerView.class), eq(dtPresenter1), eq(0)); when(event.getX()).thenReturn(250); when(event.getY()).thenReturn(250); handler.onNodeMouseMove(event); verify(columnPopOverPresenter, times(1)).show(any(GuidedDecisionTableModellerView.class), eq(dtPresenter2), eq(0)); }