From 36b78208578dcff107acec86cef18a75230d992c Mon Sep 17 00:00:00 2001 From: Julian Reschke Date: Fri, 20 Dec 2024 11:36:40 +0100 Subject: [PATCH] OAK-11311: Remove usage of Guava ImmutableList - oak-commons --- .../oak/commons/FileLineDifferenceIteratorTest.java | 8 ++++---- .../jackrabbit/oak/commons/sort/StringSortTest.java | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileLineDifferenceIteratorTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileLineDifferenceIteratorTest.java index 8011eb15b6d..1cb0ecf497a 100644 --- a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileLineDifferenceIteratorTest.java +++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/FileLineDifferenceIteratorTest.java @@ -37,7 +37,7 @@ import org.apache.commons.io.LineIterator; import org.apache.jackrabbit.guava.common.base.Splitter; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.commons.io.FileLineDifferenceIterator; import org.jetbrains.annotations.Nullable; import org.junit.Test; @@ -159,12 +159,12 @@ private static List escape(List list) { private static void assertReverseDiff(String marked, String all, List diff) throws IOException { Iterator itr = createItr(all, marked); - assertThat("marked: " + marked + " all: " + all, ImmutableList.copyOf(itr), is(diff)); + assertThat("marked: " + marked + " all: " + all, CollectionUtils.toList(itr), is(diff)); } private static void assertDiff(String marked, String all, List diff) throws IOException { Iterator itr = createItr(marked, all); - assertThat("marked: " + marked + " all: " + all, ImmutableList.copyOf(itr), is(diff)); + assertThat("marked: " + marked + " all: " + all, CollectionUtils.toList(itr), is(diff)); } private static Iterator createItr(String marked, String all) throws IOException { @@ -189,6 +189,6 @@ public String apply(@Nullable String input) { } }); - assertThat("marked: " + marked + " all: " + all, ImmutableList.copyOf(itr), is(diff)); + assertThat("marked: " + marked + " all: " + all, CollectionUtils.toList(itr), is(diff)); } } 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 cf8423038a9..1006d190acf 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,8 +28,7 @@ import java.util.List; import java.util.Set; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -106,7 +105,7 @@ private void assertConstraints(List paths) throws IOException { Collections.sort(paths, comparator); collector.sort(); - List sortedPaths = ImmutableList.copyOf(collector.getIds()); + List sortedPaths = CollectionUtils.toList(collector.getIds()); assertEquals(paths.size(), sortedPaths.size()); assertEquals(paths, sortedPaths); } @@ -123,7 +122,7 @@ private static List createTestPaths(int depth, boolean permutation){ if (permutation) { List newRoots = new ArrayList<>(); - CollectionUtils.permutations(rootPaths). + org.apache.commons.collections4.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)));