zheguang commented on code in PR #19874:
URL: https://github.com/apache/kafka/pull/19874#discussion_r2453805001


##########
connect/mirror/src/test/java/org/apache/kafka/connect/mirror/MirrorCheckpointTaskBidirectionalTest.java:
##########
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.connect.mirror;
+
+import org.apache.kafka.clients.consumer.OffsetAndMetadata;
+import org.apache.kafka.common.TopicPartition;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * Tests for bidirectional replication scenarios in MirrorCheckpointTask
+ */
+public class MirrorCheckpointTaskBidirectionalTest {
+
+    @Test
+    public void testBidirectionalSyncWithCheckpointStoreHavingHigherOffset() 
throws ExecutionException, InterruptedException {

Review Comment:
   We could refactor these two test cases for better maintainability, something 
like:
   ```java
   @Test
   public void testBidirectionalSyncWithCheckpointStoreHavingHigherOffset() 
throws ExecutionException, InterruptedException {
       Map<String, Map<TopicPartition, OffsetAndMetadata>> result = 
runBidirectionalSync(200, 100);
       assertNull(result.get("consumer1"));
   }
   
   @Test
   public void testBidirectionalSyncWithCheckpointStoreHavingLowerOffset() 
throws ExecutionException, InterruptedException {
       Map<String, Map<TopicPartition, OffsetAndMetadata>> result = 
runBidirectionalSync(75, 150);
       assertEquals(150, result.get("consumer1").get(new 
TopicPartition("topic1", 0)).offset());
   }
   
   private Map<String, Map<TopicPartition, OffsetAndMetadata>> 
runBidirectionalSync(long checkpointDownstreamOffset, long 
convertedUpstreamOffset) throws ExecutionException, InterruptedException { 
       // TODO: Refactored code here
    }
   ```



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