### Question:
Result implements Serializable { public <R> Result<R> ifSuccess(Function<T, ? extends Result<R>> function) { if (success()) { return function.apply(data); } return Result.fail(BaseResultCode.SYSTEM_ERROR); } Result(); protected  Result(T data); protected  Result(String code, String desc); protected  Result(String code, String desc, T data); protected  Result(IBaseResultCode iBaseResultCode); protected  Result(IBaseResultCode iBaseResultCode, Throwable exception); protected  Result(String code, String desc, Throwable exception); static Result<T> ok(); static Result<T> ok(T t); static Result<T> smsOk(T t); boolean isSmsOk(); Result<T> convertSmsOk(); static Result<T> okDesc(String desc); static Result<T> okDesc(String desc, T t); static MapResult<K, V> okMap(Map<K, V> data); static Result<T> okList(List<T> data); static Result<T> fail(String code, String desc); static Result<T> fail(String desc); static Result<T> fail(IBaseResultCode baseResultEnum); static Result<T> fail(IBaseResultCode baseResultEnum, String desc); static Result<T> unsureReturn(String code, String desc, T data); static Result<T> fail(IBaseResultCode baseResultEnum, Throwable exception); static Result<T> fail(IBaseResultCode baseResultEnum, Throwable e, String desc); boolean success(); Result<R> ifSuccess(Function<T, ? extends Result<R>> function); Result<T> ifNotSuccess(Consumer<? super T> consumer); Result<T> ifNotSuccessThrowException(); Result<T> ifNotSuccessOrNullThrowException(); Result<T> ifNotSuccessThrowException(BizException biz); @Deprecated Result<T> throwException(BizException biz); @Deprecated Result<T> throwException(); public String code; public String desc; public T data; }### Answer:
@Test(expected = BizException.class) public void ifSuccess() { Result.ok(Arrays.asList("a", "b", "c")) .ifNotSuccessThrowException() .ifSuccess(data -> { data.forEach(d -> System.out.println(d)); return Result.ok(data); }) .ifSuccess(data -> { data.forEach(d -> System.out.println(d)); return Result.fail("只是测试"); }) .ifNotSuccessThrowException(new BizException("500", "some exception")) ; }