wuchong commented on code in PR #1470:
URL: https://github.com/apache/fluss/pull/1470#discussion_r2265179410


##########
fluss-server/src/test/java/com/alibaba/fluss/server/coordinator/CompletedSnapshotStoreManagerTest.java:
##########
@@ -172,6 +181,50 @@ void testRemoveCompletedSnapshotStoreFromManager() throws 
Exception {
         
assertThat(completedSnapshotStoreManager.getBucketCompletedSnapshotStores()).isEmpty();
     }
 
+    @Test
+    void testMetadataInconsistencyWithMetadataNotExistsException() throws 
Exception {
+        // setup test data with mixed valid and invalid snapshots
+        TableBucket tableBucket = new TableBucket(1, 1);
+        CompletedSnapshot validSnapshot =
+                KvTestUtils.mockCompletedSnapshot(tempDir, tableBucket, 1L);
+        CompletedSnapshotHandle validSnapshotHandle = 
mock(CompletedSnapshotHandle.class);
+        
when(validSnapshotHandle.getSnapshotId()).thenReturn(validSnapshot.getSnapshotID());
+        when(validSnapshotHandle.getMetadataFilePath())
+                .thenReturn(validSnapshot.getMetadataFilePath());
+        
when(validSnapshotHandle.retrieveCompleteSnapshot()).thenReturn(validSnapshot);
+
+        CompletedSnapshot invalidSnapshot =
+                KvTestUtils.mockCompletedSnapshot(tempDir, tableBucket, 2L);
+        CompletedSnapshotHandle invalidSnapshotHandle = 
mock(CompletedSnapshotHandle.class);
+        
when(invalidSnapshotHandle.getSnapshotId()).thenReturn(invalidSnapshot.getSnapshotID());
+        when(invalidSnapshotHandle.getMetadataFilePath())
+                .thenReturn(invalidSnapshot.getMetadataFilePath());

Review Comment:
   Please avoid use Mockito, use reusable test implementations instead. (see 
[the code quality guide and reason 
here](https://flink.apache.org/how-to-contribute/code-style-and-quality-common/#avoid-mockito---use-reusable-test-implementations)).
 
   
   Here, we can easily construct the valid and invalid 
`CompletedSnapshotHandle` using its constructor, one has valid path and the 
other has invlid path. This makes the code easy to maintain for the future, and 
cover more code path. 



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