StatusObserverExceptionHandler implements UncaughtExceptionHandler { @Override public void uncaughtException(Thread thread, Throwable throwable) { String msg = String.format("Error in thread \"%s\": %s", thread.getName(), throwable.getLocalizedMessage()); statusObserver.updateStatus(msg, StatusObserver.LEVEL_ERROR); } StatusObserverExceptionHandler(StatusObserver statusObserver); @Override void uncaughtException(Thread thread, Throwable throwable);  }
@Test public void testUncaughtException() throws Exception { StatusObserver statusObserver = Mockito.mock(StatusObserver.class); StatusObserverExceptionHandler statusObserverExceptionHandler = new StatusObserverExceptionHandler(statusObserver); statusObserverExceptionHandler.uncaughtException(Thread.currentThread(), new Exception()); Mockito.verify(statusObserver, Mockito.times(1)).updateStatus(Mockito.anyString(), Mockito.anyInt()); }