### Question:
Try { public static <I, O> Function<I, Try<O>> of(ThrowingFunction<I, O> function) { return input -> { try { O result = function.apply(input); return new Success<>(result); } catch (RuntimeException e) { throw e; } catch (Exception e) { return new Failure<>(e); } }; }  static Function<I, Try<O>> of(ThrowingFunction<I, O> function); static Function<I, Supplier<Try<O>>> lazyOf(ThrowingFunction<I, O> function); static Collector<Try<E>, ?, Map<Type, List<Try<E>>>> groupingBySuccess(); static TryCollector<E> collect(); abstract Type getType(); boolean isSuccess(); boolean isFailure(); Try<F> map(Function<E, F> mapper); Try<O> flatMap(Function<E, Try<O>> mapper); Optional<E> toOption(); E getOrThrow(); void ifPresent(Consumer<E> consumer); Success<E> asSuccess(); Failure<E> asFailure();  }### Answer:
@Test public void ofSuccessTest() { Function<Integer,Try<Integer>> fn = Try.<Integer, Integer>of(i -> i + 1); assertEquals(new Success(2), fn.apply(1)); }
@Test(expected = ArithmeticException.class) public void ofRuntimeExceptionsShouldBeThrownTest() { Function<Integer, Try<Integer>> of = Try.of(i -> i / 0); Try<Integer> result = of.apply(1); }