### Question:
Result implements ImmutableBean, Serializable { public void ifFailure(Consumer<Failure> consumer) { if (failure != null) { consumer.accept(failure); } } private  Result(T value); private  Result(Failure failure); private  Result(
      T value,
      Failure failure); static Result<R> success(R value); static Result<R> failure(FailureReason reason, String message, Object... messageArgs); static Result<T> of(Supplier<T> supplier); static Result<T> wrap(Supplier<Result<T>> supplier); static Result<R> failure(Throwable cause); static Result<R> failure(Exception cause); static Result<R> failure(Throwable cause, String message, Object... messageArgs); static Result<R> failure(Exception cause, String message, Object... messageArgs); static Result<R> failure(FailureReason reason, Throwable cause); static Result<R> failure(FailureReason reason, Exception cause); static Result<R> failure(
      FailureReason reason,
      Throwable cause,
      String message,
      Object... messageArgs); static Result<R> failure(
      FailureReason reason,
      Exception cause,
      String message,
      Object... messageArgs); @SuppressWarnings("unchecked") static Result<R> failure(Result<?> failureResult); static Result<R> failure(Result<?> result1, Result<?> result2, Result<?>... results); static Result<R> failure(Iterable<? extends Result<?>> results); static Result<R> failure(Failure failure); static Result<R> failure(FailureItem failureItem); static Result<R> ofNullable(
      R value,
      FailureReason reason,
      String message,
      Object... messageArgs); static Result<R> ofNullable(R value); static boolean allSuccessful(Result<?>... results); static boolean allSuccessful(Iterable<? extends Result<?>> results); static boolean anyFailures(Result<?>... results); static boolean anyFailures(Iterable<? extends Result<?>> results); static long countFailures(Result<?>... results); static long countFailures(Iterable<? extends Result<?>> results); static Result<R> combine(
      Iterable<? extends Result<T>> results,
      Function<Stream<T>, R> function); static Result<R> flatCombine(
      Iterable<? extends Result<T>> results,
      Function<Stream<T>, Result<R>> function); boolean isSuccess(); void ifSuccess(Consumer<? super T> consumer); boolean isFailure(); void ifFailure(Consumer<Failure> consumer); Optional<T> get(); T getValue(); T getValueOrElse(T defaultValue); T getValueOrElseApply(Function<Failure, T> mapper); Failure getFailure(); Result<R> map(Function<? super T, ? extends R> function); Result<T> mapFailure(Function<Failure, Failure> function); Result<T> mapFailureItems(Function<FailureItem, FailureItem> function); Result<R> flatMap(Function<? super T, Result<R>> function); Result<R> combineWith(Result<U> other, BiFunction<T, U, Result<R>> function); Stream<T> stream(); @SuppressWarnings("rawtypes") static Result.Meta meta(); @SuppressWarnings("unchecked") static Result.Meta<R> metaResult(Class<R> cls); @SuppressWarnings("unchecked") @Override Result.Meta<T> metaBean(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void ifFailure() { Result<String> test = Result.failure(FailureReason.INVALID, "no success"); test.ifFailure((failure) -> { assertThat(failure.getReason()).isEqualTo(FailureReason.INVALID); assertThat(failure.getMessage()).isEqualTo("no success"); }); }