[GitHub] [kafka] clolov commented on a diff in pull request #14204: KAFKA-14133: Move mocks from KStreamTransformValuesTest, KTableImplTest and KTableTransformValuesTest to Mockito

2023-08-16 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/kstream/internals/KTableTransformValuesTest.java:
##
@@ -163,104 +159,74 @@ public void shouldNotSendOldValuesByDefault() {
 final Processor, String, Change> 
processor = transformValues.get();
 processor.init(context);
 
-context.forward(new Record<>("Key", new Change<>("Key->newValue!", 
null), 0));
-expectLastCall();
-replay(context);
+doNothing().when(context).forward(new Record<>("Key", new 
Change<>("Key->newValue!", null), 0));
 
 processor.process(new Record<>("Key", new Change<>("newValue", 
"oldValue"), 0));
-
-verify(context);
 }
 
 @Test
 public void shouldSendOldValuesIfConfigured() {
 final KTableTransformValues transformValues =
 new KTableTransformValues<>(parent, new 
ExclamationValueTransformerSupplier(), null);
 
-expect(parent.enableSendingOldValues(true)).andReturn(true);
-replay(parent);
+when(parent.enableSendingOldValues(true)).thenReturn(true);
 
 transformValues.enableSendingOldValues(true);
 final Processor, String, Change> 
processor = transformValues.get();
 processor.init(context);
 
-context.forward(new Record<>("Key", new Change<>("Key->newValue!", 
"Key->oldValue!"), 0));
-expectLastCall();
-replay(context);
+doNothing().when(context).forward(new Record<>("Key", new 
Change<>("Key->newValue!", "Key->oldValue!"), 0));
 
 processor.process(new Record<>("Key", new Change<>("newValue", 
"oldValue"), 0));
-
-verify(context);
-}
-
-@Test
-public void shouldNotSetSendOldValuesOnParentIfMaterialized() {

Review Comment:
   You are entirely correct!
   
   Mockito was reporting that that exception was never thrown, but I completely 
missed checking the message in the exception which would have given me the 
needed information to change the verification, apologies.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [kafka] clolov commented on a diff in pull request #14204: KAFKA-14133: Move mocks from KStreamTransformValuesTest, KTableImplTest and KTableTransformValuesTest to Mockito

2023-08-15 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/kstream/internals/KTableTransformValuesTest.java:
##
@@ -163,104 +159,74 @@ public void shouldNotSendOldValuesByDefault() {
 final Processor, String, Change> 
processor = transformValues.get();
 processor.init(context);
 
-context.forward(new Record<>("Key", new Change<>("Key->newValue!", 
null), 0));
-expectLastCall();
-replay(context);
+doNothing().when(context).forward(new Record<>("Key", new 
Change<>("Key->newValue!", null), 0));
 
 processor.process(new Record<>("Key", new Change<>("newValue", 
"oldValue"), 0));
-
-verify(context);
 }
 
 @Test
 public void shouldSendOldValuesIfConfigured() {
 final KTableTransformValues transformValues =
 new KTableTransformValues<>(parent, new 
ExclamationValueTransformerSupplier(), null);
 
-expect(parent.enableSendingOldValues(true)).andReturn(true);
-replay(parent);
+when(parent.enableSendingOldValues(true)).thenReturn(true);
 
 transformValues.enableSendingOldValues(true);
 final Processor, String, Change> 
processor = transformValues.get();
 processor.init(context);
 
-context.forward(new Record<>("Key", new Change<>("Key->newValue!", 
"Key->oldValue!"), 0));
-expectLastCall();
-replay(context);
+doNothing().when(context).forward(new Record<>("Key", new 
Change<>("Key->newValue!", "Key->oldValue!"), 0));
 
 processor.process(new Record<>("Key", new Change<>("newValue", 
"oldValue"), 0));
-
-verify(context);
-}
-
-@Test
-public void shouldNotSetSendOldValuesOnParentIfMaterialized() {

Review Comment:
   That's what I am trying to explain, however - this test is incorrect and the 
act of moving it from EasyMock to Mockito surfaced this problem. This means 
that either this test needs to be removed or it needs to be changed.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [kafka] clolov commented on a diff in pull request #14204: KAFKA-14133 Move mocks from KStreamTransformValuesTest, KTableImplTest and KTableTransformValuesTest to Mockito

2023-08-14 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/kstream/internals/KTableTransformValuesTest.java:
##
@@ -163,104 +159,74 @@ public void shouldNotSendOldValuesByDefault() {
 final Processor, String, Change> 
processor = transformValues.get();
 processor.init(context);
 
-context.forward(new Record<>("Key", new Change<>("Key->newValue!", 
null), 0));
-expectLastCall();
-replay(context);
+doNothing().when(context).forward(new Record<>("Key", new 
Change<>("Key->newValue!", null), 0));
 
 processor.process(new Record<>("Key", new Change<>("newValue", 
"oldValue"), 0));
-
-verify(context);
 }
 
 @Test
 public void shouldSendOldValuesIfConfigured() {
 final KTableTransformValues transformValues =
 new KTableTransformValues<>(parent, new 
ExclamationValueTransformerSupplier(), null);
 
-expect(parent.enableSendingOldValues(true)).andReturn(true);
-replay(parent);
+when(parent.enableSendingOldValues(true)).thenReturn(true);
 
 transformValues.enableSendingOldValues(true);
 final Processor, String, Change> 
processor = transformValues.get();
 processor.init(context);
 
-context.forward(new Record<>("Key", new Change<>("Key->newValue!", 
"Key->oldValue!"), 0));
-expectLastCall();
-replay(context);
+doNothing().when(context).forward(new Record<>("Key", new 
Change<>("Key->newValue!", "Key->oldValue!"), 0));
 
 processor.process(new Record<>("Key", new Change<>("newValue", 
"oldValue"), 0));
-
-verify(context);
-}
-
-@Test
-public void shouldNotSetSendOldValuesOnParentIfMaterialized() {

Review Comment:
   This test checks nothing as far as I can tell because the QUERYABLE_NAME 
isn't equal to null, which is when we would reach the if-condition to throw the 
exception at.
   
   There is another test which tests the behaviour when that value is null, but 
it doesn't throw an exception, so given that this is a deprecated I decided to 
not try to cover this scenario.
   
   I have also not used verifyNoMoreInteractions, but if reviewers think it is 
necessary I can circle back and add it.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org