@Test public void initUncaughtExceptionsHandler() throws InterruptedException { ToolkitView view = mock(ToolkitView.class); ToolkitPresenter presenter = new ToolkitPresenter(mock(ConfigurationModel.class), mock(SourceCodeModel.class)); presenter.setView(view); presenter.initUncaughtExceptionsHandler(); UncaughtExceptionHandler uncaughtExceptionHandler = Thread.currentThread().getUncaughtExceptionHandler(); assertThat(uncaughtExceptionHandler instanceof ThreadGroup).isFalse(); Throwable e = mock(Throwable.class); uncaughtExceptionHandler.uncaughtException(null, e); verify(e).printStackTrace(any(PrintWriter.class)); verify(view).appendToConsole(anyString()); verify(view).setFocusOnConsoleView(); }
void initUncaughtExceptionsHandler() { Thread.currentThread().setUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { Writer result = new StringWriter(); PrintWriter printWriter = new PrintWriter(result); e.printStackTrace(printWriter); view.appendToConsole(result.toString()); view.setFocusOnConsoleView(); } }); }
ToolkitPresenter { void initUncaughtExceptionsHandler() { Thread.currentThread().setUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { Writer result = new StringWriter(); PrintWriter printWriter = new PrintWriter(result); e.printStackTrace(printWriter); view.appendToConsole(result.toString()); view.setFocusOnConsoleView(); } }); } }
ToolkitPresenter { void initUncaughtExceptionsHandler() { Thread.currentThread().setUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { Writer result = new StringWriter(); PrintWriter printWriter = new PrintWriter(result); e.printStackTrace(printWriter); view.appendToConsole(result.toString()); view.setFocusOnConsoleView(); } }); } ToolkitPresenter(ConfigurationModel configurationModel, SourceCodeModel model); }
ToolkitPresenter { void initUncaughtExceptionsHandler() { Thread.currentThread().setUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { Writer result = new StringWriter(); PrintWriter printWriter = new PrintWriter(result); e.printStackTrace(printWriter); view.appendToConsole(result.toString()); view.setFocusOnConsoleView(); } }); } 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); }
ToolkitPresenter { void initUncaughtExceptionsHandler() { Thread.currentThread().setUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { Writer result = new StringWriter(); PrintWriter printWriter = new PrintWriter(result); e.printStackTrace(printWriter); view.appendToConsole(result.toString()); view.setFocusOnConsoleView(); } }); } 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);  }