From bad4936c695702f062be7eda8c1e069bdb663386 Mon Sep 17 00:00:00 2001 From: Rishabh Kumar Date: Mon, 13 Jan 2025 10:26:38 +0530 Subject: [PATCH] OAK-11384 : removed usage of Guava's Maps.difference (#1977) Co-authored-by: Rishabh Kumar --- ...uthenticationConfigurationImplOSGiTest.java | 18 ++++++++++++++---- .../oak/run/cli/BlobStoreFixtureProvider.java | 1 - .../cli/blob/AzureDataStoreFactory.java | 2 -- .../upgrade/cli/blob/S3DataStoreFactory.java | 2 -- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/AuthenticationConfigurationImplOSGiTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/AuthenticationConfigurationImplOSGiTest.java index d21334dcf94..dc1edfb0f67 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/AuthenticationConfigurationImplOSGiTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/AuthenticationConfigurationImplOSGiTest.java @@ -16,9 +16,7 @@ */ package org.apache.jackrabbit.oak.security.authentication; -import org.apache.jackrabbit.guava.common.collect.Maps; import org.apache.jackrabbit.oak.AbstractSecurityTest; -import org.apache.jackrabbit.oak.osgi.OsgiUtil; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; import org.apache.sling.testing.mock.osgi.junit.OsgiContext; import org.junit.Rule; @@ -27,8 +25,10 @@ import javax.jcr.SimpleCredentials; +import java.util.Map; +import java.util.Objects; + import static org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration.PARAM_APP_NAME; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; public class AuthenticationConfigurationImplOSGiTest extends AbstractSecurityTest { @@ -54,6 +54,16 @@ public void testGetParameters() { ConfigurationParameters expected = ConfigurationParameters.of( PARAM_APP_NAME, "name", Constants.SERVICE_PID, authenticationConfiguration.getClass().getName()); - assertTrue(Maps.difference(expected, authenticationConfiguration.getParameters()).areEqual()); + assertTrue(areEqual(expected, authenticationConfiguration.getParameters())); + } + + // helper methods + private boolean areEqual(Map first, Map second) { + if (first.size() != second.size()) { + return false; + } + + return first.entrySet().stream() + .allMatch(e -> Objects.equals(e.getValue(), second.get(e.getKey()))); } } \ No newline at end of file diff --git a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreFixtureProvider.java b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreFixtureProvider.java index 81a8c4f964c..ea6d3469931 100644 --- a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreFixtureProvider.java +++ b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreFixtureProvider.java @@ -29,7 +29,6 @@ import java.util.Map; import java.util.Properties; -import org.apache.jackrabbit.guava.common.collect.Maps; import org.apache.jackrabbit.guava.common.io.Closer; import org.apache.jackrabbit.guava.common.io.Files; import org.apache.commons.io.FileUtils; diff --git a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/blob/AzureDataStoreFactory.java b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/blob/AzureDataStoreFactory.java index 1c17b073263..41c72f15405 100644 --- a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/blob/AzureDataStoreFactory.java +++ b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/blob/AzureDataStoreFactory.java @@ -41,8 +41,6 @@ import org.apache.jackrabbit.oak.spi.blob.BlobStore; import org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider; import org.apache.jackrabbit.oak.stats.StatisticsProvider; - -import org.apache.jackrabbit.guava.common.collect.Maps; import org.apache.jackrabbit.guava.common.io.Closer; import org.apache.jackrabbit.guava.common.io.Files; diff --git a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/blob/S3DataStoreFactory.java b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/blob/S3DataStoreFactory.java index 1f78b5fdeb3..582710abd0a 100644 --- a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/blob/S3DataStoreFactory.java +++ b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/blob/S3DataStoreFactory.java @@ -32,14 +32,12 @@ import javax.jcr.RepositoryException; -import org.apache.jackrabbit.guava.common.collect.Maps; import org.apache.commons.io.IOUtils; import org.apache.jackrabbit.core.data.DataStoreException; import org.apache.jackrabbit.oak.blob.cloud.s3.S3DataStore; import org.apache.jackrabbit.oak.commons.PropertiesUtil; import org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore; import org.apache.jackrabbit.oak.spi.blob.BlobStore; - import org.apache.jackrabbit.guava.common.io.Closer; import org.apache.jackrabbit.guava.common.io.Files; import org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider;