我正在使用Micronaut构建微服务。这个特定的服务依赖于从另一个服务自动生成的客户机,我想在我的组件测试中模拟它。
然而,我无法模仿其中一个方法的顶端。签名人看起来像这样:
Single extends HttpResponse> patchProfile(String userId, UserprofileApiEntity userProfile);
哪里
HttpResponse
是从包裹里
io.micronaut.http
和
Single
来自包裹
io.reactivex
在我的测试中,我尝试这样模拟这个端点:
when(userProfileClientMock.patchProfile(userIdCaptor.capture(), profileCaptor.capture())).thenReturn(Single.just(HttpResponse.ok()));
但是我得到了错误
error: no suitable method found for thenReturn(Single)
when(userProfileClientMock.patchProfile(userIdCaptor.capture(), profileCaptor.capture())).thenReturn(response);
^
method OngoingStubbing.thenReturn(Single) is not applicable
(argument mismatch; Single cannot be converted to Single)
method OngoingStubbing.thenReturn(Single,Single...) is not applicable
(argument mismatch; Single cannot be converted to Single)
where CAP#1,CAP#2 are fresh type-variables:
CAP#1 extends HttpResponse from capture of ? extends HttpResponse
CAP#2 extends HttpResponse from capture of ? extends HttpResponse
Note: /home/anders/Documents/minecraft/minecraft.api.public.displaynames/minecraft.api.public.displaynames.server/src/test/java/net/minecraft/api/pub/displaynames/DisplaynamesApiTest.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
据我所知,这与
extends . . .>
作为签名的一部分,我成功地模仿了类似的顶点返回类似
Single
或
Maybe
不幸的是,在这种情况下,更改客户的签名是没有意义的。
我尝试将响应single指定为变量,并将其显式键入为
Single extends HttpResponse>
和
Single
莫基托的想法可能被某种类型的删除混淆了,但没有用。
有什么想法可能是导致这种情况的原因,以及如何解决它?