Kotlin 1.9.23
JDK 21
Mockito 5.7.0
I have jUnit test:
val mockOperation: () -> GetAllOrganizationsResponse = Mockito.mock()
@Test
fun testGetOrganizations() {
val request =
GetAllOrganizationsRequest.newBuilder()
request.setSearchCriteria(
SearchCriteria.newBuilder()
.setValue(StringValue.of(IDENT))
)
val req = request.build()
grpcClient.getOrganizations(IDENT)
Mockito.verify(grpcWrapper).invokeGrpcCall("getOrganizations", req.toString()) { mockOperation() }
}
And this verify is failing. Because there is a difference in expected and actual value for request. And the difference is an empty row 🙁
Expected result:
GrpcWrapper#0 bean.invokeGrpcCall(
"getOrganizations",
["searchCriteria {
value {
value: "12345678"
}
}
"],
() () -> GetAllOrganizationsResponse?
);
Actual result is:
GrpcWrapper#0 bean.invokeGrpcCall(
"getOrganizations",
["searchCriteria {
value {
value: "12345678"
}
}
"],
() () -> GetAllOrganizationsResponse?
);
<-- empty row
And this is quite unhappy.
Why is an empty row there ?
How to avoid it ?
How to tell Mockito.verify to ignore empty line ?