poorbarcode commented on code in PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#discussion_r1276632756
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/ClusterDataImpl.java:
##########
@@ -412,7 +412,16 @@ public ClusterDataImpl build() {
*
* @throws IllegalArgumentException exist illegal property.
*/
- public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ public void checkPropertiesIfPresent() throws IllegalArgumentException {
Review Comment:
Could you format the code to make the code lines have the same alignment?
<img width="880" alt="截屏2023-07-28 01 55 37"
src="https://github.com/apache/pulsar/assets/25195800/998cf694-79ab-4b49-a905-ae0f8824d300">
##########
pulsar-common/src/test/java/org/apache/pulsar/common/policies/data/ClusterDataImplTest.java:
##########
@@ -62,4 +66,34 @@ public void verifyClone() {
assertEquals(clone, originalData, "Clones should have object
equality.");
assertNotSame(clone, originalData, "Clones should not be the same
reference.");
}
+
+ @Test
+ public void testBothServiceUrlsisEmpty(){
+ ClusterDataImpl clusterData = new ClusterDataImpl();
+ clusterData.setServiceUrl("");
+ clusterData.setServiceUrlTls("");
+ clusterData.setBrokerServiceUrl("pulsar://pulsar.example.com:6650");
+
clusterData.setBrokerServiceUrlTls("pulsar+ssl://pulsar.example.com:6651");
+
+ IllegalArgumentException exception = assertThrows(
+ IllegalArgumentException.class,
clusterData::checkPropertiesIfPresent
+ );
+
+ assertEquals("At least one of ServiceUrl or ServiceUrlTls must be
set.", exception.getMessage());
+ }
+
+ @Test
+ public void testBothBrokerServiceUrlsisEmpty(){
+ ClusterDataImpl clusterData = new ClusterDataImpl();
+ clusterData.setServiceUrl("http://pulsar.example.com:8080");
+ clusterData.setServiceUrlTls("https://pulsar.example.com:8443");
+ clusterData.setBrokerServiceUrl("");
+ clusterData.setBrokerServiceUrlTls("");
+
+ IllegalArgumentException exception = assertThrows(
+ IllegalArgumentException.class,
clusterData::checkPropertiesIfPresent
+ );
+
+ assertEquals("At least one of BrokerServiceUrl or BrokerServiceUrlTls
must be set.", exception.getMessage());
Review Comment:
Since this change affects the API `Update cluster`, could you also add a
test for this API? You can write this test in the class `AdminApi2Test`, and
there are a lot of demos.
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/ClusterDataImpl.java:
##########
@@ -412,7 +412,16 @@ public ClusterDataImpl build() {
*
* @throws IllegalArgumentException exist illegal property.
*/
- public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ public void checkPropertiesIfPresent() throws IllegalArgumentException {
Review Comment:
Could you format the code to make the code lines have the same alignment?
<img width="880" alt="截屏2023-07-28 01 55 37"
src="https://github.com/apache/pulsar/assets/25195800/998cf694-79ab-4b49-a905-ae0f8824d300">
--
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]