virajjasani commented on code in PR #6546:
URL: https://github.com/apache/hadoop/pull/6546#discussion_r1492011256
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestStringUtils.java:
##########
@@ -566,6 +568,86 @@ public void testStringCollectionSplitByEquals() {
.containsEntry("element.xyz.key5", "element.abc.val5")
.containsEntry("element.xyz.key6", "element.abc.val6")
.containsEntry("element.xyz.key7", "element.abc.val7");
+
+ try {
+ StringUtils.getTrimmedStringCollectionSplitByEquals(
+ " = element.abc.val1");
+ throw new RuntimeException("Expected to throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ Assertions
+ .assertThat(e)
+ .describedAs("Exception thrown due to illegal arguments")
+ .hasMessageStartingWith(STRING_COLLECTION_SPLIT_EQUALS_INVALID_ARG);
+ }
+
+ splitMap = StringUtils.getTrimmedStringCollectionSplitByEquals(
+ "element.first.key1 = element.first.val2 ,element.first.key1
=element.first.val1");
+ Assertions
+ .assertThat(splitMap)
+ .describedAs("Map of key value pairs split by equals(=) and comma(,)")
+ .hasSize(1)
+ .containsEntry("element.first.key1", "element.first.val1");
+
+ splitMap = StringUtils.getTrimmedStringCollectionSplitByEquals(
+ ",,, , ,, ,element.first.key1 = element.first.val2 ,"
+ + "element.first.key1 = element.first.val1 , ,,, ,");
+ Assertions
+ .assertThat(splitMap)
+ .describedAs("Map of key value pairs split by equals(=) and comma(,)")
+ .hasSize(1)
+ .containsEntry("element.first.key1", "element.first.val1");
+
+ try {
+ StringUtils.getTrimmedStringCollectionSplitByEquals(
Review Comment:
ah yes, that's already an amazing utility
--
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]