public static RuntimeException wrapIf(boolean condition, Throwable t) {
    if (condition) {
      return wrap(t);
    }

    if (t instanceof RuntimeException) {
      return (RuntimeException) t;
    }

    return new RuntimeException(t);
  }
@Test
  public void testWrapIfReturnsRuntimeExceptionWhenFalse() {
    IOException cause = new IOException();
    RuntimeException wrapped = UserCodeException.wrapIf(false, cause);

    assertThat(wrapped, is(not(instanceOf(UserCodeException.class))));
    assertEquals(cause, wrapped.getCause());
  }