RollbarUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler { @Override public void uncaughtException(Thread thread, Throwable throwable) { rollbar.log(throwable, null, null, null, true); if (delegate != null) { delegate.uncaughtException(thread, throwable); } } RollbarUncaughtExceptionHandler(Rollbar rollbar, UncaughtExceptionHandler delegate); @Override void uncaughtException(Thread thread, Throwable throwable);  }
@Test public void shouldLogThrowableToRollbar() { RollbarUncaughtExceptionHandler sut = new RollbarUncaughtExceptionHandler(rollbar, null); sut.uncaughtException(thread, throwable); verify(rollbar).log(throwable, null, null, null, true); verify(uncaughtExceptionHandler, never()).uncaughtException(thread, throwable); }
@Test public void shouldLogThrowableToRollbarAndDelegate() { RollbarUncaughtExceptionHandler sut = new RollbarUncaughtExceptionHandler(rollbar, uncaughtExceptionHandler); sut.uncaughtException(thread, throwable); verify(rollbar).log(throwable, null, null, null, true); verify(uncaughtExceptionHandler).uncaughtException(thread, throwable); }