我们有一个从浏览器调用的REST端点(JAX-RS)。我们传递OutputStream以便可以在浏览器中显示调用结果。
以下是该方法:
使用Junit和Mockito,如何验证是否调用了
以下是该方法:
@Path("/mypath/{userId}")
@POST
public Response createUser(@PathParam("userId") final int userId ) {
StreamingOutput stream = (outputStream) -> {
User user = userHelper.findUser(userId);
userHelper.updateUser(user,outputStream);
};
return Response.ok(stream).build();
}
使用Junit和Mockito,如何验证是否调用了
userHelper.findUser
和userHelper.updateUser
?基本上我们只是想要验证交互。