From 5a1f56b93682f3c0f49ee17c87e5e55e13bcb1aa Mon Sep 17 00:00:00 2001 From: Julian Reschke Date: Thu, 12 Dec 2024 18:18:31 +0100 Subject: [PATCH] OAK-11304: Remove usage of Guava Collections2 - oak-commons --- oak-commons/pom.xml | 7 ++++++- .../oak/commons/sort/StringSortTest.java | 14 +++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/oak-commons/pom.xml b/oak-commons/pom.xml index b7648727ed6..a3d43214ee3 100644 --- a/oak-commons/pom.xml +++ b/oak-commons/pom.xml @@ -127,6 +127,11 @@ commons-lang3 test + + org.apache.commons + commons-collections4 + test + org.mockito mockito-core @@ -137,6 +142,6 @@ lz4-java 1.8.0 test - + diff --git a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/StringSortTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/StringSortTest.java index f419be958a2..cf8423038a9 100644 --- a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/StringSortTest.java +++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/sort/StringSortTest.java @@ -28,7 +28,7 @@ import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.Collections2; +import org.apache.commons.collections4.CollectionUtils; import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.junit.Test; @@ -121,12 +121,12 @@ private static List createTestPaths(int depth, boolean permutation){ List rootPaths = Arrays.asList("a", "b", "c", "d", "e", "f", "g"); List paths = new ArrayList(); - - if (permutation){ - List newRoots = new ArrayList(); - for (List permuts : Collections2.orderedPermutations(rootPaths)){ - newRoots.add(String.join("", permuts)); - } + if (permutation) { + List newRoots = new ArrayList<>(); + CollectionUtils.permutations(rootPaths). + stream(). + sorted((a, b) -> Arrays.compare(a.toArray(new String[0]), b.toArray(new String[0]))). + forEach(permuts -> newRoots.add(String.join("", permuts))); rootPaths = newRoots; }