[ https://issues.apache.org/jira/browse/KAFKA-9088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16987881#comment-16987881 ]
Bruno Cadonna commented on KAFKA-9088: -------------------------------------- [~vvcephei] I have the following justifications to consolidate the two classes. 1. {{InternalMockProcessorContext}} uses production code. Such a partial mock leaks code from a unit that is NOT under test into a test. We should avoid such leakage because it makes the maintenance of unit tests harder. 2. Both mocks grew over time and together they have a myriad of different constructors. That should be cleaned up (probably by using a builder pattern). 3. During the Streams metrics refactoring it wasted quite some of my time in adapting two different mocks that basically do the same. That should be avoided in future. IMO, we need to clean up those mocks. Since, we have to touch that code we should think beyond and try to simplify the use and the maintenance of the mock also by trying out new ways. For that, I thought it would be worthwhile to see what EasyMock can do for us. My expectation is that it gives us a better isolation of unit tests from production code that is not under test and less test code to maintain. My approach would be to implement a Builder that builds an EasyMock that already returns default values or the values set during the build. If then some additional expectations needs to be set, they can be set in the way you would set them when using EasyMock. But most of the setup should be hidden in the build process. This experiment should also kind of assess whether we should use EasyMock in such cases in future. If we see that EasyMock does not fulfil the expectations described above, let's do it differently. But let's at least try. Finally, I agree that the consolidation should result in less code lines than before. > Consolidate InternalMockProcessorContext and MockInternalProcessorContext > ------------------------------------------------------------------------- > > Key: KAFKA-9088 > URL: https://issues.apache.org/jira/browse/KAFKA-9088 > Project: Kafka > Issue Type: Improvement > Components: streams, unit tests > Reporter: Bruno Cadonna > Assignee: Pierangelo Di Pilato > Priority: Minor > Labels: newbie > > Currently, we have two mocks for the {{InternalProcessorContext}}. The goal > of this ticket is to merge both into one mock or replace it with an > {{EasyMock}} mock. -- This message was sent by Atlassian Jira (v8.3.4#803005)