我目前正在增加Project Reactor主题,并且在玩 reactor.core.publisher.Mono 和 reactor.test.StepVerifier 。
>考虑以下代码:
import org.junit.Test;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
public class ReactorTest {
@Test
public void test() {
Joe joe = new Joe();
Mono<Bob> result = joe.doStuff();
StepVerifier.create(result)
.expectError(RuntimeException.class)
.verifyThenAssertThat()
.hasOperatorErrorsMatching(errorList -> true); //true to be replaced by validations
}
}
和
public interface Bob {
}
还有
import reactor.core.publisher.Mono;
public class Joe {
public Mono<Bob> doStuff() {
return Mono.error(new RuntimeException());
}
}
我正在尝试在 .hasOperatorErrorsMatching(...)
的lambda表达式内执行一堆验证.hasOperatorErrorsMatching(...)被定义为 the following
我发现很难通过查看.hasOperatorErrorsMatching(...)doc和输入参数表达式来确定 errorList 的类类型:
Predicate<Collection<Tuple2<Optional<Throwable>, Optional<?>>>> arg0
我是唯一发现此表达式难以阅读的人吗?
使用Eclipse调试器,我设法确定errorList的类类型,您可以看到它是 ConcurrentLinkedQueue ,现在,我有了在中执行验证所需的内容> .hasOperatorErrorsMatching(...)。
问题:编写代码时如何确定 errorList 的类类型?您是否像我一样检查调试器,或者有更简便的方法来确定它?