【发布时间】:2020-01-07 07:05:36
【问题描述】:
我正在尝试模拟以下方法:
public Mono<PResponse> pay(final String oId,final Double amount) {
return webClient
.put()
.uri("/order/{oId}/amount/{amount}",oId,amount)
.body(BodyInserts
.fromObject(PRequest))
.exchange()
.flatMap(
response -> {
if(response.statusCode().is4xxClientError()) {
// call error Function
} else {
return response
.bodyToMono(PResponse.class)
.flatMap(pResponse -> {
return Mono.just(pResposne)
});
}
}
);
}
供您参考,webClient 是一个私有实例。
【问题讨论】:
-
尝试添加您迄今为止尝试过的内容,以便我们为您提供帮助
-
您好,感谢您的回复。我只想模拟这个部分。 return webClient .put() .uri("/order/{oId}/amount/{amount}",oId,amount) .body(BodyInserts .fromObject(PRequest)) .exchange()