### Question:
Try { public Optional<E> toOption() { return isSuccess() ? Optional.ofNullable(asSuccess().getResult()) : Optional.<E>empty(); }  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 toOptionSuccessTest() { Try<Integer> success = new Success<>(1); Optional<Integer> option = success.toOption(); assertEquals(Integer.valueOf(1), option.get()); }
@Test public void toOptionFailureTest() { Try<Integer> success; success = new Failure<>(exception); Optional<Integer> option = success.toOption(); assertFalse(option.isPresent()); }