### Question:
ExceptionUtil { public static Throwable unwrapThrowable(Throwable wrapped) { Throwable unwrapped = wrapped; while (true) { if (unwrapped instanceof InvocationTargetException) { unwrapped = ((InvocationTargetException) unwrapped).getTargetException(); } else if (unwrapped instanceof UndeclaredThrowableException) { unwrapped = ((UndeclaredThrowableException) unwrapped).getUndeclaredThrowable(); } else { return unwrapped; } } } private  ExceptionUtil(); static Throwable unwrapThrowable(Throwable wrapped);  }### Answer:
@Test void shouldUnwrapThrowable() { Exception exception = new Exception(); assertEquals(exception, ExceptionUtil.unwrapThrowable(exception)); assertEquals(exception, ExceptionUtil.unwrapThrowable(new InvocationTargetException(exception, "test"))); assertEquals(exception, ExceptionUtil.unwrapThrowable(new UndeclaredThrowableException(exception, "test"))); assertEquals(exception, ExceptionUtil.unwrapThrowable(new InvocationTargetException(new InvocationTargetException(exception, "test"), "test"))); assertEquals(exception, ExceptionUtil.unwrapThrowable(new InvocationTargetException(new UndeclaredThrowableException(exception, "test"), "test"))); }
@Test public void shouldUnwrapThrowable() { Exception exception = new Exception(); assertEquals(exception, ExceptionUtil.unwrapThrowable(exception)); assertEquals(exception, ExceptionUtil.unwrapThrowable(new InvocationTargetException(exception, "test"))); assertEquals(exception, ExceptionUtil.unwrapThrowable(new UndeclaredThrowableException(exception, "test"))); assertEquals(exception, ExceptionUtil.unwrapThrowable(new InvocationTargetException(new InvocationTargetException(exception, "test"), "test"))); assertEquals(exception, ExceptionUtil.unwrapThrowable(new InvocationTargetException(new UndeclaredThrowableException(exception, "test"), "test"))); }