ToolkitPresenter { public void onAstSelectionChanged() { view.clearSourceCodeHighlights(); AstNode firstAstNode = null; for (AstNode astNode : view.getSelectedAstNodes()) { if (firstAstNode == null) { firstAstNode = astNode; } view.highlightSourceCode(astNode); } view.scrollSourceCodeTo(firstAstNode); } ToolkitPresenter(ConfigurationModel configurationModel, SourceCodeModel model); void setView(ToolkitView view); void run(String title); void onSourceCodeOpenButtonClick(); void onSourceCodeParseButtonClick(); void onXPathEvaluateButtonClick(); void onSourceCodeKeyTyped(); void onSourceCodeTextCursorMoved(); void onAstSelectionChanged(); void onConfigurationPropertyFocusLost(String name);  }
@Test public void onAstSelectionChanged() { ToolkitView view = mock(ToolkitView.class); AstNode firstAstNode = mock(AstNode.class); AstNode secondAstNode = mock(AstNode.class); when(view.getSelectedAstNodes()).thenReturn(Arrays.asList(firstAstNode, secondAstNode)); ToolkitPresenter presenter = new ToolkitPresenter(mock(ConfigurationModel.class), mock(SourceCodeModel.class)); presenter.setView(view); presenter.onAstSelectionChanged(); verify(view).clearSourceCodeHighlights(); verify(view).highlightSourceCode(firstAstNode); verify(view).highlightSourceCode(secondAstNode); verify(view).scrollSourceCodeTo(firstAstNode); verify(view, never()).scrollSourceCodeTo(secondAstNode); }