I have a spring based project and I am trying to improve the code coverage within it
I have the following block of code which uses a lambda on the defferedResult onCompletion method
util.getResponse(userInfoDeferredResult, url, userName, password);
userInfoDeferredResult.onCompletion(() -> {
//the result can be a String or ErrorResponse
//if ErrorResponse we don't want to cause ClassCastException and we don't need to cache the result
if (userInfoDeferredResult.getResult() instanceof String){
String response = (String) userInfoDeferredResult.getResult();
cacheServices.addValueToCache(Service.USER_INFO_CACHE_NAME, corpId, response);
}
});
I was wondering - is it possible to mock the contents of the onCompletion lambda using mockito or powerMockito?