ExceptionUtil { public static Throwable getRootCause(Throwable throwable) { List<Throwable> causes = getCauses(throwable, true); return causes.isEmpty() ? null : causes.get(0); }  static boolean causedBy(Throwable throwable, Class<? extends Throwable> causeType); static Throwable getRootCause(Throwable throwable); static List<Throwable> getCauses(Throwable throwable); static List<Throwable> getCauses(Throwable throwable, boolean reversed); static RuntimeException toRuntimeException(Exception exception); static RuntimeException toRuntimeException(Exception exception,
            Class<? extends RuntimeException> runtimeExceptionClass); static void throwExceptionOrError(Throwable throwable); static void throwRuntimeExceptionOrError(Throwable throwable); static String getStackTrace(Throwable throwable);  }
@Test public void getRootCause() { assertNull(ExceptionUtil.getRootCause(null)); Throwable t = new IOException(); assertSame(t, ExceptionUtil.getRootCause(t)); assertThat(ExceptionUtil.getRootCause(getException()), instanceOf(IllegalStateException.class)); }