Description
Description
I noticed that there is a test class SinkHandler implements production class BaseHandler to assist testing methd ReactorImpl:run(). This might not be the best priactice in unit testing and can be improved by leveraging mocking frameworks.
Current Implementation
- SinkHandler implements BaseHandler and creates a new variable to keep tracking of the method invocation status for onDelivery(Devent).
- In test cases, after executing test target, the new variable will be used in assertion statement to check the execution status of onDelivery(Devent).
Proposed Implementation
- Replace SinkHandler with a mocking object created by Mockito.
- Extract the attribute into transfer(int, int) to surface counting logic.
- Use method stub to control the behavior of the mocking object.
Motivation
- Decouple test class SinkHandler from production class `BaseHandler`.
- Make test logic more clear by using method stub instead of method overriding.