### Question:
ExceptionUtils { public static Throwable rootCause(final Throwable throwable) { return throwable != null ? Throwables.getRootCause(throwable) : null; } private  ExceptionUtils(); static Throwable rootCause(final Throwable throwable);  }### Answer:
@Test public void rootCauseReturnsTopLevelCause() { final Exception rootCause = new IllegalStateException("test"); assertThat(ExceptionUtils.rootCause(rootCause)).isEqualTo(rootCause); }
@Test public void rootCauseReturnsNestedCause() { final Exception rootCause = new IllegalStateException("test"); final Throwable exception = new CompletionException(new CompletionException(rootCause)); assertThat(ExceptionUtils.rootCause(exception)).isEqualTo(rootCause); }
@Test public void rootCauseHandleNullInput() { final Exception rootCause = null; assertThat(ExceptionUtils.rootCause(rootCause)).isNull(); }