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(StreamsConfig.EXACTLY_ONCE_V2, 
"100"), true, stateManager);
         task.suspend();
         task.closeDirty();
         task = null;
 
-        ctrl.verify();
+        inOrder.verify(stateManager).taskType();
+        inOrder.verify(stateManager).registerGlobalStateStores(emptyList());
+        inOrder.verify(stateManager).taskId();
+        inOrder.verify(stateDirectory).lock(taskId);
+        inOrder.verify(stateManager).close();
+        inOrder.verify(stateManager).baseDir();
+        inOrder.verify(stateDirectory).unlock(taskId);

Review Comment:
   Absolutely correct!



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

Reply via email to