ToolkitPresenter { public void onSourceCodeParseButtonClick() { view.clearConsole(); String sourceCode = view.getSourceCode(); model.setSourceCode(sourceCode); Point sourceCodeScrollbarPosition = view.getSourceCodeScrollbarPosition(); view.displayHighlightedSourceCode(model.getHighlightedSourceCode()); view.displayAst(model.getAstNode()); view.displayXml(model.getXml()); view.scrollSourceCodeTo(sourceCodeScrollbarPosition); view.setFocusOnAbstractSyntaxTreeView(); view.enableXPathEvaluateButton(); } 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 onSourceCodeParseButtonClick() { ToolkitView view = mock(ToolkitView.class); when(view.getSourceCode()).thenReturn("my_mocked_source"); Point point = mock(Point.class); when(view.getSourceCodeScrollbarPosition()).thenReturn(point); SourceCodeModel model = mock(SourceCodeModel.class); when(model.getHighlightedSourceCode()).thenReturn("my_mocked_highlighted_source_code"); AstNode astNode = mock(AstNode.class); when(model.getAstNode()).thenReturn(astNode); when(model.getXml()).thenReturn("my_mocked_xml"); ToolkitPresenter presenter = new ToolkitPresenter(mock(ConfigurationModel.class), model); presenter.setView(view); presenter.onSourceCodeParseButtonClick(); verify(view).clearConsole(); verify(view).getSourceCode(); verify(model).setSourceCode("my_mocked_source"); verify(view).displayHighlightedSourceCode("my_mocked_highlighted_source_code"); view.displayAst(astNode); view.displayXml("my_mocked_xml"); view.scrollSourceCodeTo(point); verify(view).setFocusOnAbstractSyntaxTreeView(); verify(view).enableXPathEvaluateButton(); }