public static Map<String, String> getTrimmedStringCollectionSplitByEquals(
      String str) {
    String[] trimmedList = getTrimmedStrings(str);
    Map<String, String> pairs = new HashMap<>();
    for (String s : trimmedList) {
      if (s.isEmpty()) {
        continue;
      }
      String[] splitByKeyVal = getTrimmedStringsSplitByEquals(s);
      Preconditions.checkArgument(
          splitByKeyVal.length == 2,
          STRING_COLLECTION_SPLIT_EQUALS_INVALID_ARG + " Input: " + str);
      boolean emptyKey = org.apache.commons.lang3.StringUtils.isEmpty(splitByKeyVal[0]);
      boolean emptyVal = org.apache.commons.lang3.StringUtils.isEmpty(splitByKeyVal[1]);
      Preconditions.checkArgument(
          !emptyKey && !emptyVal,
          STRING_COLLECTION_SPLIT_EQUALS_INVALID_ARG + " Input: " + str);
      pairs.put(splitByKeyVal[0], splitByKeyVal[1]);
    }
    return pairs;
  }
@Test
  public void testStringCollectionSplitByEqualsSuccess() {
    Map<String, String> splitMap =
        StringUtils.getTrimmedStringCollectionSplitByEquals("");
    Assertions
        .assertThat(splitMap)
        .describedAs("Map of key value pairs split by equals(=) and comma(,)")
        .hasSize(0);

    splitMap = StringUtils.getTrimmedStringCollectionSplitByEquals(null);
    Assertions
        .assertThat(splitMap)
        .describedAs("Map of key value pairs split by equals(=) and comma(,)")
        .hasSize(0);

    splitMap = StringUtils.getTrimmedStringCollectionSplitByEquals(
        "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.xyz.key1 =element.abc.val1 , element.xyz.key2= element.abc.val2");

    Assertions
        .assertThat(splitMap)
        .describedAs("Map of key value pairs split by equals(=) and comma(,)")
        .hasSize(2)
        .containsEntry("element.xyz.key1", "element.abc.val1")
        .containsEntry("element.xyz.key2", "element.abc.val2");

    splitMap = StringUtils.getTrimmedStringCollectionSplitByEquals(
        "\nelement.xyz.key1 =element.abc.val1 \n"
            + ", element.xyz.key2=element.abc.val2,element.xyz.key3=element.abc.val3"
            + " , element.xyz.key4     =element.abc.val4,element.xyz.key5=        "
            + "element.abc.val5 ,\n \n \n "
            + " element.xyz.key6      =       element.abc.val6 \n , \n"
            + "element.xyz.key7=element.abc.val7,\n");

    Assertions
        .assertThat(splitMap)
        .describedAs("Map of key value pairs split by equals(=) and comma(,)")
        .hasSize(7)
        .containsEntry("element.xyz.key1", "element.abc.val1")
        .containsEntry("element.xyz.key2", "element.abc.val2")
        .containsEntry("element.xyz.key3", "element.abc.val3")
        .containsEntry("element.xyz.key4", "element.abc.val4")
        .containsEntry("element.xyz.key5", "element.abc.val5")
        .containsEntry("element.xyz.key6", "element.abc.val6")
        .containsEntry("element.xyz.key7", "element.abc.val7");

    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");

    splitMap = StringUtils.getTrimmedStringCollectionSplitByEquals(
        ",, , ,      ,, ,");
    Assertions
        .assertThat(splitMap)
        .describedAs("Map of key value pairs split by equals(=) and comma(,)")
        .hasSize(0);

  }