ytatichno commented on code in PR #668:
URL:
https://github.com/apache/commons-collections/pull/668#discussion_r3428067138
##########
src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java:
##########
@@ -142,6 +144,30 @@ void testInvert() {
assertEquals("[commons-collections, commons-configuration2]",
codecUsagesAll.toString());
}
+ @Test
+ void testInvertMap() {
+ final HashSetValuedHashMap<String, String> usages = new
HashSetValuedHashMap<>();
+
+ final Map<String, String> deps = new HashMap<>();
+ deps.put("commons-configuration1", "commons-logging");
+ deps.put("commons-configuration2", "commons-lang3");
+ deps.put("commons-configuration3", "commons-text");
+ deps.put("commons-beanutils1", "commons-collections");
+ deps.put("commons-beanutils2", "commons-logging");
+ MultiMapUtils.invert(deps, usages);
+ final Set<String> loggingUsagesCompile = usages.get("commons-logging");
+ assertEquals("[commons-beanutils2, commons-configuration1]",
loggingUsagesCompile.toString());
Review Comment:
Minor observation: I’m not sure about relying on the set’s iteration order
here (and other asserts in this test with sets casted `toString()`).
`HashSetValuedHashMap.get()` returns a `Set<String>`, but
`WrappedSet`/`HashSet` doesn’t guarantee order, so `toString()` output could
vary across JVMs or even runs.
--
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]