### Question:
Caused { public static Predicate<Throwable> by(Class<? extends Throwable> cause) { if (cause == null) { throw new IllegalArgumentException("You must provide a cause class"); } return t -> { if (t.getCause() == null) { return cause.isAssignableFrom(t.getClass()); } return cause.isAssignableFrom(t.getCause().getClass()); }; }  static Predicate<Throwable> by(Class<? extends Throwable> cause);  }### Answer:
@Test public void testWithWrappedCheckedException() { assertEquals(SPECIFIC, Uni.createFrom() .item(Unchecked.supplier(this::stringSupplierThrowingIOException)) .onFailure(Caused.by(IOException.class)) .recoverWithItem(SPECIFIC) .onFailure() .recoverWithItem(GENERIC) .await() .indefinitely()); }
@Test public void testWithWrappedCheckedExceptionSubclass() { assertEquals(SPECIFIC, Uni.createFrom() .item(Unchecked.supplier(this::stringSupplierThrowingFileNotFoundException)) .onFailure(Caused.by(IOException.class)) .recoverWithItem(SPECIFIC) .onFailure() .recoverWithItem(GENERIC) .await() .indefinitely()); }
@Test public void testWithUncheckedException() { assertEquals(SPECIFIC, Uni.createFrom() .item(Unchecked.supplier(this::numberSupplierThrowingIllegalArgumentException)) .onFailure(Caused.by(IllegalArgumentException.class)) .recoverWithItem(SPECIFIC) .onFailure() .recoverWithItem(GENERIC) .await() .indefinitely()); }
@Test public void testWithUncheckedExceptionSubclass() { assertEquals(SPECIFIC, Uni.createFrom() .item(Unchecked.supplier(this::numberSupplierThrowingNumberFormatException)) .onFailure(Caused.by(IllegalArgumentException.class)) .recoverWithItem(SPECIFIC) .onFailure() .recoverWithItem(GENERIC) .await() .indefinitely()); }
@Test public void testWithNullParameter() { assertThrows(IllegalArgumentException.class, () -> Uni.createFrom() .item(Unchecked.supplier(this::numberSupplierThrowingNumberFormatException)) .onFailure(Caused.by(null)) .recoverWithItem(SPECIFIC) .onFailure() .recoverWithItem(GENERIC) .await() .indefinitely()); }