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


##########
clients/src/test/java/org/apache/kafka/common/ClusterTest.java:
##########
@@ -89,4 +93,74 @@ public void testReturnUnmodifiableCollections() {
             new PartitionInfo(TOPIC_B, 2, NODES[1], NODES, NODES)));
     }
 
+    @Test
+    public void testNotEquals() {
+        String clusterId1 = "clusterId1";
+        String clusterId2 = "clusterId2";
+        Node node0 = new Node(0, "host0", 100);
+        Node node1 = new Node(1, "host1", 100);
+        Set<PartitionInfo> partitions1 = Collections.singleton(new 
PartitionInfo("topic1", 0, node0, new Node[]{node0, node1}, new Node[]{node0}));
+        Set<PartitionInfo> partitions2 = Collections.singleton(new 
PartitionInfo("topic2", 0, node0, new Node[]{node1, node0}, new Node[]{node1}));
+        Set<String> unauthorizedTopics1 = Collections.singleton("topic1");
+        Set<String> unauthorizedTopics2 = Collections.singleton("topic2");
+        Set<String> invalidTopics1 = Collections.singleton("topic1");
+        Set<String> invalidTopics2 = Collections.singleton("topic2");
+        Set<String> internalTopics1 = Collections.singleton("topic3");
+        Set<String> internalTopics2 = Collections.singleton("topic4");
+        Node controller1 = node0;
+        Node controller2 = node1;
+        Map<String, Uuid> topicIds1 = Collections.singletonMap("topic1", 
Uuid.randomUuid());
+        Map<String, Uuid> topicIds2 = Collections.singletonMap("topic2", 
Uuid.randomUuid());
+
+        Cluster cluster1 = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller1, 
topicIds1);
+        Cluster differentTopicIds = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller1, 
topicIds2);
+        Cluster differentController = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller2, 
topicIds1);
+        Cluster differentInternalTopics = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics2, controller1, 
topicIds1);
+        Cluster differentInvalidTopics = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics2, internalTopics1, controller1, 
topicIds1);
+        Cluster differentUnauthorizedTopics = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics2, invalidTopics1, internalTopics1, controller1, 
topicIds1);
+        Cluster differentPartitions = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions2,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller1, 
topicIds1);
+        Cluster differentNodes = new Cluster(clusterId1, Arrays.asList(node0, 
node1), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller1, 
topicIds1);
+        Cluster differentClusterId = new Cluster(clusterId2, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller1, 
topicIds1);
+
+        assertFalse(cluster1.equals(differentTopicIds));
+        assertFalse(cluster1.equals(differentController));
+        assertFalse(cluster1.equals(differentInternalTopics));
+        assertFalse(cluster1.equals(differentInvalidTopics));
+        assertFalse(cluster1.equals(differentUnauthorizedTopics));
+        assertFalse(cluster1.equals(differentPartitions));
+        assertFalse(cluster1.equals(differentNodes));
+        assertFalse(cluster1.equals(differentClusterId));
+    }
+
+    @Test
+    public void testEquals() {
+        String clusterId1 = "clusterId1";
+        Node node1 = new Node(1, "host0", 100);
+        Node node1duplicate = new Node(1, "host0", 100);
+        Set<PartitionInfo> partitions1 = Collections.singleton(new 
PartitionInfo("topic1", 0, node1, new Node[]{node1}, new Node[]{node1}));
+        Set<PartitionInfo> partitions1duplicate = Collections.singleton(new 
PartitionInfo("topic1", 0, node1duplicate, new Node[]{node1duplicate}, new 
Node[]{node1duplicate}));
+        Set<String> unauthorizedTopics1 = Collections.singleton("topic1");
+        Set<String> invalidTopics1 = Collections.singleton("topic1");
+        Set<String> internalTopics1 = Collections.singleton("topic3");
+        Node controller1 = node1;
+        Node controller1duplicate = node1duplicate;
+        Uuid topicId1 = Uuid.randomUuid();
+        Map<String, Uuid> topicIds1 = Collections.singletonMap("topic1", 
topicId1);
+        Map<String, Uuid> topicIds1duplicate = 
Collections.singletonMap("topic1", topicId1);
+
+        Cluster cluster1 = new Cluster(clusterId1, 
Collections.singletonList(node1), partitions1, unauthorizedTopics1,
+            invalidTopics1, internalTopics1, controller1, topicIds1);
+        Cluster cluster1duplicate = new Cluster(clusterId1, 
Collections.singletonList(node1duplicate), partitions1duplicate,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, 
controller1duplicate, topicIds1duplicate);
+        assertTrue(cluster1.equals(cluster1duplicate));

Review Comment:
   Could you please use `assertEqual`?



##########
clients/src/test/java/org/apache/kafka/common/ClusterTest.java:
##########
@@ -89,4 +93,74 @@ public void testReturnUnmodifiableCollections() {
             new PartitionInfo(TOPIC_B, 2, NODES[1], NODES, NODES)));
     }
 
