ahuang98 commented on code in PR #16774:
URL: https://github.com/apache/kafka/pull/16774#discussion_r1708070162


##########
clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java:
##########
@@ -8232,4 +8242,92 @@ boolean callHasExpired(KafkaAdminClient.Call call) {
             }
         }
     }
+
+    @ParameterizedTest
+    @CsvSource({ "false, false", "false, true", "true, false", "true, true" })
+    public void testAddRaftVoterRequest(boolean fail, boolean sendClusterId) 
throws Exception {
+        try (AdminClientUnitTestEnv env = mockClientEnv()) {
+            AddRaftVoterResponseData responseData = new 
AddRaftVoterResponseData();
+            if (fail) {
+                responseData.
+                    setErrorCode(Errors.DUPLICATE_VOTER.code()).
+                    setErrorMessage("duplicate");
+            }
+            AtomicReference<AddRaftVoterRequestData> requestData = new 
AtomicReference<>();
+            env.kafkaClient().prepareResponse(
+                request -> {
+                    if (!(request instanceof AddRaftVoterRequest)) return 
false;
+                    requestData.set((AddRaftVoterRequestData) request.data());
+                    return true;
+                },
+                new AddRaftVoterResponse(responseData));
+            AddRaftVoterOptions options = new AddRaftVoterOptions();
+            if (sendClusterId) {
+                options.setClusterId(Optional.of("_o_GnDGwQaWu4r-NMzmkTw"));
+            }
+            AddRaftVoterResult result = env.adminClient().addRaftVoter(1,
+                    Uuid.fromString("YAfa4HClT3SIIW2klIUspg"),
+                    Collections.singleton(new RaftVoterEndpoint("CONTROLLER", 
"example.com", 8080)),
+                    options);
+            assertNotNull(result.all());
+            if (fail) {
+                TestUtils.assertFutureThrows(result.all(), 
Errors.DUPLICATE_VOTER.exception().getClass());
+            } else {
+                result.all().get();

Review Comment:
   nit: should we assertNull? would clarify to readers of this code that we 
expect the result of a successful add voter to be null



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