Resolved mismatch stubbings in MultiRequestHttpClientServiceImplTest.java#246
Resolved mismatch stubbings in MultiRequestHttpClientServiceImplTest.java#246ARMS2025 wants to merge 1 commit intouPortal-Project:masterfrom
Conversation
|
Thanks for the contribution. These auto-generated strict-stubbing cleanups target We're also currently blocking a Mockito 5 migration at the fleet level because Mockito 5's inline MockMaker has a byte-buddy classpath clash with the Javassist 1.12 pulled via Hibernate ( Closing this out for now. If you're interested in contributing the same set of fixes as part of the eventual Mockito 5 migration PR, that'd be welcome. |
I analyzed the test doubles (mocks) in the test code of the project. In my analysis of the project, I observed that
In the test
testGetSharedClient:getAttributemethod for thesessionobject:i) during test execution the method is actually called with arguments
["org.springframework.web.util.WebUtils.MUTEX", 1], but is not stubbed, resulting in a mismatch stubbing.In the test
testGetUnsharedClient:getValuemethod for thepreferencesobject:i) is stubbed in the
setUpmethod with arguments[MultiRequestHttpClientServiceImpl.HTTP_CLIENT_CONNECTION_TIMEOUT, String.valueOf(MultiRequestHttpClientServiceImpl.DEFAULT_HTTP_CLIENT_CONNECTION_TIMEOUT)]ii) during test execution the method is actually called with arguments
["sharedSessionKey", null], resulting in a mismatch stubbinggetAttributemethod for thesessionobject:i) during test execution the method is actually called with arguments
["org.springframework.web.util.WebUtils.MUTEX", 1], but is not stubbed, resulting in a mismatch stubbing.In the test
testCreateUnsharedClient:getValuemethod for thepreferencesobject:i) during test execution the method is actually called with arguments
["sharedSessionKey", null], but is not stubbed, resulting in a mismatch stubbing.In general, a mismatched stubbing occurs when a method is stubbed with specific arguments in a test but later invoked with different arguments in the code. Mockito recommends addressing this type of issue (https://www.javadoc.io/doc/org.mockito/mockito-core/latest/org.mockito/org/mockito/exceptions/misusing/PotentialStubbingProblem.html).
I propose a solution below to resolve the mismatch stubbing. Happy to modify the pull request based on your feedback.