+    @Test
+    public void testNotEquals() {
+        String clusterId1 = "clusterId1";
+        String clusterId2 = "clusterId2";
+        Node node0 = new Node(0, "host0", 100);
+        Node node1 = new Node(1, "host1", 100);
+        Set<PartitionInfo> partitions1 = Collections.singleton(new 
PartitionInfo("topic1", 0, node0, new Node[]{node0, node1}, new Node[]{node0}));
+        Set<PartitionInfo> partitions2 = Collections.singleton(new 
PartitionInfo("topic2", 0, node0, new Node[]{node1, node0}, new Node[]{node1}));
+        Set<String> unauthorizedTopics1 = Collections.singleton("topic1");
+        Set<String> unauthorizedTopics2 = Collections.singleton("topic2");
+        Set<String> invalidTopics1 = Collections.singleton("topic1");
+        Set<String> invalidTopics2 = Collections.singleton("topic2");
+        Set<String> internalTopics1 = Collections.singleton("topic3");
+        Set<String> internalTopics2 = Collections.singleton("topic4");
+        Node controller1 = node0;
+        Node controller2 = node1;
+        Map<String, Uuid> topicIds1 = Collections.singletonMap("topic1", 
Uuid.randomUuid());
+        Map<String, Uuid> topicIds2 = Collections.singletonMap("topic2", 
Uuid.randomUuid());
+
+        Cluster cluster1 = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller1, 
topicIds1);
+        Cluster differentTopicIds = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller1, 
topicIds2);
+        Cluster differentController = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller2, 
topicIds1);
+        Cluster differentInternalTopics = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics2, controller1, 
topicIds1);
+        Cluster differentInvalidTopics = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics2, internalTopics1, controller1, 
topicIds1);
+        Cluster differentUnauthorizedTopics = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics2, invalidTopics1, internalTopics1, controller1, 
topicIds1);
+        Cluster differentPartitions = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions2,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller1, 
topicIds1);
+        Cluster differentNodes = new Cluster(clusterId1, Arrays.asList(node0, 
node1), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller1, 
topicIds1);
+        Cluster differentClusterId = new Cluster(clusterId2, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller1, 
topicIds1);
+
+        assertFalse(cluster1.equals(differentTopicIds));
+        assertFalse(cluster1.equals(differentController));
+        assertFalse(cluster1.equals(differentInternalTopics));
+        assertFalse(cluster1.equals(differentInvalidTopics));
+        assertFalse(cluster1.equals(differentUnauthorizedTopics));
+        assertFalse(cluster1.equals(differentPartitions));
+        assertFalse(cluster1.equals(differentNodes));
+        assertFalse(cluster1.equals(differentClusterId));
+    }
+
+    @Test
+    public void testEquals() {
+        String clusterId1 = "clusterId1";
+        Node node1 = new Node(1, "host0", 100);
+        Node node1duplicate = new Node(1, "host0", 100);
+        Set<PartitionInfo> partitions1 = Collections.singleton(new 
PartitionInfo("topic1", 0, node1, new Node[]{node1}, new Node[]{node1}));
+        Set<PartitionInfo> partitions1duplicate = Collections.singleton(new 
PartitionInfo("topic1", 0, node1duplicate, new Node[]{node1duplicate}, new 
Node[]{node1duplicate}));
+        Set<String> unauthorizedTopics1 = Collections.singleton("topic1");
+        Set<String> invalidTopics1 = Collections.singleton("topic1");
+        Set<String> internalTopics1 = Collections.singleton("topic3");
+        Node controller1 = node1;

Review Comment:
   Could you please create different nodes for controller?



##########
clients/src/test/java/org/apache/kafka/common/ClusterTest.java:
##########
@@ -89,4 +93,74 @@ public void testReturnUnmodifiableCollections() {
             new PartitionInfo(TOPIC_B, 2, NODES[1], NODES, NODES)));
     }
 
+    @Test
+    public void testNotEquals() {
+        String clusterId1 = "clusterId1";
+        String clusterId2 = "clusterId2";
+        Node node0 = new Node(0, "host0", 100);
+        Node node1 = new Node(1, "host1", 100);
+        Set<PartitionInfo> partitions1 = Collections.singleton(new 
PartitionInfo("topic1", 0, node0, new Node[]{node0, node1}, new Node[]{node0}));
+        Set<PartitionInfo> partitions2 = Collections.singleton(new 
PartitionInfo("topic2", 0, node0, new Node[]{node1, node0}, new Node[]{node1}));
+        Set<String> unauthorizedTopics1 = Collections.singleton("topic1");
+        Set<String> unauthorizedTopics2 = Collections.singleton("topic2");
+        Set<String> invalidTopics1 = Collections.singleton("topic1");
+        Set<String> invalidTopics2 = Collections.singleton("topic2");
+        Set<String> internalTopics1 = Collections.singleton("topic3");
+        Set<String> internalTopics2 = Collections.singleton("topic4");
+        Node controller1 = node0;
+        Node controller2 = node1;
+        Map<String, Uuid> topicIds1 = Collections.singletonMap("topic1", 
Uuid.randomUuid());
+        Map<String, Uuid> topicIds2 = Collections.singletonMap("topic2", 
Uuid.randomUuid());
+
+        Cluster cluster1 = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller1, 
topicIds1);
+        Cluster differentTopicIds = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller1, 
topicIds2);
+        Cluster differentController = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller2, 
topicIds1);
+        Cluster differentInternalTopics = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics2, controller1, 
topicIds1);
+        Cluster differentInvalidTopics = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics2, internalTopics1, controller1, 
topicIds1);
+        Cluster differentUnauthorizedTopics = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics2, invalidTopics1, internalTopics1, controller1, 
topicIds1);
+        Cluster differentPartitions = new Cluster(clusterId1, 
Collections.singletonList(node0), partitions2,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller1, 
topicIds1);
+        Cluster differentNodes = new Cluster(clusterId1, Arrays.asList(node0, 
node1), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller1, 
topicIds1);
+        Cluster differentClusterId = new Cluster(clusterId2, 
Collections.singletonList(node0), partitions1,
+            unauthorizedTopics1, invalidTopics1, internalTopics1, controller1, 
topicIds1);
+
+        assertFalse(cluster1.equals(differentTopicIds));

Review Comment:
   ditto. please use `assertEqual`



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