sreejasahithi commented on code in PR #9812:
URL: https://github.com/apache/ozone/pull/9812#discussion_r2851838716


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/balancer/TestContainerBalancerTask.java:
##########
@@ -419,21 +419,23 @@ public void testStartBalancerWithInvalidNodes() {
     ContainerBalancerConfiguration cbConf = 
conf.getObject(ContainerBalancerConfiguration.class);
 
     // Testing invalid hostname and ip for includeNodes
-    cbConf.setIncludeNodes("invalid-host-name");
-    assertThrows(InvalidContainerBalancerConfigurationException.class, () -> 
balancer.startBalancer(cbConf),
-        "Should throw exception for non-existent hostname in includeNodes");
-    cbConf.setIncludeNodes("883.883.883.883");
-    assertThrows(InvalidContainerBalancerConfigurationException.class, () -> 
balancer.startBalancer(cbConf),
-        "Should throw exception for non-existent IP in includeNodes");
+    String invalidHost = "invalid-host-name";
+    cbConf.setIncludeNodes(invalidHost);
+    assertThatThrownBy(() -> balancer.startBalancer(cbConf)).
+        
isInstanceOf(InvalidContainerBalancerConfigurationException.class).hasMessageContaining(invalidHost);

Review Comment:
   This is not wrong but if we want to be consistent with the codebase then it 
is better to follow
   assertThrows + assertThat
   for example:
   ```
   exception = 
assertThrows(InvalidContainerBalancerConfigurationException.class,
               () -> balancer.startBalancer(cbConf),
               "Should throw exception for non-existent hostname in 
includeNodes");
   assertThat(exception.getMessage()).contains(invalidHost);
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to