clolov commented on code in PR #12422:
URL: https://github.com/apache/kafka/pull/12422#discussion_r925337713


##########
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerConfigTransformerTest.java:
##########
@@ -53,64 +50,72 @@ public class WorkerConfigTransformerTest {
     public static final String TEST_RESULT_WITH_TTL = "testResultWithTTL";
     public static final String TEST_RESULT_WITH_LONGER_TTL = 
"testResultWithLongerTTL";
 
-    @Mock private Herder herder;
-    @Mock private Worker worker;
-    @Mock private HerderRequest requestId;
+    private final Herder herder = Mockito.mock(Herder.class);
+    private final Worker worker = Mockito.mock(Worker.class);
+    private final HerderRequest requestId = Mockito.mock(HerderRequest.class);

Review Comment:
   If I use @Mock I get the following error in some of the tests
   ```
   java.lang.NullPointerException: Cannot invoke 
"org.apache.kafka.connect.runtime.Worker.herder()" because "this.worker" is null
   ```
   I saw that there are multiple approaches to solve this 
https://stackoverflow.com/questions/29590621/mock-instance-is-null-after-mock-annotation.
 Are we following any of those in the code base? If so, I will just change to 
that approach.



##########
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerConfigTransformerTest.java:
##########
@@ -53,64 +50,72 @@ public class WorkerConfigTransformerTest {
     public static final String TEST_RESULT_WITH_TTL = "testResultWithTTL";
     public static final String TEST_RESULT_WITH_LONGER_TTL = 
"testResultWithLongerTTL";
 
-    @Mock private Herder herder;
-    @Mock private Worker worker;
-    @Mock private HerderRequest requestId;
+    private final Herder herder = Mockito.mock(Herder.class);
+    private final Worker worker = Mockito.mock(Worker.class);
+    private final HerderRequest requestId = Mockito.mock(HerderRequest.class);

Review Comment:
   If I use `@Mock` I get the following error in some of the tests
   ```
   java.lang.NullPointerException: Cannot invoke 
"org.apache.kafka.connect.runtime.Worker.herder()" because "this.worker" is null
   ```
   I saw that there are multiple approaches to solve this 
https://stackoverflow.com/questions/29590621/mock-instance-is-null-after-mock-annotation.
 Are we following any of those in the code base? If so, I will just change to 
that approach.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to