Source:
<code>public void testSyncOffset() { Map<String, Map<TopicPartition, OffsetAndMetadata>> idleConsumerGroupsOffset = new HashMap<>(); Map<String, List<Checkpoint>> checkpointsPerConsumerGroup = new HashMap<>(); String consumer1 = "consumer1"; String consumer2 = "consumer2"; String topic1 = "topic1"; String topic2 = "topic2"; Map<TopicPartition, OffsetAndMetadata> c1t1 = new HashMap<>(); TopicPartition t1p0 = new TopicPartition(topic1, 0); Entry<TopicPartition, OffsetAndMetadata> c1t1p0 = new SimpleEntry<>(t1p0, new OffsetAndMetadata(100, "")); c1t1.put(t1p0, new OffsetAndMetadata(100, "")); Map<TopicPartition, OffsetAndMetadata> c2t2 = new HashMap<>(); TopicPartition t2p0 = new TopicPartition(topic2, 0); <START> Entry<TopicPartition, OffsetAndMetadata> c2t2p0 = new SimpleEntry<>(t2p0, new OffsetAndMetadata(50, "")); <END> c2t2.put(t2p0, new OffsetAndMetadata(50, "")); idleConsumerGroupsOffset.put(consumer1, c1t1); idleConsumerGroupsOffset.put(consumer2, c2t2); Checkpoint cpC1T1P0 = new Checkpoint(consumer1, new TopicPartition(topic1, 0), 200, 101, "metadata"); Checkpoint cpC2T2P0 = new Checkpoint(consumer2, new TopicPartition(topic2, 0), 100, 51, "metadata"); List<Checkpoint> checkpointListC1 = new ArrayList<>(); checkpointListC1.add(cpC1T1P0); List<Checkpoint> checkpointListC2 = new ArrayList<>(); checkpointListC2.add(cpC2T2P0); checkpointsPerConsumerGroup.put(consumer1, checkpointListC1); checkpointsPerConsumerGroup.put(consumer2, checkpointListC2); MirrorCheckpointTask mirrorCheckpointTask = new MirrorCheckpointTask("source1", "target2", new DefaultReplicationPolicy(), null, idleConsumerGroupsOffset, checkpointsPerConsumerGroup); Map<String, Map<TopicPartition, OffsetAndMetadata>> output = mirrorCheckpointTask.syncGroupOffset(); assertEquals(101, output.get(consumer1).get(t1p0).offset()); assertEquals(51, output.get(consumer2).get(t2p0).offset()); }</code><technical_language>new OffsetAndMetadata(50) if set metadata</technical_language>

Target:
public void testSyncOffset() { Map<String, Map<TopicPartition, OffsetAndMetadata>> idleConsumerGroupsOffset = new HashMap<>(); Map<String, List<Checkpoint>> checkpointsPerConsumerGroup = new HashMap<>(); String consumer1 = "consumer1"; String consumer2 = "consumer2"; String topic1 = "topic1"; String topic2 = "topic2"; Map<TopicPartition, OffsetAndMetadata> c1t1 = new HashMap<>(); TopicPartition t1p0 = new TopicPartition(topic1, 0); c1t1.put(t1p0, new OffsetAndMetadata(100)); Map<TopicPartition, OffsetAndMetadata> c2t2 = new HashMap<>(); TopicPartition t2p0 = new TopicPartition(topic2, 0); c2t2.put(t2p0, new OffsetAndMetadata(50)); idleConsumerGroupsOffset.put(consumer1, c1t1); idleConsumerGroupsOffset.put(consumer2, c2t2); Checkpoint cpC1T1P0 = new Checkpoint(consumer1, new TopicPartition(topic1, 0), 200, 101, "metadata"); Checkpoint cpC2T2P0 = new Checkpoint(consumer2, new TopicPartition(topic2, 0), 100, 51, "metadata"); List<Checkpoint> checkpointListC1 = new ArrayList<>(); checkpointListC1.add(cpC1T1P0); List<Checkpoint> checkpointListC2 = new ArrayList<>(); checkpointListC2.add(cpC2T2P0); checkpointsPerConsumerGroup.put(consumer1, checkpointListC1); checkpointsPerConsumerGroup.put(consumer2, checkpointListC2); MirrorCheckpointTask mirrorCheckpointTask = new MirrorCheckpointTask("source1", "target2", new DefaultReplicationPolicy(), null, idleConsumerGroupsOffset, checkpointsPerConsumerGroup); Map<String, Map<TopicPartition, OffsetAndMetadata>> output = mirrorCheckpointTask.syncGroupOffset(); assertEquals(101, output.get(consumer1).get(t1p0).offset()); assertEquals(51, output.get(consumer2).get(t2p0).offset()); }