Java Mockito mocking retrytemplate.execute并返回mocked响应

Java Mockito mocking retrytemplate.execute并返回mocked响应,java,spring-boot,unit-testing,mockito,Java,Spring Boot,Unit Testing,Mockito,下面是我要测试的代码: @Autowired RetryTemplate retryTemplate; MyResponse response; response = retryTemplate.execute(new RetryCallback<Mono<MyResponse>, RuntimeException>() { public Mono<MyResponse> doRetry(RetryContext context) {

下面是我要测试的代码:

@Autowired
RetryTemplate retryTemplate;

MyResponse response;

response = retryTemplate.execute(new RetryCallback<Mono<MyResponse>, RuntimeException>() {
    public Mono<MyResponse> doRetry(RetryContext context) {
        return webclient.post.body(Mono.just(requestBodyObj), RequestBodyObj.class).retrieve().bodyToMono(MyResponse.class);
    }
});

请指导此处的错误是什么,以及在调用
重试时如何返回
myResponseObj
。doWithRetry

请查看以下retryTemplate执行方法:

public final <T, E extends Throwable> T execute(RetryCallback<T, E> retryCallback) throws E {
        return this.doExecute(retryCallback, (RecoveryCallback)null, (RetryState)null);
}
public final T execute(RetryCallback RetryCallback)抛出{
返回此.doExecute(retryCallback,(RecoveryCallback)null,(RetryState)null);
}

当我们调用retryTemplate.execute(retryCallback)时,doExecute方法中的其他两个参数为null,因此基本上这就是为什么会出现无效使用matchers异常的原因。

请查看以下retryTemplate执行方法:

public final <T, E extends Throwable> T execute(RetryCallback<T, E> retryCallback) throws E {
        return this.doExecute(retryCallback, (RecoveryCallback)null, (RetryState)null);
}
public final T execute(RetryCallback RetryCallback)抛出{
返回此.doExecute(retryCallback,(RecoveryCallback)null,(RetryState)null);
}
当我们调用retryTemplate.execute(retryCallback)时,doExecute方法中的另外两个参数为null,所以基本上这就是为什么会出现无效使用matchers异常的原因