Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-05-09 Thread via GitHub


chia7712 merged PR #14716:
URL: https://github.com/apache/kafka/pull/14716


-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-05-09 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -411,25 +394,32 @@ public void seek(final TopicPartition partition, final 
long offset) {
 
 shouldNotSeek.set(new AssertionError("Should not seek"));
 
+@SuppressWarnings("unchecked")
 final java.util.function.Consumer> resetter =
-EasyMock.mock(java.util.function.Consumer.class);
-resetter.accept(Collections.singleton(partition1));
-EasyMock.expectLastCall();
-EasyMock.replay(resetter);
+mock(java.util.function.Consumer.class);

Review Comment:
   Heya @chia7712 and thank you for the review and the good suggestions! 
Apologies for not responding sooner, I somehow missed it. The newest commits 
ought to address both of your suggestions 😊 



-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-30 Thread via GitHub


chia7712 commented on code in PR #14716:
URL: https://github.com/apache/kafka/pull/14716#discussion_r1584442796


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -411,25 +394,32 @@ public void seek(final TopicPartition partition, final 
long offset) {
 
 shouldNotSeek.set(new AssertionError("Should not seek"));
 
+@SuppressWarnings("unchecked")
 final java.util.function.Consumer> resetter =
-EasyMock.mock(java.util.function.Consumer.class);
-resetter.accept(Collections.singleton(partition1));
-EasyMock.expectLastCall();
-EasyMock.replay(resetter);
+mock(java.util.function.Consumer.class);

Review Comment:
   we can just pass lambda function to `task.completeRestoration`. For example:
   ```java
   // We need to keep a separate reference to the arguments of 
Consumer#accept
   // because the underlying data-structure is emptied and on 
verification time
   // it is reported as empty.
   final Set partitionsAtCall = new HashSet<>();
   
   task.initializeIfNeeded();
   task.completeRestoration(partitionsAtCall::addAll);
   ```



-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-24 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -293,17 +288,12 @@ public void cleanup() throws IOException {
 task = null;
 }
 Utils.delete(BASE_DIR);
-mockito.finishMocking();
 }
 
 @Test
-public void shouldThrowLockExceptionIfFailedToLockStateDirectory() throws 
IOException {
-stateDirectory = EasyMock.createNiceMock(StateDirectory.class);
-EasyMock.expect(stateDirectory.lock(taskId)).andReturn(false);
-
EasyMock.expect(stateManager.changelogPartitions()).andReturn(Collections.emptySet());
-stateManager.registerStore(stateStore, 
stateStore.stateRestoreCallback, null);
-EasyMock.expectLastCall();
-EasyMock.replay(stateDirectory, stateManager);
+public void shouldThrowLockExceptionIfFailedToLockStateDirectory() {
+stateDirectory = mock(StateDirectory.class);

Review Comment:
   Heya @cadonna! I had another pass. The problem here is that the tests which 
appear to be properly using the state directory don't actually lock it. This 
means that when I try to close it I get the error above. As such, I decided to 
explicitly lock the state directory during setup (added the call + explanation 
to the setup method). Let me know if you disagree with this 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: jira-unsubscr...@kafka.apache.org

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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-15 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -293,17 +288,12 @@ public void cleanup() throws IOException {
 task = null;
 }
 Utils.delete(BASE_DIR);
-mockito.finishMocking();
 }
 
 @Test
-public void shouldThrowLockExceptionIfFailedToLockStateDirectory() throws 
IOException {
-stateDirectory = EasyMock.createNiceMock(StateDirectory.class);
-EasyMock.expect(stateDirectory.lock(taskId)).andReturn(false);
-
EasyMock.expect(stateManager.changelogPartitions()).andReturn(Collections.emptySet());
-stateManager.registerStore(stateStore, 
stateStore.stateRestoreCallback, null);
-EasyMock.expectLastCall();
-EasyMock.replay(stateDirectory, stateManager);
+public void shouldThrowLockExceptionIfFailedToLockStateDirectory() {
+stateDirectory = mock(StateDirectory.class);

Review Comment:
   Okay, let me try this out



-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-09 Thread via GitHub


cadonna commented on code in PR #14716:
URL: https://github.com/apache/kafka/pull/14716#discussion_r1557865864


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -293,17 +288,12 @@ public void cleanup() throws IOException {
 task = null;
 }
 Utils.delete(BASE_DIR);
-mockito.finishMocking();
 }
 
 @Test
-public void shouldThrowLockExceptionIfFailedToLockStateDirectory() throws 
IOException {
-stateDirectory = EasyMock.createNiceMock(StateDirectory.class);
-EasyMock.expect(stateDirectory.lock(taskId)).andReturn(false);
-
EasyMock.expect(stateManager.changelogPartitions()).andReturn(Collections.emptySet());
-stateManager.registerStore(stateStore, 
stateStore.stateRestoreCallback, null);
-EasyMock.expectLastCall();
-EasyMock.replay(stateDirectory, stateManager);
+public void shouldThrowLockExceptionIfFailedToLockStateDirectory() {
+stateDirectory = mock(StateDirectory.class);

Review Comment:
   In general, an implementation of `AutoClosable` should always be closed. If 
closing does not work, let's remove the creation of the state directory from 
`setup()` and close the state directory in the test methods that do not use a 
mock (maybe `try-with-resources` block?). 



-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-09 Thread via GitHub


cadonna commented on code in PR #14716:
URL: https://github.com/apache/kafka/pull/14716#discussion_r1557865864


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -293,17 +288,12 @@ public void cleanup() throws IOException {
 task = null;
 }
 Utils.delete(BASE_DIR);
-mockito.finishMocking();
 }
 
 @Test
-public void shouldThrowLockExceptionIfFailedToLockStateDirectory() throws 
IOException {
-stateDirectory = EasyMock.createNiceMock(StateDirectory.class);
-EasyMock.expect(stateDirectory.lock(taskId)).andReturn(false);
-
EasyMock.expect(stateManager.changelogPartitions()).andReturn(Collections.emptySet());
-stateManager.registerStore(stateStore, 
stateStore.stateRestoreCallback, null);
-EasyMock.expectLastCall();
-EasyMock.replay(stateDirectory, stateManager);
+public void shouldThrowLockExceptionIfFailedToLockStateDirectory() {
+stateDirectory = mock(StateDirectory.class);

Review Comment:
   In general, an implementation of `AutoClosable` should always be closed. If 
closing does not work, let's remove the creation of the state directory from 
`setup()`. 



-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-09 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -293,17 +288,12 @@ public void cleanup() throws IOException {
 task = null;
 }
 Utils.delete(BASE_DIR);
-mockito.finishMocking();
 }
 
 @Test
-public void shouldThrowLockExceptionIfFailedToLockStateDirectory() throws 
IOException {
-stateDirectory = EasyMock.createNiceMock(StateDirectory.class);
-EasyMock.expect(stateDirectory.lock(taskId)).andReturn(false);
-
EasyMock.expect(stateManager.changelogPartitions()).andReturn(Collections.emptySet());
-stateManager.registerStore(stateStore, 
stateStore.stateRestoreCallback, null);
-EasyMock.expectLastCall();
-EasyMock.replay(stateDirectory, stateManager);
+public void shouldThrowLockExceptionIfFailedToLockStateDirectory() {
+stateDirectory = mock(StateDirectory.class);

Review Comment:
   So, I tried with explicitly closing the "old" stateDirectory, but that was 
complaining because the lockStateDirectory method was never called on it:
   ```
   @Override
   public void close() {
   if (hasPersistentStores) {
   try {
   stateDirLock.release(); <--- THIS IS NULL;
   stateDirLockChannel.close();
   
   stateDirLock = null;
   stateDirLockChannel = null;
   } catch (final IOException e) {
  ...
   }
   }
   }
   ```
   I am not too familiar with the StateDirectory class itself, what underlying 
resources could be leaking and I ought to pay attention to closing?



-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-09 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -411,25 +384,22 @@ public void seek(final TopicPartition partition, final 
long offset) {
 
 shouldNotSeek.set(new AssertionError("Should not seek"));
 
+@SuppressWarnings("unchecked")
 final java.util.function.Consumer> resetter =
-EasyMock.mock(java.util.function.Consumer.class);
-resetter.accept(Collections.singleton(partition1));
-EasyMock.expectLastCall();
-EasyMock.replay(resetter);
+mock(java.util.function.Consumer.class);
+doNothing().when(resetter).accept(Collections.singleton(partition1));

Review Comment:
   Yeah, that is the main reason why I kept it as a doNothing rather than 
verification. This being said, I like your solution because it is explicit and 
in my opinion it is a stronger assertion than relying on StrictStubs, so I will 
use that one



-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-09 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -1958,64 +1859,58 @@ public void 
shouldNotCheckpointForSuspendedRunningTaskWithSmallProgress() {
 
 task.suspend();
 task.postCommit(false);
-EasyMock.verify(stateManager);
+
+verify(stateManager).checkpoint(); // checkpoint should only be called 
once

Review Comment:
   I moved the same comment from the setup to the verification, but you are 
correct, it is not needed, I shall remove 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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-08 Thread via GitHub


cadonna commented on code in PR #14716:
URL: https://github.com/apache/kafka/pull/14716#discussion_r1555453187


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -293,17 +288,12 @@ public void cleanup() throws IOException {
 task = null;
 }
 Utils.delete(BASE_DIR);
-mockito.finishMocking();
 }
 
 @Test
-public void shouldThrowLockExceptionIfFailedToLockStateDirectory() throws 
IOException {
-stateDirectory = EasyMock.createNiceMock(StateDirectory.class);
-EasyMock.expect(stateDirectory.lock(taskId)).andReturn(false);
-
EasyMock.expect(stateManager.changelogPartitions()).andReturn(Collections.emptySet());
-stateManager.registerStore(stateStore, 
stateStore.stateRestoreCallback, null);
-EasyMock.expectLastCall();
-EasyMock.replay(stateDirectory, stateManager);
+public void shouldThrowLockExceptionIfFailedToLockStateDirectory() {
+stateDirectory = mock(StateDirectory.class);

Review Comment:
   I am wondering whether we leak resources, if we assign a mock to 
`stateDirectory` without closing the state directory before.
   In `setup()` an actual state directory is created with 
   ```
   stateDirectory = new StateDirectory(createConfig("100"), new MockTime(), 
true, false);  
   ```
   It has been there before this PR, but we should fix it.
   
   You can either close the state directory before the mock is assigned or 
remove the creation of the state directory from `setup()` and create it in each 
test method that uses it. 
   
   Same is true for the other occurrences in this test class.



##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -1912,42 +1823,32 @@ public void shouldThrowIfPostCommittingOnIllegalState() 
{
 
 @Test
 public void shouldSkipCheckpointingSuspendedCreatedTask() {
-stateManager.checkpoint();
-EasyMock.expectLastCall().andThrow(new AssertionError("Should not have 
tried to checkpoint"));
-
EasyMock.expect(recordCollector.offsets()).andReturn(emptyMap()).anyTimes();
-EasyMock.replay(stateManager, recordCollector);
-
 task = createStatefulTask(createConfig("100"), true);
 task.suspend();
 task.postCommit(true);
+
+verify(stateManager, never()).checkpoint();
 }
 
 @Test
 public void shouldCheckpointForSuspendedTask() {
-stateManager.checkpoint();
-EasyMock.expectLastCall().once();
-EasyMock.expect(stateManager.changelogOffsets())
-.andReturn(singletonMap(partition1, 1L));
-
EasyMock.expect(recordCollector.offsets()).andReturn(emptyMap()).anyTimes();
-EasyMock.replay(stateManager, recordCollector);
+when(stateManager.changelogOffsets())
+.thenReturn(singletonMap(partition1, 1L));

Review Comment:
   nit:
   ```suggestion
   
when(stateManager.changelogOffsets()).thenReturn(singletonMap(partition1, 1L));
   ```



##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -411,25 +384,22 @@ public void seek(final TopicPartition partition, final 
long offset) {
 
 shouldNotSeek.set(new AssertionError("Should not seek"));
 
+@SuppressWarnings("unchecked")
 final java.util.function.Consumer> resetter =
-EasyMock.mock(java.util.function.Consumer.class);
-resetter.accept(Collections.singleton(partition1));
-EasyMock.expectLastCall();
-EasyMock.replay(resetter);
+mock(java.util.function.Consumer.class);
+doNothing().when(resetter).accept(Collections.singleton(partition1));

Review Comment:
   This should be a verification. However, there is an issue here. If I add it 
to the verifications with 
   ```java
   verify(resetter).accept(Collections.singleton(partition1));
   ```
   the test fails.
   The reason is that when ` accept()` is called, the argument is indeed 
`Collections.singleton(partition1)` but after the call the collection is 
cleared:
   
   
https://github.com/apache/kafka/blob/d144b7ee387308a59e52cbdabc7b66dd3b2926cc/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamTask.java#L955
   
   At the time the call is verified the argument changed. Apparently, Mockito 
stores the reference to the argument in the invocation.
   
   One way to solve this is the following:
   
   ```java
   final java.util.function.Consumer> resetter =
   mock(java.util.function.Consumer.class);
   final Set partitionsAtCall = new HashSet<>();
   doAnswer(
   invocation -> {
   partitionsAtCall.addAll(invocation.getArgument(0));
   return null;
   }
   ).when(resetter).accept(Collections.singleton(partition1));
   
   task.initializeIfNeeded();
   task.completeRestoration(resetter);
   
   // because we mocked the `rese

Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-05 Thread via GitHub


clolov commented on PR #14716:
URL: https://github.com/apache/kafka/pull/14716#issuecomment-2039443091

   Heya @cadonna! I have rebased and hopefully addressed all of the first batch 
of comments. The verifications which are missing are reported as 
unnecessary/uncalled by Mockito, but if you think they are necessary I will 
circle back to check


-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-05 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -1652,81 +1598,64 @@ public void shouldReInitializeTopologyWhenResuming() 
throws IOException {
 assertTrue(source1.initialized);
 assertTrue(source2.initialized);
 
-EasyMock.verify(stateManager, recordCollector);
-
-EasyMock.reset(recordCollector);
-EasyMock.expect(recordCollector.offsets()).andReturn(emptyMap());
-EasyMock.replay(recordCollector);
 assertThat("Map did not contain the partition", 
task.highWaterMark().containsKey(partition1));
+
+verify(recordCollector).offsets();
 }
 
 @Test
 public void 
shouldNotCheckpointOffsetsAgainOnCommitIfSnapshotNotChangedMuch() {
 final Long offset = 543L;
 
-
EasyMock.expect(recordCollector.offsets()).andReturn(singletonMap(changelogPartition,
 offset)).anyTimes();
-stateManager.checkpoint();
-EasyMock.expectLastCall().once();
-EasyMock.expect(stateManager.changelogOffsets())
-.andReturn(singletonMap(changelogPartition, 10L)) // restoration 
checkpoint
-.andReturn(singletonMap(changelogPartition, 10L))
-.andReturn(singletonMap(changelogPartition, 20L));
-EasyMock.expectLastCall();
-EasyMock.replay(stateManager, recordCollector);
+
when(recordCollector.offsets()).thenReturn(singletonMap(changelogPartition, 
offset));
+when(stateManager.changelogOffsets())
+.thenReturn(singletonMap(changelogPartition, 10L)) // restoration 
checkpoint
+.thenReturn(singletonMap(changelogPartition, 10L))
+.thenReturn(singletonMap(changelogPartition, 20L));
 
 task = createStatefulTask(createConfig("100"), true);
 
 task.initializeIfNeeded();
-task.completeRestoration(noOpResetter -> { });
+task.completeRestoration(noOpResetter -> { }); // should checkpoint
 
 task.prepareCommit();
-task.postCommit(true);   // should checkpoint
+task.postCommit(true); // should checkpoint
 
 task.prepareCommit();
-task.postCommit(false);   // should not checkpoint
+task.postCommit(false); // should not checkpoint
 
-EasyMock.verify(stateManager, recordCollector);
 assertThat("Map was empty", task.highWaterMark().size() == 2);
+
+verify(stateManager, times(2)).checkpoint();
 }
 
 @Test
 public void shouldCheckpointOffsetsOnCommitIfSnapshotMuchChanged() {
 final Long offset = 543L;
 
-
EasyMock.expect(recordCollector.offsets()).andReturn(singletonMap(changelogPartition,
 offset)).anyTimes();
-stateManager.checkpoint();
-EasyMock.expectLastCall().times(2);
-
EasyMock.expect(stateManager.changelogPartitions()).andReturn(singleton(changelogPartition));
-EasyMock.expect(stateManager.changelogOffsets())
-.andReturn(singletonMap(changelogPartition, 0L))
-.andReturn(singletonMap(changelogPartition, 10L))
-.andReturn(singletonMap(changelogPartition, 12000L));
-stateManager.registerStore(stateStore, 
stateStore.stateRestoreCallback, null);
-EasyMock.expectLastCall();
-EasyMock.replay(stateManager, recordCollector);
+
when(recordCollector.offsets()).thenReturn(singletonMap(changelogPartition, 
offset));
+when(stateManager.changelogOffsets())
+.thenReturn(singletonMap(changelogPartition, 0L))
+.thenReturn(singletonMap(changelogPartition, 10L))
+.thenReturn(singletonMap(changelogPartition, 12000L));
 
 task = createStatefulTask(createConfig("100"), true);
 
 task.initializeIfNeeded();
-task.completeRestoration(noOpResetter -> { });
+task.completeRestoration(noOpResetter -> { }); // should checkpoint
 task.prepareCommit();
-task.postCommit(true);
+task.postCommit(true); // should checkpoint
 
 task.prepareCommit();
-task.postCommit(false);
+task.postCommit(false); // should checkpoint since the offset delta is 
greater than the threshold
 
-EasyMock.verify(recordCollector);
 assertThat("Map was empty", task.highWaterMark().size() == 2);
+
+verify(stateManager, times(3)).checkpoint();
 }
 
 @Test
 public void shouldNotCheckpointOffsetsOnCommitIfEosIsEnabled() {
-
EasyMock.expect(stateManager.changelogPartitions()).andReturn(singleton(changelogPartition));
-stateManager.registerStore(stateStore, 
stateStore.stateRestoreCallback, null);

Review Comment:
   According to Mockito neither of these were called



-- 
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 uns

Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-05 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -312,55 +302,40 @@ public void 
shouldThrowLockExceptionIfFailedToLockStateDirectory() throws IOExce
 
 @Test
 public void shouldNotAttemptToLockIfNoStores() {
-stateDirectory = EasyMock.createNiceMock(StateDirectory.class);
-EasyMock.replay(stateDirectory);
+stateDirectory = mock(StateDirectory.class);
 
 task = createStatelessTask(createConfig("100"));
 
 task.initializeIfNeeded();
 
 // should fail if lock is called
-EasyMock.verify(stateDirectory);
+verify(stateDirectory, never()).lock(any());
 }
 
 @Test
-public void 
shouldAttemptToDeleteStateDirectoryWhenCloseDirtyAndEosEnabled() throws 
IOException {
-final IMocksControl ctrl = EasyMock.createNiceControl();
-final ProcessorStateManager stateManager = 
ctrl.createMock(ProcessorStateManager.class);
-
EasyMock.expect(stateManager.taskType()).andStubReturn(TaskType.ACTIVE);
-stateDirectory = ctrl.createMock(StateDirectory.class);
+public void 
shouldAttemptToDeleteStateDirectoryWhenCloseDirtyAndEosEnabled() {
+when(stateManager.taskType()).thenReturn(TaskType.ACTIVE);
+stateDirectory = mock(StateDirectory.class);
 
-stateManager.registerGlobalStateStores(emptyList());
-EasyMock.expectLastCall();
-
-EasyMock.expect(stateManager.taskId()).andReturn(taskId);
-
-EasyMock.expect(stateDirectory.lock(taskId)).andReturn(true);
-
-stateManager.close();
-EasyMock.expectLastCall();
-
-stateManager.transitionTaskState(SUSPENDED);

Review Comment:
   When I moved these to verifications Mockito claimed they were never called



-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-05 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -1866,9 +1810,6 @@ public void 
shouldReturnOffsetsForRepartitionTopicsForPurging() {
 
 @Test
 public void shouldThrowStreamsExceptionWhenFetchCommittedFailed() {
-
EasyMock.expect(stateManager.changelogPartitions()).andReturn(singleton(partition1));

Review Comment:
   Reported as unnecessary by Mockito



-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-05 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -1798,8 +1746,6 @@ public void 
shouldCloseStateManagerEvenDuringFailureOnUncleanTaskClose() {
 
 assertThrows(RuntimeException.class, () -> task.suspend());
 task.closeDirty();
-
-EasyMock.verify(stateManager);

Review Comment:
   I have moved
   ```
   doNothing().when(stateManager).close();
   ```
   to
   ```
   verify(stateManager).close();
   ```
   in subsequent commits.
   Everything else is related to empty maps or sets, so I have removed the 
stubbings



-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-05 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -514,8 +496,6 @@ public void 
shouldTransitToRestoringThenRunningAfterCreation() throws IOExceptio
 assertEquals(RUNNING, task.state());
 assertTrue(source1.initialized);
 assertTrue(source2.initialized);
-
-EasyMock.verify(stateDirectory);

Review Comment:
   Yeah, this is where I should have been more explicit:
   ```
   
EasyMock.expect(stateManager.changelogPartitions()).andReturn(singleton(changelogPartition));
   ```
   is reported as an unnecessary stub and
   ```
   stateManager.registerStore(stateStore, stateStore.stateRestoreCallback, 
null);
   ```
   if verified is reported as not called



-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-05 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -365,11 +356,10 @@ public void 
shouldResetOffsetsToLastCommittedForSpecifiedPartitions() {
 consumer.seek(partition1, 10L);
 consumer.seek(partition2, 15L);
 
+@SuppressWarnings("unchecked")
 final java.util.function.Consumer> resetter =
-EasyMock.mock(java.util.function.Consumer.class);
-resetter.accept(Collections.emptySet());
-EasyMock.expectLastCall();
-EasyMock.replay(resetter);
+mock(java.util.function.Consumer.class);
+doNothing().when(resetter).accept(Collections.emptySet());

Review Comment:
   This is fair, I have added a verification instead since it was expected in 
EasyMock. If you don't think the verification is necessary I can remove it 
completely



-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-05 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -1568,10 +1548,8 @@ public void 
shouldNotShareHeadersBetweenPunctuateIterations() {
 
 @Test
 public void shouldWrapKafkaExceptionWithStreamsExceptionWhenProcess() {
-
EasyMock.expect(stateManager.changelogPartitions()).andReturn(Collections.emptySet()).anyTimes();
-
EasyMock.expect(stateManager.changelogOffsets()).andReturn(emptyMap()).anyTimes();
-
EasyMock.expect(recordCollector.offsets()).andReturn(emptyMap()).anyTimes();
-EasyMock.replay(stateManager, recordCollector);
+when(stateManager.changelogOffsets()).thenReturn(emptyMap());
+when(recordCollector.offsets()).thenReturn(emptyMap());

Review Comment:
   This is also absolutely correct, these are not needed. I have removed all 
stub-related references to emptyMap



-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-05 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -309,49 +300,49 @@ public void 
shouldThrowLockExceptionIfFailedToLockStateDirectory() throws IOExce
 
 @Test
 public void shouldNotAttemptToLockIfNoStores() {
-stateDirectory = EasyMock.createNiceMock(StateDirectory.class);
-EasyMock.replay(stateDirectory);
+stateDirectory = mock(StateDirectory.class);
 
 task = createStatelessTask(createConfig("100"));
 
 task.initializeIfNeeded();
 
 // should fail if lock is called
-EasyMock.verify(stateDirectory);
+verify(stateDirectory, never()).lock(any());
 }
 
 @Test
 public void 
shouldAttemptToDeleteStateDirectoryWhenCloseDirtyAndEosEnabled() throws 
IOException {
-final IMocksControl ctrl = EasyMock.createStrictControl();
-final ProcessorStateManager stateManager = 
ctrl.createMock(ProcessorStateManager.class);
-
EasyMock.expect(stateManager.taskType()).andStubReturn(TaskType.ACTIVE);
-stateDirectory = ctrl.createMock(StateDirectory.class);
+final ProcessorStateManager stateManager = 
mock(ProcessorStateManager.class);
+when(stateManager.taskType()).thenReturn(TaskType.ACTIVE);
+stateDirectory = mock(StateDirectory.class);
 
-stateManager.registerGlobalStateStores(emptyList());
-EasyMock.expectLastCall();
+doNothing().when(stateManager).registerGlobalStateStores(emptyList());
 
-EasyMock.expect(stateManager.taskId()).andReturn(taskId);
+when(stateManager.taskId()).thenReturn(taskId);
 
-EasyMock.expect(stateDirectory.lock(taskId)).andReturn(true);
+when(stateDirectory.lock(taskId)).thenReturn(true);
 
-stateManager.close();
-EasyMock.expectLastCall();
+doNothing().when(stateManager).close();
 
 // The `baseDir` will be accessed when attempting to delete the state 
store.
-
EasyMock.expect(stateManager.baseDir()).andReturn(TestUtils.tempDirectory("state_store"));
+
when(stateManager.baseDir()).thenReturn(TestUtils.tempDirectory("state_store"));
 
-stateDirectory.unlock(taskId);
-EasyMock.expectLastCall();
+doNothing().when(stateDirectory).unlock(taskId);

Review Comment:
   No, it is already verified later on, removed



##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -309,49 +300,49 @@ public void 
shouldThrowLockExceptionIfFailedToLockStateDirectory() throws IOExce
 
 @Test
 public void shouldNotAttemptToLockIfNoStores() {
-stateDirectory = EasyMock.createNiceMock(StateDirectory.class);
-EasyMock.replay(stateDirectory);
+stateDirectory = mock(StateDirectory.class);
 
 task = createStatelessTask(createConfig("100"));
 
 task.initializeIfNeeded();
 
 // should fail if lock is called
-EasyMock.verify(stateDirectory);
+verify(stateDirectory, never()).lock(any());
 }
 
 @Test
 public void 
shouldAttemptToDeleteStateDirectoryWhenCloseDirtyAndEosEnabled() throws 
IOException {
-final IMocksControl ctrl = EasyMock.createStrictControl();
-final ProcessorStateManager stateManager = 
ctrl.createMock(ProcessorStateManager.class);
-
EasyMock.expect(stateManager.taskType()).andStubReturn(TaskType.ACTIVE);
-stateDirectory = ctrl.createMock(StateDirectory.class);
+final ProcessorStateManager stateManager = 
mock(ProcessorStateManager.class);
+when(stateManager.taskType()).thenReturn(TaskType.ACTIVE);
+stateDirectory = mock(StateDirectory.class);
 
-stateManager.registerGlobalStateStores(emptyList());
-EasyMock.expectLastCall();
+doNothing().when(stateManager).registerGlobalStateStores(emptyList());
 
-EasyMock.expect(stateManager.taskId()).andReturn(taskId);
+when(stateManager.taskId()).thenReturn(taskId);
 
-EasyMock.expect(stateDirectory.lock(taskId)).andReturn(true);
+when(stateDirectory.lock(taskId)).thenReturn(true);
 
-stateManager.close();
-EasyMock.expectLastCall();
+doNothing().when(stateManager).close();
 
 // The `baseDir` will be accessed when attempting to delete the state 
store.
-
EasyMock.expect(stateManager.baseDir()).andReturn(TestUtils.tempDirectory("state_store"));
+
when(stateManager.baseDir()).thenReturn(TestUtils.tempDirectory("state_store"));
 
-stateDirectory.unlock(taskId);
-EasyMock.expectLastCall();
+doNothing().when(stateDirectory).unlock(taskId);
 
-ctrl.checkOrder(true);
-ctrl.replay();
+final InOrder inOrder = inOrder(stateManager, stateDirectory);
 
 task = createStatefulTask(createConfig(StreamsConf

Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-05 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -309,49 +300,49 @@ public void 
shouldThrowLockExceptionIfFailedToLockStateDirectory() throws IOExce
 
 @Test
 public void shouldNotAttemptToLockIfNoStores() {
-stateDirectory = EasyMock.createNiceMock(StateDirectory.class);
-EasyMock.replay(stateDirectory);
+stateDirectory = mock(StateDirectory.class);
 
 task = createStatelessTask(createConfig("100"));
 
 task.initializeIfNeeded();
 
 // should fail if lock is called
-EasyMock.verify(stateDirectory);
+verify(stateDirectory, never()).lock(any());
 }
 
 @Test
 public void 
shouldAttemptToDeleteStateDirectoryWhenCloseDirtyAndEosEnabled() throws 
IOException {
-final IMocksControl ctrl = EasyMock.createStrictControl();
-final ProcessorStateManager stateManager = 
ctrl.createMock(ProcessorStateManager.class);
-
EasyMock.expect(stateManager.taskType()).andStubReturn(TaskType.ACTIVE);
-stateDirectory = ctrl.createMock(StateDirectory.class);
+final ProcessorStateManager stateManager = 
mock(ProcessorStateManager.class);
+when(stateManager.taskType()).thenReturn(TaskType.ACTIVE);

Review Comment:
   Nope, removed in a subsequent commit



-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-05 Thread via GitHub


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


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -309,49 +300,49 @@ public void 
shouldThrowLockExceptionIfFailedToLockStateDirectory() throws IOExce
 
 @Test
 public void shouldNotAttemptToLockIfNoStores() {
-stateDirectory = EasyMock.createNiceMock(StateDirectory.class);
-EasyMock.replay(stateDirectory);
+stateDirectory = mock(StateDirectory.class);
 
 task = createStatelessTask(createConfig("100"));
 
 task.initializeIfNeeded();
 
 // should fail if lock is called
-EasyMock.verify(stateDirectory);
+verify(stateDirectory, never()).lock(any());
 }
 
 @Test
 public void 
shouldAttemptToDeleteStateDirectoryWhenCloseDirtyAndEosEnabled() throws 
IOException {
-final IMocksControl ctrl = EasyMock.createStrictControl();
-final ProcessorStateManager stateManager = 
ctrl.createMock(ProcessorStateManager.class);
-
EasyMock.expect(stateManager.taskType()).andStubReturn(TaskType.ACTIVE);
-stateDirectory = ctrl.createMock(StateDirectory.class);
+final ProcessorStateManager stateManager = 
mock(ProcessorStateManager.class);
+when(stateManager.taskType()).thenReturn(TaskType.ACTIVE);
+stateDirectory = mock(StateDirectory.class);
 
-stateManager.registerGlobalStateStores(emptyList());
-EasyMock.expectLastCall();
+doNothing().when(stateManager).registerGlobalStateStores(emptyList());

Review Comment:
   No, it is already verified later on, removed



##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -309,49 +300,49 @@ public void 
shouldThrowLockExceptionIfFailedToLockStateDirectory() throws IOExce
 
 @Test
 public void shouldNotAttemptToLockIfNoStores() {
-stateDirectory = EasyMock.createNiceMock(StateDirectory.class);
-EasyMock.replay(stateDirectory);
+stateDirectory = mock(StateDirectory.class);
 
 task = createStatelessTask(createConfig("100"));
 
 task.initializeIfNeeded();
 
 // should fail if lock is called
-EasyMock.verify(stateDirectory);
+verify(stateDirectory, never()).lock(any());
 }
 
 @Test
 public void 
shouldAttemptToDeleteStateDirectoryWhenCloseDirtyAndEosEnabled() throws 
IOException {
-final IMocksControl ctrl = EasyMock.createStrictControl();
-final ProcessorStateManager stateManager = 
ctrl.createMock(ProcessorStateManager.class);
-
EasyMock.expect(stateManager.taskType()).andStubReturn(TaskType.ACTIVE);
-stateDirectory = ctrl.createMock(StateDirectory.class);
+final ProcessorStateManager stateManager = 
mock(ProcessorStateManager.class);
+when(stateManager.taskType()).thenReturn(TaskType.ACTIVE);
+stateDirectory = mock(StateDirectory.class);
 
-stateManager.registerGlobalStateStores(emptyList());
-EasyMock.expectLastCall();
+doNothing().when(stateManager).registerGlobalStateStores(emptyList());
 
-EasyMock.expect(stateManager.taskId()).andReturn(taskId);
+when(stateManager.taskId()).thenReturn(taskId);

Review Comment:
   Nope, I do not, it is already in the setup!



##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -309,49 +300,49 @@ public void 
shouldThrowLockExceptionIfFailedToLockStateDirectory() throws IOExce
 
 @Test
 public void shouldNotAttemptToLockIfNoStores() {
-stateDirectory = EasyMock.createNiceMock(StateDirectory.class);
-EasyMock.replay(stateDirectory);
+stateDirectory = mock(StateDirectory.class);
 
 task = createStatelessTask(createConfig("100"));
 
 task.initializeIfNeeded();
 
 // should fail if lock is called
-EasyMock.verify(stateDirectory);
+verify(stateDirectory, never()).lock(any());
 }
 
 @Test
 public void 
shouldAttemptToDeleteStateDirectoryWhenCloseDirtyAndEosEnabled() throws 
IOException {
-final IMocksControl ctrl = EasyMock.createStrictControl();
-final ProcessorStateManager stateManager = 
ctrl.createMock(ProcessorStateManager.class);
-
EasyMock.expect(stateManager.taskType()).andStubReturn(TaskType.ACTIVE);
-stateDirectory = ctrl.createMock(StateDirectory.class);
+final ProcessorStateManager stateManager = 
mock(ProcessorStateManager.class);
+when(stateManager.taskType()).thenReturn(TaskType.ACTIVE);
+stateDirectory = mock(StateDirectory.class);
 
-stateManager.registerGlobalStateStores(emptyList());
-EasyMock.expectLastCall();
+doNothing().when(stateManager).registerGlobalStateStores(emptyList());
 
-EasyMock.expect(stateManager.taskId()).andReturn(taskId);
+

Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-04-04 Thread via GitHub


cadonna commented on code in PR #14716:
URL: https://github.com/apache/kafka/pull/14716#discussion_r1552378325


##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -309,49 +300,49 @@ public void 
shouldThrowLockExceptionIfFailedToLockStateDirectory() throws IOExce
 
 @Test
 public void shouldNotAttemptToLockIfNoStores() {
-stateDirectory = EasyMock.createNiceMock(StateDirectory.class);
-EasyMock.replay(stateDirectory);
+stateDirectory = mock(StateDirectory.class);
 
 task = createStatelessTask(createConfig("100"));
 
 task.initializeIfNeeded();
 
 // should fail if lock is called
-EasyMock.verify(stateDirectory);
+verify(stateDirectory, never()).lock(any());
 }
 
 @Test
 public void 
shouldAttemptToDeleteStateDirectoryWhenCloseDirtyAndEosEnabled() throws 
IOException {
-final IMocksControl ctrl = EasyMock.createStrictControl();
-final ProcessorStateManager stateManager = 
ctrl.createMock(ProcessorStateManager.class);
-
EasyMock.expect(stateManager.taskType()).andStubReturn(TaskType.ACTIVE);
-stateDirectory = ctrl.createMock(StateDirectory.class);
+final ProcessorStateManager stateManager = 
mock(ProcessorStateManager.class);
+when(stateManager.taskType()).thenReturn(TaskType.ACTIVE);
+stateDirectory = mock(StateDirectory.class);
 
-stateManager.registerGlobalStateStores(emptyList());
-EasyMock.expectLastCall();
+doNothing().when(stateManager).registerGlobalStateStores(emptyList());

Review Comment:
   Do we really need this stub?



##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -309,49 +300,49 @@ public void 
shouldThrowLockExceptionIfFailedToLockStateDirectory() throws IOExce
 
 @Test
 public void shouldNotAttemptToLockIfNoStores() {
-stateDirectory = EasyMock.createNiceMock(StateDirectory.class);
-EasyMock.replay(stateDirectory);
+stateDirectory = mock(StateDirectory.class);
 
 task = createStatelessTask(createConfig("100"));
 
 task.initializeIfNeeded();
 
 // should fail if lock is called
-EasyMock.verify(stateDirectory);
+verify(stateDirectory, never()).lock(any());
 }
 
 @Test
 public void 
shouldAttemptToDeleteStateDirectoryWhenCloseDirtyAndEosEnabled() throws 
IOException {
-final IMocksControl ctrl = EasyMock.createStrictControl();
-final ProcessorStateManager stateManager = 
ctrl.createMock(ProcessorStateManager.class);
-
EasyMock.expect(stateManager.taskType()).andStubReturn(TaskType.ACTIVE);
-stateDirectory = ctrl.createMock(StateDirectory.class);
+final ProcessorStateManager stateManager = 
mock(ProcessorStateManager.class);
+when(stateManager.taskType()).thenReturn(TaskType.ACTIVE);
+stateDirectory = mock(StateDirectory.class);
 
-stateManager.registerGlobalStateStores(emptyList());
-EasyMock.expectLastCall();
+doNothing().when(stateManager).registerGlobalStateStores(emptyList());
 
-EasyMock.expect(stateManager.taskId()).andReturn(taskId);
+when(stateManager.taskId()).thenReturn(taskId);
 
-EasyMock.expect(stateDirectory.lock(taskId)).andReturn(true);
+when(stateDirectory.lock(taskId)).thenReturn(true);
 
-stateManager.close();
-EasyMock.expectLastCall();
+doNothing().when(stateManager).close();

Review Comment:
   Do we really need this stub?



##
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##
@@ -309,49 +300,49 @@ public void 
shouldThrowLockExceptionIfFailedToLockStateDirectory() throws IOExce
 
 @Test
 public void shouldNotAttemptToLockIfNoStores() {
-stateDirectory = EasyMock.createNiceMock(StateDirectory.class);
-EasyMock.replay(stateDirectory);
+stateDirectory = mock(StateDirectory.class);
 
 task = createStatelessTask(createConfig("100"));
 
 task.initializeIfNeeded();
 
 // should fail if lock is called
-EasyMock.verify(stateDirectory);
+verify(stateDirectory, never()).lock(any());
 }
 
 @Test
 public void 
shouldAttemptToDeleteStateDirectoryWhenCloseDirtyAndEosEnabled() throws 
IOException {
-final IMocksControl ctrl = EasyMock.createStrictControl();
-final ProcessorStateManager stateManager = 
ctrl.createMock(ProcessorStateManager.class);
-
EasyMock.expect(stateManager.taskType()).andStubReturn(TaskType.ACTIVE);
-stateDirectory = ctrl.createMock(StateDirectory.class);
+final ProcessorStateManager stateManager = 
mock(ProcessorStateManager.class);
+when(stateManager.taskType()).thenReturn(TaskType.ACTIVE);
+stateDirectory = mock(StateDirectory.class);
 
-stateManager.regi

Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-03-28 Thread via GitHub


clolov commented on PR #14716:
URL: https://github.com/apache/kafka/pull/14716#issuecomment-2025540351

   Okay, enjoy your time off!


-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-03-28 Thread via GitHub


cadonna commented on PR #14716:
URL: https://github.com/apache/kafka/pull/14716#issuecomment-2024894127

   @clolov That is great! Looking forward to reviewing it! I am on vacation at 
the moment. Maybe I can look at it next week or the week after.


-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-03-27 Thread via GitHub


clolov commented on PR #14716:
URL: https://github.com/apache/kafka/pull/14716#issuecomment-2023192543

   Hello @cadonna! This ought to be one of the last PRs for the migration. I 
will circle back tomorrow morning to rebase it since it has been out for a long 
time


-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2024-02-11 Thread via GitHub


github-actions[bot] commented on PR #14716:
URL: https://github.com/apache/kafka/pull/14716#issuecomment-1938023875

   This PR is being marked as stale since it has not had any activity in 90 
days. If you would like to keep this PR alive, please ask a committer for 
review. If the PR has  merge conflicts, please update it with the latest from 
trunk (or appropriate release branch)  If this PR is no longer valid or 
desired, please feel free to close it. If no activity occurs in the next 30 
days, it will be automatically closed.


-- 
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



Re: [PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2023-11-08 Thread via GitHub


clolov commented on PR #14716:
URL: https://github.com/apache/kafka/pull/14716#issuecomment-1801761375

   I will circle back a bit later to provide reasoning about why some seemingly 
needed things were removed.


-- 
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



[PR] KAFKA-14133: Move StreamTaskTest to Mockito [kafka]

2023-11-08 Thread via GitHub


clolov opened a new pull request, #14716:
URL: https://github.com/apache/kafka/pull/14716

   This pull requests migrates mocks from StreamTaskTest to Mockito.
   


-- 
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