Skip to content

Commit

Permalink
Test can reuse StringUtils.join(Iterable, String)
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Dec 7, 2024
1 parent fa88991 commit 2bd480d
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/test/java/org/apache/commons/beanutils2/PropertyUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

import org.apache.commons.beanutils2.priv.PrivateBeanFactory;
import org.apache.commons.beanutils2.priv.PrivateDirect;
import org.apache.commons.beanutils2.priv.PublicSubBean;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -156,17 +158,8 @@ private static PropertyDescriptor findNameDescriptor(final PropertyDescriptor[]
* <p>
* If there are no keys, an empty string is returned.
*/
private String keysToString(final Map<?, ?> map) {
final Object[] mapKeys = map.keySet().toArray();
Arrays.sort(mapKeys);
final StringBuilder buf = new StringBuilder();
for (int i = 0; i < mapKeys.length; ++i) {
if (i != 0) {
buf.append(", ");
}
buf.append(mapKeys[i]);
}
return buf.toString();
private String keysToString(final Map<String, ?> map) {
return StringUtils.join(new TreeSet<>(map.keySet()), ", ");
}

/**
Expand Down

0 comments on commit 2bd480d

Please sign in to comment.