ExceptionUtil { public static RuntimeException toRuntimeException(Exception exception) { return toRuntimeException(exception, null); }  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 toRuntimeException() { assertNull(ExceptionUtil.toRuntimeException(null)); assertEquals(RuntimeException.class, ExceptionUtil.toRuntimeException(new Exception(), PrivateRuntimeException.class).getClass()); IllegalArgumentException iae = new IllegalArgumentException(); IOException ioe = new IOException(); assertSame(iae, ExceptionUtil.toRuntimeException(iae)); assertTrue(ExceptionUtil.toRuntimeException(ioe) instanceof RuntimeException); assertSame(ioe, ExceptionUtil.toRuntimeException(ioe).getCause()); }
@Test public void toRuntimeException2() { IllegalArgumentException iae = new IllegalArgumentException(); IOException ioe = new IOException(); assertSame(iae, ExceptionUtil.toRuntimeException(iae, IllegalStateException.class)); assertTrue(ExceptionUtil.toRuntimeException(ioe, IllegalStateException.class) instanceof IllegalStateException); assertSame(ioe, ExceptionUtil.toRuntimeException(ioe, IllegalStateException.class).getCause()); }