Closed draugrmorar closed 2 years ago
Hi @Radnaeva, this library does not use any of the Mockito's constructs, but even in Mockito, your usage of any()
would be incorrect.
If you can't match your request object fully via .equals
method, then you have to use the Predicate
form of withRequest
method. Then you can do one of the following:
.withRequest(req -> req.getEmail().equals("some@email")
&& req.getName().equals("Some Name"))
.withRequest(req -> req.toBuilder().clearPassword().build().equals(CreateUserReq.newBuilder()
.setEmail(email)
.build()))
How to mock Grpc Method with request with one unknown field?
stubFor(unaryMethod(UserGrpc.getCreateMethod()) .withRequest(UserOuterClass.CreateUserReq.newBuilder() .setEmail(email) .setPassword( any() ) <--------- this field? .build() ) .willReturn(UserOuterClass.User.newBuilder() .setId(userId) .build() ) );
I tried Mockito's any() etc. It doesn't work