'Mock a complex api call
I have some problemi understanding spring @MockBean
in complex api call:
serviceCommunication.callAPI(HttpMethod.POST,
ServiceCommunication.TokenType.TokenTypeApplication,
"document-service",
URIConstants.CREATE_DOCUMENT,
docDTO,
new ParameterizedTypeReference<ApiResultResponse<String>>() {
});
I mock before the test with:
when(serviceCommunication.callAPI(eq(HttpMethod.POST),
any(ServiceCommunication.TokenType.class),
eq("document-service"),
eq(URIConstants.CREATE_DOCUMENT),
any(),
eq(new ParameterizedTypeReference<ApiResultResponse<String>>() {}))).thenReturn(new ApiResultResponse<>(documentID));
but I got a null result, where I wrong?
Solution 1:[1]
I resolved, I have mocked the task executor, the problem was when mock bean is called in another thread
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Macdeveloper |