diff --git a/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalIdentityRepositoryInitializer.java b/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalIdentityRepositoryInitializer.java index fac8145fb57..96e3bf2eac7 100644 --- a/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalIdentityRepositoryInitializer.java +++ b/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalIdentityRepositoryInitializer.java @@ -22,7 +22,7 @@ import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.jetbrains.annotations.NotNull; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import java.util.List; /** * Implementation of the {@code RepositoryInitializer} interface responsible for @@ -54,12 +54,12 @@ public void initialize(@NotNull NodeBuilder builder) { NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder); if (enforceUniqueIds && !index.hasChildNode("externalId")) { NodeBuilder definition = IndexUtils.createIndexDefinition(index, "externalId", true, true, - ImmutableList.of(ExternalIdentityConstants.REP_EXTERNAL_ID), null); + List.of(ExternalIdentityConstants.REP_EXTERNAL_ID), null); definition.setProperty("info", "Oak index assuring uniqueness of rep:externalId properties."); } if (!index.hasChildNode("externalPrincipalNames")) { NodeBuilder definition = IndexUtils.createIndexDefinition(index, "externalPrincipalNames", true, false, - ImmutableList.of(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES), null); + List.of(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES), null); definition.setProperty("info", "Oak index used by the principal management provided by the external authentication module."); } diff --git a/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalPrincipalConfiguration.java b/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalPrincipalConfiguration.java index 14644cb98c1..ffa37a671ea 100644 --- a/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalPrincipalConfiguration.java +++ b/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalPrincipalConfiguration.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.principal.PrincipalManager; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.namepath.NamePathMapper; @@ -53,6 +52,7 @@ import org.osgi.service.metatype.annotations.Option; import java.security.Principal; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; @@ -182,7 +182,7 @@ public RepositoryInitializer getRepositoryInitializer() { public List getValidators(@NotNull String workspaceName, @NotNull Set principals, @NotNull MoveTracker moveTracker) { boolean isSystem = new SystemPrincipalConfig(getPrincipalNames()).containsSystemPrincipal(principals); - ImmutableList.Builder vps = new ImmutableList.Builder<>(); + List vps = new ArrayList<>(); vps.add(new ExternalIdentityValidatorProvider(isSystem, protectedExternalIds())); Set idpNamesWithDynamicGroups = getIdpNamesWithDynamicGroups(); @@ -194,7 +194,7 @@ public List getValidators(@NotNull String workspace if (ipt != IdentityProtectionType.NONE && !isSystem) { vps.add(new ExternalUserValidatorProvider(getRootProvider(), getTreeProvider(), getSecurityProvider(), ipt, getProtectionConfig())); } - return vps.build(); + return Collections.unmodifiableList(vps); } @NotNull diff --git a/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalUserValidatorProvider.java b/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalUserValidatorProvider.java index cb9fc52dd4f..e8204604adc 100644 --- a/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalUserValidatorProvider.java +++ b/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalUserValidatorProvider.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.PropertyState; @@ -44,6 +43,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import static org.apache.jackrabbit.oak.commons.conditions.Validate.checkArgument; @@ -284,13 +285,13 @@ private static final class AggregatedContext extends Context.Default { List ctxs; private AggregatedContext(@NotNull SecurityProvider securityProvider) { - ImmutableList.Builder builder = ImmutableList.builder(); + List builder = new ArrayList<>(); for (SecurityConfiguration sc : securityProvider.getConfigurations()) { if (!UserConfiguration.NAME.equals(sc.getName())) { builder.add(sc.getContext()); } } - ctxs = builder.build(); + ctxs = Collections.unmodifiableList(builder); } @Override diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalIdentityRefTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalIdentityRefTest.java index 9da36685a8e..38e73d903b1 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalIdentityRefTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalIdentityRefTest.java @@ -17,11 +17,10 @@ package org.apache.jackrabbit.oak.spi.security.authentication.external; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.Test; @@ -169,7 +168,7 @@ public Iterable getDeclaredGroups() { @Test public void testToString() { - for (ExternalIdentityRef r : ImmutableList.of(ref, refEmptyProvider, refEmptyProvider)) { + for (ExternalIdentityRef r : List.of(ref, refEmptyProvider, refEmptyProvider)) { assertEquals("ExternalIdentityRef{" + "id='" + r.getId() + '\'' + ", providerName='" + r.getProviderName() + '\'' + '}', r.toString()); } } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/TestIdentityProvider.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/TestIdentityProvider.java index ebbb8d17b0c..380f7e8ed1e 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/TestIdentityProvider.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/TestIdentityProvider.java @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Supplier; @@ -29,8 +30,6 @@ import javax.jcr.SimpleCredentials; import javax.security.auth.login.LoginException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.jetbrains.annotations.NotNull; @@ -76,7 +75,7 @@ public TestIdentityProvider(@NotNull String idpName) { addUser(new TestUser(ID_SECOND_USER, getName()) .withProperty("profile/name", "Second User") .withProperty("age", 24) - .withProperty("col", ImmutableList.of("v1", "v2", "v3")) + .withProperty("col", List.of("v1", "v2", "v3")) .withProperty("boolArr", new Boolean[]{true, false}) .withProperty("charArr", new char[]{'t', 'o', 'b'}) .withProperty("byteArr", new byte[0]) @@ -284,7 +283,7 @@ public ForeignExternalGroup() { @NotNull @Override public Iterable getDeclaredMembers() { - return ImmutableList.of(); + return List.of(); } } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/basic/DefaultSyncContextTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/basic/DefaultSyncContextTest.java index 32a607cbaed..444d26698ea 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/basic/DefaultSyncContextTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/basic/DefaultSyncContextTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.basic; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; @@ -1451,7 +1450,7 @@ public void testCreateValueFromInputStream() throws Exception { @Test public void testCreateValuesEmptyCollection() throws Exception { - Value[] vs = syncCtx.createValues(ImmutableList.of()); + Value[] vs = syncCtx.createValues(List.of()); assertNotNull(vs); assertEquals(0, vs.length); } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/AbstractDynamicTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/AbstractDynamicTest.java index 41909166559..6094a9774e5 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/AbstractDynamicTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/AbstractDynamicTest.java @@ -16,12 +16,11 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; -import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.UserManager; import org.apache.jackrabbit.oak.api.Root; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser; @@ -36,6 +35,7 @@ import java.security.Principal; import java.util.Iterator; import java.util.List; +import java.util.stream.Collectors; import static org.junit.Assert.assertSame; @@ -116,17 +116,17 @@ protected void sync(@NotNull ExternalIdentity externalIdentity, @NotNull SyncRes @NotNull static List getIds(@NotNull Iterator authorizables) { - return ImmutableList.copyOf(Iterators.transform(authorizables, authorizable -> { + return CollectionUtils.toStream(authorizables).map(authorizable -> { try { return authorizable.getID(); } catch (RepositoryException repositoryException) { throw new RuntimeException(); } - })); + }).collect(Collectors.toList()); } @NotNull static List getPrincipalNames(@NotNull Iterator groupPrincipals) { - return ImmutableList.copyOf(Iterators.transform(groupPrincipals, Principal::getName)); + return CollectionUtils.toStream(groupPrincipals).map(Principal::getName).collect(Collectors.toList()); } } \ No newline at end of file diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/CustomCredentialsSupportTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/CustomCredentialsSupportTest.java index 704f0c1a914..1ba7db49a52 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/CustomCredentialsSupportTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/CustomCredentialsSupportTest.java @@ -27,7 +27,6 @@ import javax.jcr.SimpleCredentials; import javax.security.auth.login.LoginException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.AuthInfo; import org.apache.jackrabbit.oak.api.ContentSession; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup; @@ -71,7 +70,7 @@ public void testLogin() throws Exception { @Test public void testLoginWithUnsupportedCredentials() throws Exception { - List creds = ImmutableList.of( + List creds = List.of( new SimpleCredentials("testUser", new char[0]), new GuestCredentials()); diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicGroupsTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicGroupsTest.java index a398d75482a..a6e57907d35 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicGroupsTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicGroupsTest.java @@ -16,9 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; -import org.apache.jackrabbit.guava.common.collect.Iterators; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal; import org.apache.jackrabbit.api.security.principal.PrincipalManager; import org.apache.jackrabbit.api.security.user.Authorizable; @@ -26,6 +23,7 @@ import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.api.security.user.UserManager; import org.apache.jackrabbit.oak.api.Tree; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityProvider; @@ -294,7 +292,7 @@ public void testCrossIDPMembership() throws Exception { UserManager um = getUserManager(r); PrincipalManager pm = getPrincipalManager(r); - List declaredGroupRefs = ImmutableList.copyOf(previouslySyncedUser.getDeclaredGroups()); + List declaredGroupRefs = CollectionUtils.toList(previouslySyncedUser.getDeclaredGroups()); assertTrue(declaredGroupRefs.size() > 1); String groupId = declaredGroupRefs.get(0).getId(); diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicSyncContextTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicSyncContextTest.java index 40106a43991..6680d231bc3 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicSyncContextTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/DynamicSyncContextTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.user.Authorizable; @@ -47,6 +46,7 @@ import javax.jcr.RepositoryException; import javax.jcr.Value; +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Objects; @@ -119,7 +119,7 @@ protected void assertDynamicMembership(@NotNull ExternalIdentity externalIdentit private void assertDynamicMembership(@NotNull Authorizable a, @NotNull ExternalIdentity externalIdentity, long depth) throws Exception { Value[] vs = a.getProperty(REP_EXTERNAL_PRINCIPAL_NAMES); - Set pNames = ImmutableList.copyOf(vs).stream().map(value -> { + Set pNames = Arrays.stream(vs).map(value -> { try { return value.getString(); } catch (RepositoryException e) { diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/DynamicGroupValidatorTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/DynamicGroupValidatorTest.java index 130605c6f3f..b780521f332 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/DynamicGroupValidatorTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/DynamicGroupValidatorTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.api.security.user.User; @@ -141,7 +140,7 @@ public void testAddMembersProperty() throws Exception { assertFalse(groupTree.hasProperty(REP_MEMBERS)); String uuid = r.getTree(userManager.getAuthorizable(USER_ID).getPath()).getProperty(JCR_UUID).getValue(Type.STRING); - groupTree.setProperty(REP_MEMBERS, ImmutableList.of(uuid), Type.WEAKREFERENCES); + groupTree.setProperty(REP_MEMBERS, List.of(uuid), Type.WEAKREFERENCES); try { r.commit(); fail("CommitFailedException 77 expected."); diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProviderTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProviderTest.java index 3fa32144a98..832192d7613 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProviderTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalProviderTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.principal.GroupPrincipal; import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal; @@ -29,6 +28,7 @@ import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.namepath.NamePathMapper; import org.apache.jackrabbit.oak.plugins.tree.TreeAware; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup; @@ -593,7 +593,7 @@ public Iterator findPrincipals(@Nullable String nameHint, i return in.iterator(); } }; - List out = ImmutableList.copyOf(p.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1)); + List out = CollectionUtils.toList(p.findPrincipals(null, false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1)); Collections.sort(in, Comparator.comparing(Principal::getName)); assertEquals(in, out); } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalTest.java index 78e5bb6ac63..69cb1f25a5b 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalGroupPrincipalTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.principal.GroupPrincipal; import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal; @@ -26,6 +25,7 @@ import org.apache.jackrabbit.oak.api.QueryEngine; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser; @@ -38,7 +38,9 @@ import java.security.Principal; import java.text.ParseException; import java.util.Enumeration; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import static org.apache.jackrabbit.oak.spi.security.authentication.external.TestIdentityProvider.ID_SECOND_USER; import static org.apache.jackrabbit.oak.spi.security.authentication.external.impl.ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES; @@ -69,10 +71,10 @@ public void testNotIsMember() throws Exception { Authorizable notMember = getUserManager(root).getAuthorizable(ID_SECOND_USER); assertFalse(principal.isMember(notMember.getPrincipal())); - root.getTree(notMember.getPath()).setProperty(REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("secondGroup"), Type.STRINGS); + root.getTree(notMember.getPath()).setProperty(REP_EXTERNAL_PRINCIPAL_NAMES, List.of("secondGroup"), Type.STRINGS); assertFalse(principal.isMember(notMember.getPrincipal())); - root.getTree(notMember.getPath()).setProperty(REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of(), Type.STRINGS); + root.getTree(notMember.getPath()).setProperty(REP_EXTERNAL_PRINCIPAL_NAMES, List.of(), Type.STRINGS); assertFalse(principal.isMember(new PrincipalImpl(notMember.getPrincipal().getName()))); } @@ -80,7 +82,8 @@ public void testNotIsMember() throws Exception { public void testIsMemberExternalGroup() throws Exception { GroupPrincipal principal = getGroupPrincipal(); - Iterable exGroupPrincNames = Iterables.transform(ImmutableList.copyOf(idp.listGroups()), ExternalIdentity::getPrincipalName); + List exGroupPrincNames = CollectionUtils.toStream( + idp.listGroups()).map(ExternalIdentity::getPrincipalName).collect(Collectors.toList()); for (String principalName : exGroupPrincNames) { assertFalse(principal.isMember(new PrincipalImpl(principalName))); } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalIdentityValidatorTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalIdentityValidatorTest.java index 52963b03707..b45b21062b0 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalIdentityValidatorTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ExternalIdentityValidatorTest.java @@ -18,7 +18,6 @@ import javax.jcr.SimpleCredentials; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.oak.api.CommitFailedException; @@ -85,7 +84,7 @@ protected boolean isDynamic() { public void testAddExternalPrincipalNames() throws Exception { Tree userTree = root.getTree(testUserPath); try { - userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("principalName"), Type.STRINGS); + userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, List.of("principalName"), Type.STRINGS); root.commit(); fail("Creating rep:externalPrincipalNames must be detected."); } catch (CommitFailedException e) { @@ -101,7 +100,7 @@ public void testAddExternalPrincipalNamesAsSystemMissingExternalId() throws Exce Root systemRoot = getSystemRoot(); try { Tree userTree = systemRoot.getTree(testUserPath); - userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("principalName"), Type.STRINGS); + userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, List.of("principalName"), Type.STRINGS); systemRoot.commit(); fail("Creating rep:externalPrincipalNames without rep:externalId must be detected."); } catch (CommitFailedException e) { @@ -117,7 +116,7 @@ public void testAddExternalPrincipalNamesAsSystem() throws Exception { Root systemRoot = getSystemRoot(); Tree userTree = systemRoot.getTree(testUserPath); userTree.setProperty(REP_EXTERNAL_ID, "externalId"); - userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("principalName"), Type.STRINGS); + userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, List.of("principalName"), Type.STRINGS); systemRoot.commit(); } @@ -167,7 +166,7 @@ public void testModifyExternalPrincipalNamesAsSystem() throws Exception { Tree userTree = systemRoot.getTree(externalUserPath); // changing with system root must succeed - userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("principalNames"), Type.STRINGS); + userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, List.of("principalNames"), Type.STRINGS); systemRoot.commit(); } @@ -233,7 +232,7 @@ public void testRepExternalIdMultiple() throws Exception { Root systemRoot = getSystemRoot(); try { Tree userTree = systemRoot.getTree(testUserPath); - userTree.setProperty(REP_EXTERNAL_ID, ImmutableList.of("id", "id2"), Type.STRINGS); + userTree.setProperty(REP_EXTERNAL_ID, List.of("id", "id2"), Type.STRINGS); systemRoot.commit(); fail("Creating rep:externalId as multiple STRING property must be detected."); } catch (CommitFailedException e) { diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/PrincipalProviderAutoMembershipTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/PrincipalProviderAutoMembershipTest.java index 9f4c37d3bbb..5b23190cc1a 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/PrincipalProviderAutoMembershipTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/PrincipalProviderAutoMembershipTest.java @@ -16,10 +16,8 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterators; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.api.security.principal.GroupPrincipal; import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal; import org.apache.jackrabbit.api.security.principal.PrincipalManager; @@ -301,7 +299,7 @@ public void testGetPrincipals() throws Exception { @Test public void testFindPrincipalsByHint() throws Exception { - List hints = ImmutableList.of( + List hints = List.of( USER_AUTO_MEMBERSHIP_GROUP_PRINCIPAL_NAME, GROUP_AUTO_MEMBERSHIP_GROUP_PRINCIPAL_NAME, USER_AUTO_MEMBERSHIP_GROUP_ID, diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ValidatorNoProtectionTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ValidatorNoProtectionTest.java index 0c894a35510..8866700c557 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ValidatorNoProtectionTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ValidatorNoProtectionTest.java @@ -16,9 +16,9 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; +import java.util.List; import java.util.Map; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; @@ -41,7 +41,7 @@ public void before() throws Exception { public void testRepExternalIdMultiple() throws Exception { Root systemRoot = getSystemRoot(); Tree userTree = systemRoot.getTree(testUserPath); - userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_ID, ImmutableList.of("id", "id2"), Type.STRINGS); + userTree.setProperty(ExternalIdentityConstants.REP_EXTERNAL_ID, List.of("id", "id2"), Type.STRINGS); systemRoot.commit(); } diff --git a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ValidatorNotDynamicTest.java b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ValidatorNotDynamicTest.java index a6a9ab2d366..f63aef64502 100644 --- a/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ValidatorNotDynamicTest.java +++ b/oak-auth-external/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/principal/ValidatorNotDynamicTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.external.impl.principal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; @@ -24,6 +23,8 @@ import org.apache.jackrabbit.oak.spi.security.authentication.external.impl.ExternalIdentityConstants; import org.junit.Test; +import java.util.List; + import static org.apache.jackrabbit.oak.api.CommitFailedException.CONSTRAINT; import static org.junit.Assert.fail; @@ -41,7 +42,7 @@ protected boolean isDynamic() { private void setExternalPrincipalNames() throws Exception { Root systemRoot = getSystemRoot(); - systemRoot.getTree(externalUserPath).setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, ImmutableList.of("principalName"), Type.STRINGS); + systemRoot.getTree(externalUserPath).setProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, List.of("principalName"), Type.STRINGS); systemRoot.commit(); root.refresh(); diff --git a/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugConfiguration.java b/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugConfiguration.java index 4a086ec7706..db38a54bbfd 100644 --- a/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugConfiguration.java +++ b/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugConfiguration.java @@ -26,7 +26,6 @@ import javax.jcr.RepositoryException; import javax.jcr.security.AccessControlManager; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.namepath.NamePathMapper; @@ -171,7 +170,7 @@ public List getCommitHooks(@NotNull String workspaceName) @NotNull @Override public List getValidators(@NotNull String workspaceName, @NotNull Set principals, @NotNull MoveTracker moveTracker) { - return ImmutableList.of(new CugValidatorProvider()); + return List.of(new CugValidatorProvider()); } @NotNull diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/AccessControlTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/AccessControlTest.java index b157e1b404c..bef75f9debf 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/AccessControlTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/AccessControlTest.java @@ -21,7 +21,6 @@ import javax.jcr.security.AccessControlManager; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; @@ -73,7 +72,7 @@ public void before() throws Exception { * - /content2 : allow everyone, deny testGroup (isolated) * */ - acPaths = ImmutableList.of( + acPaths = List.of( "/content/rep:policy", PermissionConstants.PERMISSIONS_STORE_PATH, "/content/a/rep:cugPolicy", diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugAccessControlManagerTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugAccessControlManagerTest.java index 34e1598281a..3f8a124b575 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugAccessControlManagerTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugAccessControlManagerTest.java @@ -30,7 +30,6 @@ import javax.jcr.security.NamedAccessControlPolicy; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.guava.common.collect.Sets; @@ -171,7 +170,7 @@ public void testGetPoliciesAfterManualCreation() throws Exception { CugPolicy cugPolicy = (CugPolicy) policies[0]; assertTrue(cugPolicy.getPrincipals().isEmpty()); - cug.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of("unknownPrincipalName", EveryonePrincipal.NAME), Type.STRINGS); + cug.setProperty(REP_PRINCIPAL_NAMES, List.of("unknownPrincipalName", EveryonePrincipal.NAME), Type.STRINGS); policies = cugAccessControlManager.getPolicies(SUPPORTED_PATH); cugPolicy = (CugPolicy) policies[0]; @@ -324,7 +323,7 @@ public void testSetPolicyPersisted() throws Exception { @Test public void testSetInvalidPolicy() throws Exception { - List invalidPolicies = ImmutableList.of( + List invalidPolicies = List.of( new AccessControlPolicy() {}, (NamedAccessControlPolicy) () -> "name", InvalidCug.INSTANCE @@ -454,7 +453,7 @@ public void testRemovePolicyMixinAlreadyRemoved() throws Exception { @Test public void testRemoveInvalidPolicy() throws Exception { - List invalidPolicies = ImmutableList.of( + List invalidPolicies = List.of( new AccessControlPolicy() {}, (NamedAccessControlPolicy) () -> "name", InvalidCug.INSTANCE diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugConfigurationTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugConfigurationTest.java index e5aab423ae1..5023c9a6e61 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugConfigurationTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugConfigurationTest.java @@ -23,7 +23,6 @@ import java.util.Set; import javax.jcr.security.AccessControlManager; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.namepath.NamePathMapper; @@ -187,7 +186,7 @@ public void testExcludedPrincipals() { CugConstants.PARAM_CUG_SUPPORTED_PATHS, "/content"); CugConfiguration cc = createConfiguration(params); - List excluded = ImmutableList.of( + List excluded = List.of( SystemPrincipal.INSTANCE, (AdminPrincipal) () -> "admin", (SystemUserPrincipal) () -> "systemUser"); diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugContextTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugContextTest.java index 63c323b78ec..5508bde0128 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugContextTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugContextTest.java @@ -21,7 +21,6 @@ import javax.jcr.security.AccessControlList; import javax.jcr.security.AccessControlManager; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; import org.apache.jackrabbit.oak.api.PropertyState; @@ -41,7 +40,7 @@ public class CugContextTest extends AbstractCugTest implements NodeTypeConstants { private static String CUG_PATH = "/content/a/rep:cugPolicy"; - private static List NO_CUG_PATH = ImmutableList.of( + private static List NO_CUG_PATH = List.of( "/content", "/content/a", "/content/rep:policy", @@ -116,7 +115,7 @@ public void testDefinesLocation() { assertTrue(CugContext.INSTANCE.definesLocation(TreeLocation.create(root, CUG_PATH))); assertTrue(CugContext.INSTANCE.definesLocation(TreeLocation.create(root, CUG_PATH + "/" + CugConstants.REP_PRINCIPAL_NAMES))); - List existingNoCug = ImmutableList.of( + List existingNoCug = List.of( "/content", "/content/a", "/content/rep:policy" @@ -126,7 +125,7 @@ public void testDefinesLocation() { assertFalse(path, CugContext.INSTANCE.definesLocation(TreeLocation.create(root, path + "/" + CugConstants.REP_PRINCIPAL_NAMES))); } - List nonExistingCug = ImmutableList.of( + List nonExistingCug = List.of( "/content/rep:cugPolicy", UNSUPPORTED_PATH + "/rep:cugPolicy"); for (String path : nonExistingCug) { diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugEvaluationTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugEvaluationTest.java index 4aea777e4d0..a2ed9357c09 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugEvaluationTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugEvaluationTest.java @@ -22,7 +22,6 @@ import javax.jcr.security.AccessControlList; import javax.jcr.security.AccessControlManager; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; import org.apache.jackrabbit.oak.api.CommitFailedException; @@ -105,7 +104,7 @@ private PermissionProvider createPermissionProvider(Principal... principals) { @Test public void testRead() { - List noAccess = ImmutableList.of( + List noAccess = List.of( "/", UNSUPPORTED_PATH, /* no access */ "/content/a", "/content/a/b", "/content/aa/bb", /* granted by ace, denied by cug */ "/content2" /* granted by cug only */ @@ -114,7 +113,7 @@ public void testRead() { assertFalse(p, testRoot.getTree(p).exists()); } - List readAccess = ImmutableList.of("/content", "/content/subtree", "/content/a/b/c", "/content/aa"); + List readAccess = List.of("/content", "/content/subtree", "/content/a/b/c", "/content/aa"); for (String p : readAccess) { assertTrue(p, testRoot.getTree(p).exists()); } @@ -136,7 +135,7 @@ public void testReadAcl2() throws Exception { @Test public void testReadCug() { - List noAccess = ImmutableList.of( + List noAccess = List.of( "/content/a/rep:cugPolicy", "/content/aa/bb/rep:cugPolicy", "/content2/rep:cugPolicy" ); for (String p : noAccess) { @@ -156,7 +155,7 @@ public void testReadCug2() throws Exception { @Test public void testWrite() throws Exception { - List readOnly = ImmutableList.of("/content", "/content/a/b/c"); + List readOnly = List.of("/content", "/content/a/b/c"); for (String p : readOnly) { try { Tree content = testRoot.getTree(p); @@ -180,7 +179,7 @@ public void testWrite2() throws Exception { assertTrue(pp.isGranted(root.getTree("/content/writeTest"), null, Permissions.ADD_NODE)); assertTrue(pp.isGranted(root.getTree("/content/a/b/c/writeTest"), null, Permissions.ADD_NODE)); - List paths = ImmutableList.of("/content", "/content/a/b/c"); + List paths = List.of("/content", "/content/a/b/c"); for (String p : paths) { Tree content = r.getTree(p); TreeUtil.addChild(content, "writeTest", NT_OAK_UNSTRUCTURED); @@ -198,7 +197,7 @@ public void testWriteAcl() throws Exception { Root r = cs.getLatestRoot(); try { Tree tree = r.getTree("/content/a/b/c"); - tree.setProperty(JCR_MIXINTYPES, ImmutableList.of(MIX_REP_CUG_MIXIN, AccessControlConstants.MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); + tree.setProperty(JCR_MIXINTYPES, List.of(MIX_REP_CUG_MIXIN, AccessControlConstants.MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); tree.addChild(AccessControlConstants.REP_POLICY).setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_ACL, Type.NAME); r.commit(); fail(); @@ -216,7 +215,7 @@ public void testWriteCug() throws Exception { try { // modify the existing cug Tree tree = r.getTree("/content/a/rep:cugPolicy"); - tree.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME, testGroupPrincipal.getName()), Type.STRINGS); + tree.setProperty(REP_PRINCIPAL_NAMES, List.of(EveryonePrincipal.NAME, testGroupPrincipal.getName()), Type.STRINGS); r.commit(); fail(); } catch (CommitFailedException e) { diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugPermissionProviderTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugPermissionProviderTest.java index be0551a2f93..9d26e422a25 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugPermissionProviderTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugPermissionProviderTest.java @@ -25,7 +25,6 @@ import javax.jcr.GuestCredentials; import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.ContentSession; import org.apache.jackrabbit.oak.api.Root; @@ -88,11 +87,11 @@ public class CugPermissionProviderTest extends AbstractCugTest implements NodeTy PATH_INCUG_MAP.put(INVALID_PATH, false); } - private static final List READABLE_PATHS = ImmutableList.of( + private static final List READABLE_PATHS = List.of( "/content/a/b/c", "/content/a/b/c/jcr:primaryType", "/content/a/b/c/nonExisting", "/content/a/b/c/nonExisting/jcr:primaryType"); - private static final List NOT_READABLE_PATHS = ImmutableList.of( + private static final List NOT_READABLE_PATHS = List.of( "/", "/jcr:primaryType", UNSUPPORTED_PATH, UNSUPPORTED_PATH + "/jcr:primaryType", "/content", "/content/jcr:primaryType", diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugValidatorTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugValidatorTest.java index 1831b7921d4..b5036c057f6 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugValidatorTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugValidatorTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.cug.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.PropertyState; @@ -37,6 +36,8 @@ import javax.jcr.nodetype.NodeDefinitionTemplate; import javax.jcr.nodetype.NodeTypeTemplate; +import java.util.List; + import static java.util.Objects.requireNonNull; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -64,7 +65,7 @@ public void testChangePrimaryType() { node = root.getTree(SUPPORTED_PATH2); try { node.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_CUG_POLICY, Type.NAME); - node.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME), Type.STRINGS); + node.setProperty(REP_PRINCIPAL_NAMES, List.of(EveryonePrincipal.NAME), Type.STRINGS); root.commit(); fail(); } catch (CommitFailedException e) { @@ -118,9 +119,9 @@ public void testPropertyChangedNoCugInvolved() throws Exception { @Test(expected = CommitFailedException.class) public void testChangePrimaryTypeOfCug() throws Exception { - node.setProperty(JcrConstants.JCR_MIXINTYPES, ImmutableList.of(MIX_REP_CUG_MIXIN), Type.NAMES); + node.setProperty(JcrConstants.JCR_MIXINTYPES, List.of(MIX_REP_CUG_MIXIN), Type.NAMES); Tree cug = TreeUtil.addChild(node, REP_CUG_POLICY, NT_REP_CUG_POLICY); - cug.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME), Type.STRINGS); + cug.setProperty(REP_PRINCIPAL_NAMES, List.of(EveryonePrincipal.NAME), Type.STRINGS); root.commit(); try { @@ -136,7 +137,7 @@ public void testChangePrimaryTypeOfCug() throws Exception { @Test(expected = CommitFailedException.class) public void testInvalidPrimaryType() throws Exception { Tree cug = TreeUtil.addChild(node, REP_CUG_POLICY, NodeTypeConstants.NT_OAK_UNSTRUCTURED); - cug.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME), Type.STRINGS); + cug.setProperty(REP_PRINCIPAL_NAMES, List.of(EveryonePrincipal.NAME), Type.STRINGS); try { root.commit(); @@ -152,7 +153,7 @@ public void testInvalidPrimaryType() throws Exception { @Test(expected = CommitFailedException.class) public void testMissingMixin() throws Exception { Tree cug = TreeUtil.addChild(node, REP_CUG_POLICY, NT_REP_CUG_POLICY); - cug.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME), Type.STRINGS); + cug.setProperty(REP_PRINCIPAL_NAMES, List.of(EveryonePrincipal.NAME), Type.STRINGS); try { root.commit(); @@ -167,9 +168,9 @@ public void testMissingMixin() throws Exception { @Test(expected = CommitFailedException.class) public void testRemoveMixin() throws Exception { - node.setProperty(JcrConstants.JCR_MIXINTYPES, ImmutableList.of(MIX_REP_CUG_MIXIN), Type.NAMES); + node.setProperty(JcrConstants.JCR_MIXINTYPES, List.of(MIX_REP_CUG_MIXIN), Type.NAMES); Tree cug = TreeUtil.addChild(node, REP_CUG_POLICY, NT_REP_CUG_POLICY); - cug.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME), Type.STRINGS); + cug.setProperty(REP_PRINCIPAL_NAMES, List.of(EveryonePrincipal.NAME), Type.STRINGS); root.commit(); try { @@ -186,9 +187,9 @@ public void testRemoveMixin() throws Exception { @Test(expected = CommitFailedException.class) public void testCugPolicyWithDifferentName() throws Exception { - node.setProperty(JcrConstants.JCR_MIXINTYPES, ImmutableList.of(MIX_REP_CUG_MIXIN), Type.NAMES); + node.setProperty(JcrConstants.JCR_MIXINTYPES, List.of(MIX_REP_CUG_MIXIN), Type.NAMES); Tree cug = TreeUtil.addChild(node, "anotherName", NT_REP_CUG_POLICY); - cug.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME), Type.STRINGS); + cug.setProperty(REP_PRINCIPAL_NAMES, List.of(EveryonePrincipal.NAME), Type.STRINGS); try { root.commit(); } catch (CommitFailedException e) { @@ -228,7 +229,7 @@ protected Tree getTypes() { public void testJcrNodeTypesOutsideOfSystemIsValidated() throws Exception { Tree n = TreeUtil.addChild(node, JCR_NODE_TYPES, NT_OAK_UNSTRUCTURED); Tree cug = TreeUtil.addChild(n, REP_CUG_POLICY, NT_REP_CUG_POLICY); - cug.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME), Type.STRINGS); + cug.setProperty(REP_PRINCIPAL_NAMES, List.of(EveryonePrincipal.NAME), Type.STRINGS); try { root.commit(); diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NestedCugHookTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NestedCugHookTest.java index 462fef159ea..e5a8fef4bb0 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NestedCugHookTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NestedCugHookTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.cug.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; @@ -36,6 +35,7 @@ import javax.jcr.security.AccessControlManager; import javax.jcr.security.AccessControlPolicy; import java.util.Collections; +import java.util.List; import static org.apache.jackrabbit.oak.commons.PathUtils.ROOT_PATH; import static org.junit.Assert.assertEquals; @@ -421,7 +421,7 @@ public void testRemoveWithInvalidHiddenNestedCugEntry() throws Exception { // cannot be relativized during the reconnect-preparation NodeBuilder before = new MemoryNodeBuilder(getTreeProvider().asNodeState(adminSession.getLatestRoot().getTree(PathUtils.ROOT_PATH))); NodeBuilder cugNode = before.getChildNode("content").getChildNode("rep:cugPolicy"); - cugNode.setProperty(HIDDEN_NESTED_CUGS, ImmutableList.of("/nested/out/of/hierarchy", "/content/subtree"), Type.STRINGS); + cugNode.setProperty(HIDDEN_NESTED_CUGS, List.of("/nested/out/of/hierarchy", "/content/subtree"), Type.STRINGS); NestedCugHook nch = new NestedCugHook(); nch.processCommit(before.getNodeState(), after, new CommitInfo("sid", null)); @@ -442,7 +442,7 @@ public void testRemoveWithMissingHiddenNestedCugEntry() throws Exception { // for that very cug) NodeBuilder after = new MemoryNodeBuilder(getTreeProvider().asNodeState(root.getTree(PathUtils.ROOT_PATH))); NodeBuilder cugNode = after.getChildNode("content").getChildNode("rep:cugPolicy"); - cugNode.setProperty(HIDDEN_NESTED_CUGS, ImmutableList.of(), Type.STRINGS); + cugNode.setProperty(HIDDEN_NESTED_CUGS, List.of(), Type.STRINGS); NodeState before = getTreeProvider().asNodeState(adminSession.getLatestRoot().getTree(PathUtils.ROOT_PATH)); @@ -467,7 +467,7 @@ public void testRemoveWithMissingHiddenNestedCugEntry2() throws Exception { // the nested cug of the before-state (and thus cannot clean-up the hidden structure) NodeBuilder before = new MemoryNodeBuilder(getTreeProvider().asNodeState(adminSession.getLatestRoot().getTree(PathUtils.ROOT_PATH))); NodeBuilder cugNode = before.getChildNode("content").getChildNode("rep:cugPolicy"); - cugNode.setProperty(HIDDEN_NESTED_CUGS, ImmutableList.of(), Type.STRINGS); + cugNode.setProperty(HIDDEN_NESTED_CUGS, List.of(), Type.STRINGS); NestedCugHook nch = new NestedCugHook(); nch.processCommit(before.getNodeState(), after, new CommitInfo("sid", null)); @@ -510,7 +510,7 @@ public void testRemoveWithMissingHiddenNestedCugEntryAtRootNode() throws Excepti // the nested /content with the root node (and thus cannot clean-up the hidden structure, // which is already 'cleaned' for that very cug) NodeBuilder after = new MemoryNodeBuilder(getTreeProvider().asNodeState(root.getTree(PathUtils.ROOT_PATH))); - after.setProperty(HIDDEN_NESTED_CUGS, ImmutableList.of(), Type.STRINGS); + after.setProperty(HIDDEN_NESTED_CUGS, List.of(), Type.STRINGS); after.setProperty(HIDDEN_TOP_CUG_CNT, 0); NodeState before = getTreeProvider().asNodeState(adminSession.getLatestRoot().getTree(PathUtils.ROOT_PATH)); diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NoCugTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NoCugTest.java index c0f0ca07764..586aa8e5d31 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NoCugTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/NoCugTest.java @@ -21,7 +21,6 @@ import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.plugins.tree.TreeLocation; @@ -40,7 +39,7 @@ public class NoCugTest extends AbstractCugTest { - private static final List PATHS = ImmutableList.of(PathUtils.ROOT_PATH, SUPPORTED_PATH, SUPPORTED_PATH + "/subtree", SUPPORTED_PATH3, UNSUPPORTED_PATH, INVALID_PATH); + private static final List PATHS = List.of(PathUtils.ROOT_PATH, SUPPORTED_PATH, SUPPORTED_PATH + "/subtree", SUPPORTED_PATH3, UNSUPPORTED_PATH, INVALID_PATH); private CugPermissionProvider cugPermProvider; diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/SupportedPathsTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/SupportedPathsTest.java index 31ed92b7bf9..dad9f29bc67 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/SupportedPathsTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/SupportedPathsTest.java @@ -21,7 +21,6 @@ import java.util.Map; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -79,7 +78,7 @@ public void testMayContainCug() { public void testRootPath() { SupportedPaths supportedPaths = new SupportedPaths(Set.of("/")); - List paths = ImmutableList.of("/", "/content", "/jcr:system", "/testRoot", "/some/other/path", "/content/a", "/content/a/b"); + List paths = List.of("/", "/content", "/jcr:system", "/testRoot", "/some/other/path", "/content/a", "/content/a/b"); for (String path : paths) { assertTrue(path, supportedPaths.includes(path)); @@ -91,7 +90,7 @@ public void testRootPath() { public void testEmpty() { SupportedPaths supportedPaths = new SupportedPaths(Set.of()); - List paths = ImmutableList.of("/", "/content", "/jcr:system", "/testRoot", "/some/other/path", "/content/a", "/content/a/b"); + List paths = List.of("/", "/content", "/jcr:system", "/testRoot", "/some/other/path", "/content/a", "/content/a/b"); for (String path : paths) { assertFalse(path, supportedPaths.includes(path)); diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/TopLevelPathTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/TopLevelPathTest.java index d3f534d4efc..caf119c3f68 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/TopLevelPathTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/TopLevelPathTest.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PathUtils; @@ -39,7 +38,7 @@ public class TopLevelPathTest extends AbstractCugTest { - private static final List PATHS = ImmutableList.of(ROOT_PATH, SUPPORTED_PATH, SUPPORTED_PATH + "/subtree", SUPPORTED_PATH3, UNSUPPORTED_PATH, INVALID_PATH); + private static final List PATHS = List.of(ROOT_PATH, SUPPORTED_PATH, SUPPORTED_PATH + "/subtree", SUPPORTED_PATH3, UNSUPPORTED_PATH, INVALID_PATH); @Test public void testHasAnyNoCug() { diff --git a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/VersionTest.java b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/VersionTest.java index 5ae6789678b..0a90e552537 100644 --- a/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/VersionTest.java +++ b/oak-authorization-cug/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/VersionTest.java @@ -20,7 +20,6 @@ import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.ContentSession; @@ -76,12 +75,12 @@ public void before() throws Exception { // - /content2 : allow everyone, deny testGroup (isolated) setupCugsAndAcls(); - readAccess = ImmutableList.of( + readAccess = List.of( SUPPORTED_PATH, "/content/subtree", "/content/aa"); - noReadAccess = ImmutableList.of( + noReadAccess = List.of( UNSUPPORTED_PATH, /* no access */ "/content2", /* granted by cug only */ "/content/a", /* granted by ace, denied by cug */ diff --git a/oak-authorization-principalbased/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalBasedAuthorizationConfiguration.java b/oak-authorization-principalbased/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalBasedAuthorizationConfiguration.java index a9b24c3472b..ba05f846e9b 100644 --- a/oak-authorization-principalbased/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalBasedAuthorizationConfiguration.java +++ b/oak-authorization-principalbased/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalBasedAuthorizationConfiguration.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; @@ -164,7 +163,7 @@ public List getCommitHooks(@NotNull String workspaceName) @NotNull @Override public List getValidators(@NotNull String workspaceName, @NotNull Set principals, @NotNull MoveTracker moveTracker) { - return ImmutableList.of(new PrincipalPolicyValidatorProvider(new MgrProviderImpl(this), principals, workspaceName)); + return List.of(new PrincipalPolicyValidatorProvider(new MgrProviderImpl(this), principals, workspaceName)); } @NotNull diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/AccessControlManagerLimitedUserTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/AccessControlManagerLimitedUserTest.java index 642a6812ceb..ccb3d1977a1 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/AccessControlManagerLimitedUserTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/AccessControlManagerLimitedUserTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager; import org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy; @@ -47,7 +46,6 @@ import javax.jcr.security.Privilege; import java.security.Principal; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Set; @@ -561,7 +559,7 @@ public void testAddEntryTree() throws Exception { Tree policyTree = testRoot.getTree(getPolicyPath()); Tree entry = TreeUtil.addChild(policyTree, "entry", NT_REP_PRINCIPAL_ENTRY); entry.setProperty(REP_EFFECTIVE_PATH, TEST_OAK_PATH, Type.PATH); - entry.setProperty(Constants.REP_PRIVILEGES, ImmutableList.of(JCR_ADD_CHILD_NODES), Type.NAMES); + entry.setProperty(Constants.REP_PRIVILEGES, List.of(JCR_ADD_CHILD_NODES), Type.NAMES); testRoot.commit(); } catch (CommitFailedException e) { assertEquals(CommitFailedException.ACCESS, e.getType()); @@ -581,7 +579,7 @@ public void testAddEntryTreeModAcOnSystemPrincipal() throws Exception { Tree policyTree = testRoot.getTree(getPolicyPath()); Tree entry = TreeUtil.addChild(policyTree, "entry", NT_REP_PRINCIPAL_ENTRY); entry.setProperty(REP_EFFECTIVE_PATH, TEST_OAK_PATH, Type.PATH); - entry.setProperty(Constants.REP_PRIVILEGES, ImmutableList.of(JCR_ADD_CHILD_NODES), Type.NAMES); + entry.setProperty(Constants.REP_PRIVILEGES, List.of(JCR_ADD_CHILD_NODES), Type.NAMES); testRoot.commit(); } catch (CommitFailedException e) { assertEquals(CommitFailedException.ACCESS, e.getType()); @@ -612,7 +610,7 @@ public void testAddEntryTreeFullModAc() throws Exception { Tree policyTree = testRoot.getTree(getPolicyPath()); Tree entry = TreeUtil.addChild(policyTree, "entry", NT_REP_PRINCIPAL_ENTRY); entry.setProperty(REP_EFFECTIVE_PATH, TEST_OAK_PATH, Type.PATH); - entry.setProperty(Constants.REP_PRIVILEGES, ImmutableList.of(JCR_ADD_CHILD_NODES), Type.NAMES); + entry.setProperty(Constants.REP_PRIVILEGES, List.of(JCR_ADD_CHILD_NODES), Type.NAMES); testRoot.commit(); } diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/MockUtility.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/MockUtility.java index 6d87333b096..ad7e90f0e1b 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/MockUtility.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/MockUtility.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; @@ -36,6 +35,7 @@ import org.jetbrains.annotations.Nullable; import org.mockito.Mockito; +import java.util.Arrays; import java.util.Set; import static org.mockito.ArgumentMatchers.any; @@ -98,7 +98,7 @@ static PropertyState createPrimaryTypeProperty(@NotNull String ntName) { } static PropertyState createMixinTypesProperty(@NotNull String... mixinTypes) { - return PropertyStates.createProperty(JcrConstants.JCR_MIXINTYPES, ImmutableList.copyOf(mixinTypes), Type.NAMES); + return PropertyStates.createProperty(JcrConstants.JCR_MIXINTYPES, Arrays.asList(mixinTypes), Type.NAMES); } static FilterProvider mockFilterProvider(boolean canHandle) { diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PolicyValidatorTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PolicyValidatorTest.java index 2205f984f70..66b46e64e0a 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PolicyValidatorTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PolicyValidatorTest.java @@ -16,8 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; @@ -42,6 +40,7 @@ import javax.jcr.RepositoryException; import javax.jcr.Value; +import java.util.List; import java.util.Map; import java.util.Set; @@ -525,7 +524,7 @@ public void testAddEntryPrivilegeLookupThrowsRepositoryException() throws Except try { NodeState entry = mockNodeState(NT_REP_PRINCIPAL_ENTRY); when(entry.getProperty(REP_EFFECTIVE_PATH)).thenReturn(PropertyStates.createProperty(REP_EFFECTIVE_PATH,"/path", Type.PATH)); - when(entry.getNames(REP_PRIVILEGES)).thenReturn(ImmutableList.of("privName")); + when(entry.getNames(REP_PRIVILEGES)).thenReturn(List.of("privName")); v.childNodeChanged("entryName", entry, entry); fail("CommitFailedException type OAK code 13 expected."); @@ -554,7 +553,7 @@ public void testAddEntryMissingEffectivePath() throws Exception { try { NodeState entry = mockNodeState(NT_REP_PRINCIPAL_ENTRY); when(entry.getProperty(REP_EFFECTIVE_PATH)).thenReturn(null); - when(entry.getNames(REP_PRIVILEGES)).thenReturn(ImmutableList.of(JCR_READ)); + when(entry.getNames(REP_PRIVILEGES)).thenReturn(List.of(JCR_READ)); v.childNodeChanged("entryName", entry, entry); fail("CommitFailedException type CONSTRAINT code 21 expected."); diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalBasedAccessControlManagerTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalBasedAccessControlManagerTest.java index f00ce03e00f..4d5ce01c01f 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalBasedAccessControlManagerTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalBasedAccessControlManagerTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy; @@ -25,6 +24,7 @@ import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.tree.TreeUtil; import org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants; import org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration; @@ -556,7 +556,7 @@ public void testGetEffectivePrincipalsEmptyPaths() throws Exception { Iterator effective = acMgr.getEffectivePolicies(principals, new String[0]); AccessControlPolicy[] expected = acMgr.getEffectivePolicies(principals); - assertArrayEquals(expected, ImmutableList.copyOf(effective).toArray(new AccessControlPolicy[0])); + assertArrayEquals(expected, (CollectionUtils.toList(effective).toArray())); } @Test @@ -569,7 +569,7 @@ public void testGetEffectivePrincipalsReadablePaths() throws Exception { String[] paths = readablePaths.stream().map(oakPath -> namePathMapper.getJcrPath(oakPath)).distinct().toArray(String[]::new); assertEquals(3, paths.length); - List effective = ImmutableList.copyOf(acMgr.getEffectivePolicies(Collections.singleton(validPrincipal), paths)); + List effective = CollectionUtils.toList(acMgr.getEffectivePolicies(Collections.singleton(validPrincipal), paths)); assertEquals(1, effective.size()); assertEquals(ReadPolicy.INSTANCE, effective.get(0)); diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImplTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImplTest.java index f27ed5f5565..c8f5bd7bd91 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImplTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImplTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.authorization.PrincipalAccessControlList; import org.apache.jackrabbit.api.security.authorization.PrivilegeCollection; @@ -50,6 +49,7 @@ import javax.jcr.security.AccessControlException; import javax.jcr.security.Privilege; import java.security.Principal; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; @@ -140,7 +140,7 @@ private Tree createEntryTree(@NotNull String oakPath, @NotNull String... privile Tree t = mock(Tree.class); PropertyState path = PropertyStates.createProperty(REP_EFFECTIVE_PATH, oakPath); when(t.getProperty(REP_EFFECTIVE_PATH)).thenReturn(path); - PropertyState privs = PropertyStates.createProperty(REP_PRIVILEGES, ImmutableList.copyOf(privilegeNames), Type.NAMES); + PropertyState privs = PropertyStates.createProperty(REP_PRIVILEGES, Arrays.asList(privilegeNames), Type.NAMES); when(t.getProperty(REP_PRIVILEGES)).thenReturn(privs); Tree rTree = when(mock(Tree.class).getProperties()).thenReturn(Collections.emptySet()).getMock(); when(t.getChild(REP_RESTRICTIONS)).thenReturn(rTree); diff --git a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImporterTest.java b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImporterTest.java index b969900f80d..a6aabe51378 100644 --- a/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImporterTest.java +++ b/oak-authorization-principalbased/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/principalbased/impl/PrincipalPolicyImporterTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Maps; import org.apache.jackrabbit.api.security.user.User; @@ -53,6 +52,7 @@ import javax.jcr.security.AccessControlPolicy; import java.security.Principal; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -148,10 +148,10 @@ private List mockPropInfos(@NotNull Map restrictions, } private List mockPropInfos(@NotNull Map restrictions) throws RepositoryException { - List propInfos = new ArrayList(); + List propInfos = new ArrayList<>(); for (Map.Entry r : restrictions.entrySet()) { String jcrName = r.getKey(); - List vs = ImmutableList.copyOf(r.getValue()); + List vs = Arrays.asList(r.getValue()); PropInfo propInfo = mockPropInfo(jcrName); if (!vs.isEmpty()) { TextValue first = when(mock(TextValue.class).getString()).thenReturn(vs.get(0).getString()).getMock(); @@ -574,7 +574,7 @@ public void testStartChildInfoWrongPrivilegesPropertyType() throws Exception { // rep:privileges with wrong type PropInfo propInfo = mockPropInfo(getJcrName(REP_PRIVILEGES)); TextValue tx = when(mock(TextValue.class).getString()).thenReturn(getJcrName(JCR_READ)).getMock(); - List values = ImmutableList.of(tx); + List values = List.of(tx); when(propInfo.getTextValues()).thenReturn(values); when(propInfo.getType()).thenReturn(PropertyType.STRING); propInfos.add(propInfo); diff --git a/oak-benchmarks-lucene/src/main/java/org/apache/jackrabbit/oak/scalability/suites/ScalabilityNodeRelationshipSuite.java b/oak-benchmarks-lucene/src/main/java/org/apache/jackrabbit/oak/scalability/suites/ScalabilityNodeRelationshipSuite.java index fffc4450fbb..196d847b982 100644 --- a/oak-benchmarks-lucene/src/main/java/org/apache/jackrabbit/oak/scalability/suites/ScalabilityNodeRelationshipSuite.java +++ b/oak-benchmarks-lucene/src/main/java/org/apache/jackrabbit/oak/scalability/suites/ScalabilityNodeRelationshipSuite.java @@ -32,7 +32,6 @@ import javax.jcr.RepositoryException; import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.commons.math3.stat.descriptive.SynchronizedDescriptiveStatistics; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.user.Authorizable; @@ -104,7 +103,7 @@ public class ScalabilityNodeRelationshipSuite extends ScalabilityNodeSuite { protected static final List NODE_LEVELS = Splitter.on(",").trimResults() .omitEmptyStrings().splitToList(System.getProperty("nodeLevels", "10,5,2,1")); - protected static final List NODE_LEVELS_DEFAULT = ImmutableList.of("10","5","2","1"); + protected static final List NODE_LEVELS_DEFAULT = List.of("10","5","2","1"); private static final int NUM_USERS = (NODE_LEVELS.size() >= 1 ? Integer.parseInt(NODE_LEVELS.get(0)) : Integer.parseInt(NODE_LEVELS_DEFAULT.get(0))); diff --git a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentHasPermissionTest.java b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentHasPermissionTest.java index 35f744e5a85..5a0a28fcaa5 100644 --- a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentHasPermissionTest.java +++ b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentHasPermissionTest.java @@ -20,8 +20,6 @@ import javax.jcr.RepositoryException; import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - /** * Concurrently calls Session#hasPermission on the deep tree: * - the path argument a random path out of the deep tree @@ -29,7 +27,7 @@ */ public class ConcurrentHasPermissionTest extends ConcurrentReadDeepTreeTest { - private static final List ACTIONS = ImmutableList.of( + private static final List ACTIONS = List.of( Session.ACTION_READ, Session.ACTION_ADD_NODE, Session.ACTION_SET_PROPERTY, diff --git a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/FacetSearchTest.java b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/FacetSearchTest.java index d393c81cea2..34623b9e385 100644 --- a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/FacetSearchTest.java +++ b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/FacetSearchTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.benchmark; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; @@ -245,7 +244,7 @@ public void initialize(@NotNull NodeBuilder builder) { t.setProperty("jcr:primaryType", "nt:unstructured", NAME); NodeBuilder uuid = IndexUtils.createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "uuid", true, true, - ImmutableList.of("jcr:uuid"), null); + List.of("jcr:uuid"), null); uuid.setProperty("info", "Oak index for UUID lookup (direct lookup of nodes with the mixin 'mix:referenceable')."); diff --git a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/PropertyFullTextTest.java b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/PropertyFullTextTest.java index f599c3488b5..949dcbdc232 100644 --- a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/PropertyFullTextTest.java +++ b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/PropertyFullTextTest.java @@ -16,8 +16,6 @@ */ package org.apache.jackrabbit.oak.benchmark; - -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.benchmark.wikipedia.WikipediaImport; import org.apache.jackrabbit.oak.commons.PathUtils; @@ -36,11 +34,11 @@ import javax.jcr.query.RowIterator; import java.io.File; +import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; - import static java.util.Objects.requireNonNull; import static org.apache.jackrabbit.oak.api.Type.BOOLEAN; import static org.apache.jackrabbit.oak.api.Type.LONG; @@ -181,7 +179,7 @@ public void initialize(final @NotNull NodeBuilder builder) { t.setProperty("jcr:primaryType", "nt:unstructured", NAME); NodeBuilder uuid = IndexUtils.createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "uuid", true, true, - ImmutableList.of("jcr:uuid"), null); + List.of("jcr:uuid"), null); uuid.setProperty("info", "Oak index for UUID lookup (direct lookup of nodes with the mixin 'mix:referenceable')."); diff --git a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/SearchTest.java b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/SearchTest.java index b1c99ef7f51..6433f8177fb 100644 --- a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/SearchTest.java +++ b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/SearchTest.java @@ -40,7 +40,6 @@ import javax.jcr.query.QueryResult; import javax.jcr.query.RowIterator; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.commons.io.FileUtils; import org.apache.jackrabbit.oak.benchmark.wikipedia.WikipediaImport; import org.apache.jackrabbit.oak.plugins.index.IndexUtils; @@ -219,7 +218,7 @@ protected class UUIDInitializer implements RepositoryInitializer { public void initialize(@NotNull NodeBuilder builder) { NodeBuilder uuid = IndexUtils.createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "uuid", true, true, - ImmutableList.of("jcr:uuid"), null); + List.of("jcr:uuid"), null); uuid.setProperty("info", "Oak index for UUID lookup (direct lookup of nodes with the mixin 'mix:referenceable')."); diff --git a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/PrincipalNameResolutionTest.java b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/PrincipalNameResolutionTest.java index eafc72d5001..2d7e8bd9b9e 100644 --- a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/PrincipalNameResolutionTest.java +++ b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/PrincipalNameResolutionTest.java @@ -18,13 +18,14 @@ import javax.security.auth.login.Configuration; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; import org.apache.jackrabbit.oak.spi.security.authentication.ConfigurationUtil; import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef; import org.apache.jackrabbit.oak.spi.security.authentication.external.impl.jmx.SyncMBeanImpl; import org.apache.jackrabbit.oak.spi.security.authentication.external.impl.jmx.SynchronizationMBean; +import java.util.List; + /** * Benchmark for {@link SynchronizationMBean#syncExternalUsers(String[])} */ @@ -33,7 +34,7 @@ public class PrincipalNameResolutionTest extends AbstractExternalTest { private SynchronizationMBean bean; public PrincipalNameResolutionTest(int numberOfUsers, int membershipSize, long expTime, int roundtripDelay) { - super(numberOfUsers, membershipSize, expTime, true, ImmutableList.of(), roundtripDelay, 0L); + super(numberOfUsers, membershipSize, expTime, true, List.of(), roundtripDelay, 0L); } @Override diff --git a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/GetPrivilegeCollectionIncludeNamesTest.java b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/GetPrivilegeCollectionIncludeNamesTest.java index 3e9a4718988..aa91bcf6477 100644 --- a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/GetPrivilegeCollectionIncludeNamesTest.java +++ b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/GetPrivilegeCollectionIncludeNamesTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.benchmark.authorization; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import joptsimple.internal.Strings; import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager; import org.apache.jackrabbit.api.security.authorization.PrivilegeCollection; @@ -44,7 +43,7 @@ private enum EvaluationType { ACCESSCONTORL_MANAGER_HAS_PRIVILEGES } - private static final List ALL_PRIVILEGE_NAMES = ImmutableList.copyOf(PrivilegeBits.BUILT_IN.keySet()); + private static final List ALL_PRIVILEGE_NAMES = List.copyOf(PrivilegeBits.BUILT_IN.keySet()); private final EvaluationType evalType; @@ -73,7 +72,7 @@ private static EvaluationType getEvalType(@Nullable String type) { @Override void additionalOperations(@NotNull String path, @NotNull Session s, @NotNull AccessControlManager acMgr) { try { - List privNames = ImmutableList.of(getRandom(ALL_PRIVILEGE_NAMES), getRandom(ALL_PRIVILEGE_NAMES), getRandom(ALL_PRIVILEGE_NAMES), getRandom(ALL_PRIVILEGE_NAMES)); + List privNames = List.of(getRandom(ALL_PRIVILEGE_NAMES), getRandom(ALL_PRIVILEGE_NAMES), getRandom(ALL_PRIVILEGE_NAMES), getRandom(ALL_PRIVILEGE_NAMES)); String accessControlledPath = getAccessControlledPath(path); if (EvaluationType.ACCESSCONTORL_MANAGER_GET_PRIVILEGE_COLLECTION == evalType) { PrivilegeCollection pc = ((JackrabbitAccessControlManager) acMgr).getPrivilegeCollection(accessControlledPath); diff --git a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/principalbased/PermissionEvaluationTest.java b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/principalbased/PermissionEvaluationTest.java index f9b41678e38..e5731f83f29 100644 --- a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/principalbased/PermissionEvaluationTest.java +++ b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/principalbased/PermissionEvaluationTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.benchmark.authorization.principalbased; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.security.authorization.permission.Permissions; import org.jetbrains.annotations.NotNull; @@ -38,7 +37,7 @@ protected void randomRead(Session testSession, List allPaths, int cnt) t logout = true; } try { - List permissionNames = ImmutableList.copyOf(Permissions.PERMISSION_NAMES.values()); + List permissionNames = List.copyOf(Permissions.PERMISSION_NAMES.values()); int access = 0; int noAccess = 0; long start = System.currentTimeMillis(); diff --git a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/principalbased/PrinicipalBasedReadTest.java b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/principalbased/PrinicipalBasedReadTest.java index 4fa7ed37036..8587b579545 100644 --- a/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/principalbased/PrinicipalBasedReadTest.java +++ b/oak-benchmarks/src/main/java/org/apache/jackrabbit/oak/benchmark/authorization/principalbased/PrinicipalBasedReadTest.java @@ -16,8 +16,6 @@ */ package org.apache.jackrabbit.oak.benchmark.authorization.principalbased; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.JackrabbitSession; @@ -161,7 +159,8 @@ private static boolean addEntry(@NotNull JackrabbitAccessControlManager acMgr, @ } added = acl.addAccessControlEntry(principal, privileges); } else { - for (JackrabbitAccessControlPolicy policy : Iterables.concat(ImmutableList.copyOf(acMgr.getApplicablePolicies(principal)), ImmutableList.copyOf(acMgr.getPolicies(principal)))) { + for (JackrabbitAccessControlPolicy policy : Iterables.concat(Arrays.asList(acMgr.getApplicablePolicies(principal)), + Arrays.asList(acMgr.getPolicies(principal)))) { if (policy instanceof PrincipalAccessControlList) { acl = (PrincipalAccessControlList) policy; break; diff --git a/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3DataStoreUtils.java b/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3DataStoreUtils.java index 7b4a9afa1c2..b0e0c15fb44 100644 --- a/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3DataStoreUtils.java +++ b/oak-blob-cloud/src/test/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3DataStoreUtils.java @@ -41,7 +41,6 @@ import com.amazonaws.services.s3.transfer.TransferManager; import org.apache.jackrabbit.guava.common.base.Strings; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Maps; import org.apache.commons.io.IOUtils; import org.apache.jackrabbit.core.data.DataStore; @@ -66,7 +65,7 @@ public class S3DataStoreUtils extends DataStoreUtils { protected static Class S3 = S3DataStore.class; public static List getFixtures() { - return ImmutableList.of(S3.getName()); + return List.of(S3.getName()); } public static boolean isS3DataStore() { diff --git a/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/AbstractSharedCachingDataStore.java b/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/AbstractSharedCachingDataStore.java index fb1459068a4..5bb8a907cab 100644 --- a/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/AbstractSharedCachingDataStore.java +++ b/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/AbstractSharedCachingDataStore.java @@ -57,7 +57,6 @@ import org.slf4j.LoggerFactory; import org.apache.jackrabbit.guava.common.base.Stopwatch; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.guava.common.io.Closeables; import org.apache.jackrabbit.guava.common.util.concurrent.ListeningExecutorService; @@ -374,7 +373,7 @@ public boolean exists(final DataIdentifier identifier) { } public List getStats() { - return ImmutableList.of(cache.getCacheStats(), cache.getStagingCacheStats()); + return List.of(cache.getCacheStats(), cache.getStagingCacheStats()); } protected CompositeDataStoreCache getCache() { diff --git a/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/DataStoreCacheUpgradeUtils.java b/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/DataStoreCacheUpgradeUtils.java index 129365f493e..3c913b4c8d8 100644 --- a/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/DataStoreCacheUpgradeUtils.java +++ b/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/DataStoreCacheUpgradeUtils.java @@ -27,7 +27,6 @@ import java.util.List; import java.util.Map; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.io.serialization.ValidatingObjectInputStream; @@ -105,7 +104,7 @@ private static boolean notInExceptions(File file, List exceptions) { * @param path the root of the datastore */ public static void moveDownloadCache(final File path) { - final List exceptions = ImmutableList.of("tmp", UPLOAD_STAGING_DIR, DOWNLOAD_DIR); + final List exceptions = List.of("tmp", UPLOAD_STAGING_DIR, DOWNLOAD_DIR); File newDownloadDir = new File(path, DOWNLOAD_DIR); FileTreeTraverser.depthFirstPostOrder(path) diff --git a/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/MarkSweepGarbageCollector.java b/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/MarkSweepGarbageCollector.java index 50cd2943f18..7470f1ea4ac 100644 --- a/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/MarkSweepGarbageCollector.java +++ b/oak-blob-plugins/src/main/java/org/apache/jackrabbit/oak/plugins/blob/MarkSweepGarbageCollector.java @@ -54,7 +54,6 @@ import org.apache.jackrabbit.guava.common.base.Stopwatch; import org.apache.jackrabbit.guava.common.collect.FluentIterable; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableListMultimap; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.guava.common.collect.Lists; @@ -287,8 +286,7 @@ public List getStats() throws Exception { } if (references.containsKey(id)) { - ImmutableList refRecs = references.get(id); - for(DataRecord refRec : refRecs) { + for(DataRecord refRec : references.get(id)) { String uniqueSessionId = refRec.getIdentifier().toString() .substring(SharedStoreRecordType.REFERENCES.getType().length() + 1); diff --git a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/SharedDataStoreMarkSweepGarbageCollectorTest.java b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/SharedDataStoreMarkSweepGarbageCollectorTest.java index 1d577b893b2..e36a5695799 100644 --- a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/SharedDataStoreMarkSweepGarbageCollectorTest.java +++ b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/SharedDataStoreMarkSweepGarbageCollectorTest.java @@ -16,10 +16,8 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.blob; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.core.data.DataIdentifier; import org.apache.jackrabbit.core.data.DataRecord; import org.apache.jackrabbit.core.data.DataStoreException; @@ -79,7 +77,7 @@ public class SharedDataStoreMarkSweepGarbageCollectorTest { @Before public void setUp() throws IOException { when(whiteboard.track(CheckpointMBean.class)).thenReturn(tracker); - when(tracker.getServices()).thenReturn(ImmutableList.of(checkpointMBean)); + when(tracker.getServices()).thenReturn(List.of(checkpointMBean)); when(blobStore.getType()).thenReturn(SHARED); @@ -116,7 +114,7 @@ public void markAndSweepShouldFailIfNotAllRepositoriesHaveMarkedReferencesAvaila @Test public void markAndSweepShouldSucceedWhenAllRepositoriesAreAvailable() throws Exception { setupSharedDataRecords("REPO1", "REPO1"); - when(blobStore.getAllChunkIds(0L)).thenReturn(ImmutableList.of().iterator()); + when(blobStore.getAllChunkIds(0L)).thenReturn(List.of().iterator()); collector.markAndSweep(false, true); @@ -133,8 +131,8 @@ private void setupSharedDataRecords(final String refRepoId, final String repoRep DataRecord repoDataRecord = mock(DataRecord.class); when(repoDataRecord.getIdentifier()).thenReturn(new DataIdentifier("repository-" + repoRepoId)); - List refs = ImmutableList.of(refDataRecord); - List repos = ImmutableList.of(repoDataRecord); + List refs = List.of(refDataRecord); + List repos = List.of(repoDataRecord); when(blobStore.getAllMetadataRecords(SharedDataStoreUtils.SharedStoreRecordType.REFERENCES.getType())).thenReturn(refs); when(blobStore.getAllMetadataRecords(SharedDataStoreUtils.SharedStoreRecordType.REPOSITORY.getType())).thenReturn(repos); diff --git a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStoreTest.java b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStoreTest.java index a797063affa..028a88b6502 100644 --- a/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStoreTest.java +++ b/oak-blob-plugins/src/test/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStoreTest.java @@ -29,9 +29,7 @@ import java.util.Set; import java.util.UUID; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.jackrabbit.core.data.DataIdentifier; @@ -170,7 +168,7 @@ public void testGetAllChunks() throws Exception{ DataIdentifier d10 = new DataIdentifier("d-10"); DataIdentifier d20 = new DataIdentifier("d-20"); DataIdentifier d30 = new DataIdentifier("d-30"); - List dis = ImmutableList.of(d10, d20, d30); + List dis = List.of(d10, d20, d30); List recs = CollectionUtils.toList( Iterables.transform(dis, input -> new TimeDataRecord(input))); OakFileDataStore mockedDS = mock(OakFileDataStore.class); 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))); diff --git a/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/whiteboard/WhiteboardUtils.java b/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/whiteboard/WhiteboardUtils.java index 3b6eda2011b..74febd396b5 100644 --- a/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/whiteboard/WhiteboardUtils.java +++ b/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/whiteboard/WhiteboardUtils.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Map; import java.util.function.Predicate; +import java.util.stream.Collectors; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; @@ -30,9 +31,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; -import org.apache.jackrabbit.guava.common.collect.Iterables; - import static org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.ScheduleExecutionInstanceTypes.DEFAULT; import static org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.ScheduleExecutionInstanceTypes.RUN_ON_LEADER; import static org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.ScheduleExecutionInstanceTypes.RUN_ON_SINGLE; @@ -165,7 +163,7 @@ public static List getServices(@NotNull Whiteboard wb, @NotNull Class if (predicate == null) { return tracker.getServices(); } else { - return ImmutableList.copyOf(Iterables.filter(tracker.getServices(), (input) -> predicate.test(input))); + return tracker.getServices().stream().filter(predicate).collect(Collectors.toUnmodifiableList()); } } finally { tracker.stop(); diff --git a/oak-core-spi/src/test/java/org/apache/jackrabbit/oak/spi/mount/MountInfoTest.java b/oak-core-spi/src/test/java/org/apache/jackrabbit/oak/spi/mount/MountInfoTest.java index d8763fc186a..33817431de3 100644 --- a/oak-core-spi/src/test/java/org/apache/jackrabbit/oak/spi/mount/MountInfoTest.java +++ b/oak-core-spi/src/test/java/org/apache/jackrabbit/oak/spi/mount/MountInfoTest.java @@ -16,10 +16,8 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.spi.mount; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -27,12 +25,13 @@ import org.junit.Test; import java.util.Collections; +import java.util.List; public class MountInfoTest { @Test public void testIsMounted() throws Exception{ - MountInfo md = new MountInfo("foo", false, of("/x/y"), of("/a", "/b")); + MountInfo md = new MountInfo("foo", false, List.of("/x/y"), List.of("/a", "/b")); assertTrue(md.isMounted("/a")); assertTrue(md.isMounted("/b")); assertTrue(md.isMounted("/b/c/d")); @@ -45,7 +44,7 @@ public void testIsMounted() throws Exception{ @Test public void testIsUnder() { - MountInfo md = new MountInfo("foo", false, Collections.emptyList(), of("/apps", "/etc/config", "/content/my/site", "/var")); + MountInfo md = new MountInfo("foo", false, Collections.emptyList(), List.of("/apps", "/etc/config", "/content/my/site", "/var")); assertTrue(md.isUnder("/etc")); assertTrue(md.isUnder("/content")); assertTrue(md.isUnder("/content/my")); @@ -56,7 +55,7 @@ public void testIsUnder() { @Test public void testIsDirectlyUnder() { - MountInfo md = new MountInfo("foo", false, Collections.emptyList(), of("/apps", "/etc/my/config", "/var")); + MountInfo md = new MountInfo("foo", false, Collections.emptyList(), List.of("/apps", "/etc/my/config", "/var")); assertFalse(md.isDirectlyUnder("/etc")); assertTrue(md.isDirectlyUnder("/etc/my")); assertFalse(md.isDirectlyUnder("/etc/my/config")); @@ -65,7 +64,7 @@ public void testIsDirectlyUnder() { @Test public void testSupportFragment() { - MountInfo md = new MountInfo("foo", false, of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList()); + MountInfo md = new MountInfo("foo", false, List.of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList()); assertFalse(md.isSupportFragment("/")); assertTrue(md.isSupportFragment("/apps")); @@ -86,7 +85,7 @@ public void testSupportFragment() { @Test public void testSupportFragmentUnder() { - MountInfo md = new MountInfo("foo", false, of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList()); + MountInfo md = new MountInfo("foo", false, List.of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList()); assertTrue(md.isSupportFragmentUnder("/")); assertTrue(md.isSupportFragmentUnder("/apps")); @@ -107,7 +106,7 @@ public void testSupportFragmentUnder() { @Test public void testIsMountedWithFragments() { - MountInfo md = new MountInfo("foo", false, of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList()); + MountInfo md = new MountInfo("foo", false, List.of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList()); assertFalse(md.isMounted("/oak:mount-foo")); assertTrue(md.isMounted("/apps/oak:mount-foo")); diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/InitialContent.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/InitialContent.java index 8dca28e2246..820affc82b4 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/InitialContent.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/InitialContent.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.io.InputStream; +import java.util.List; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; @@ -45,8 +46,6 @@ import org.apache.jackrabbit.oak.spi.version.VersionConstants; import org.jetbrains.annotations.NotNull; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - /** * {@code InitialContent} implements a {@link RepositoryInitializer} the creates * the initial JCR/Oak repository structure. This includes creating @@ -96,11 +95,11 @@ public void initialize(@NotNull NodeBuilder builder) { NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder); NodeBuilder uuid = IndexUtils.createIndexDefinition(index, "uuid", true, true, - ImmutableList.of(JCR_UUID), null); + List.of(JCR_UUID), null); uuid.setProperty("info", "Oak index for UUID lookup (direct lookup of nodes with the mixin 'mix:referenceable')."); NodeBuilder nodetype = IndexUtils.createIndexDefinition(index, "nodetype", true, false, - ImmutableList.of(JCR_PRIMARYTYPE, JCR_MIXINTYPES), null); + List.of(JCR_PRIMARYTYPE, JCR_MIXINTYPES), null); nodetype.setProperty("info", "Oak index for queries with node type, and possibly path restrictions, " + "for example \"/jcr:root/content//element(*, mix:language)\"."); diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java index d21f4ad74d0..2b03bfcc712 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java @@ -48,7 +48,6 @@ import javax.management.StandardMBean; import javax.security.auth.login.LoginException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.io.Closer; @@ -1037,20 +1036,20 @@ public static class OakDefaultComponents { @Deprecated public static final OakDefaultComponents INSTANCE = new OakDefaultComponents(); - private final Iterable commitHooks = ImmutableList.of(new VersionHook()); + private final Iterable commitHooks = List.of(new VersionHook()); - private final Iterable repositoryInitializers = ImmutableList + private final Iterable repositoryInitializers = List .of(new InitialContent()); - private final Iterable editorProviders = ImmutableList.of( + private final Iterable editorProviders = List.of( new ItemSaveValidatorProvider(), new NameValidatorProvider(), new NamespaceEditorProvider(), new TypeEditorProvider(), new ConflictValidatorProvider(), new ChangeCollectorProvider()); - private final Iterable indexEditorProviders = ImmutableList.of( + private final Iterable indexEditorProviders = List.of( new ReferenceEditorProvider(), new PropertyIndexEditorProvider(), new NodeCounterEditorProvider(), new OrderedPropertyIndexEditorProvider()); - private final Iterable queryIndexProviders = ImmutableList + private final Iterable queryIndexProviders = List .of(new ReferenceIndexProvider(), new PropertyIndexProvider(), new NodeTypeIndexProvider()); private final SecurityProvider securityProvider = SecurityProviderBuilder.newBuilder().build(); diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/impl/CacheStatsMetrics.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/impl/CacheStatsMetrics.java index d8a7e61eada..f301b5e6152 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/impl/CacheStatsMetrics.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/cache/impl/CacheStatsMetrics.java @@ -25,7 +25,6 @@ import com.codahale.metrics.Counter; import com.codahale.metrics.Metric; import com.codahale.metrics.MetricRegistry; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.jmx.CacheStatsMBean; import org.osgi.service.component.annotations.Component; @@ -51,7 +50,7 @@ public class CacheStatsMetrics { static final String ELEMENT = "element"; static final String LOAD_TIME = "loadTime"; - private static final List TYPES = ImmutableList.of( + private static final List TYPES = List.of( REQUEST, HIT, MISS, EVICTION, ELEMENT, LOAD_TIME); private Map cacheStatsMBeans = new HashMap<>(); diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/JcrConflictHandler.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/JcrConflictHandler.java index 957f68950a4..093298db46d 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/JcrConflictHandler.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/JcrConflictHandler.java @@ -21,7 +21,8 @@ import org.apache.jackrabbit.oak.spi.commit.CompositeConflictHandler; import org.apache.jackrabbit.oak.spi.commit.ConflictHandlers; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import java.util.List; + /** * Utility class providing conflict handlers used for JCR. @@ -34,7 +35,7 @@ public final class JcrConflictHandler { * and {@link AnnotatingConflictHandler}. */ public static CompositeConflictHandler createJcrConflictHandler() { - return new CompositeConflictHandler(ImmutableList.of( + return new CompositeConflictHandler(List.of( new JcrLastModifiedConflictHandler(), ConflictHandlers.wrap(new ChildOrderConflictHandler()), new AnnotatingConflictHandler())); diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/CompositeIndexEditorProvider.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/CompositeIndexEditorProvider.java index aa2f2b4c50c..a9c59e8c727 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/CompositeIndexEditorProvider.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/CompositeIndexEditorProvider.java @@ -28,8 +28,6 @@ import org.apache.jackrabbit.oak.spi.state.NodeState; import org.jetbrains.annotations.NotNull; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - /** * Aggregation of a list of editor providers into a single provider. */ @@ -50,7 +48,7 @@ public Editor getIndexEditor( return providers.iterator().next(); } else { return new CompositeIndexEditorProvider( - ImmutableList.copyOf(providers)); + List.copyOf(providers)); } } diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java index a35ee9fe420..da50feafbde 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexUtils.java @@ -30,8 +30,10 @@ import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_PROPERTY_NAME; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.UNIQUE_PROPERTY_NAME; +import java.util.Arrays; import java.util.Collection; import java.util.Comparator; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.LinkedHashMap; @@ -42,7 +44,6 @@ import javax.jcr.RepositoryException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; @@ -131,7 +132,7 @@ public static Tree createIndexDefinition(@NotNull Tree indexNode, @NotNull String[] propertyNames, @NotNull String... declaringNodeTypeNames) throws RepositoryException { - return createIndexDefinition(indexNode, indexDefName, unique, ImmutableList.copyOf(propertyNames), ImmutableList.copyOf(declaringNodeTypeNames), PropertyIndexEditorProvider.TYPE, null); + return createIndexDefinition(indexNode, indexDefName, unique, Arrays.asList(propertyNames), Arrays.asList(declaringNodeTypeNames), PropertyIndexEditorProvider.TYPE, null); } /** diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/inventory/IndexPrinter.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/inventory/IndexPrinter.java index 2ccabd43af2..e27ad0f715c 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/inventory/IndexPrinter.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/inventory/IndexPrinter.java @@ -28,11 +28,11 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.felix.inventory.Format; import org.apache.felix.inventory.InventoryPrinter; import org.apache.jackrabbit.oak.api.jmx.IndexStatsMBean; import org.apache.jackrabbit.oak.commons.IOUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.commons.json.JsopBuilder; import org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfo; import org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService; @@ -76,7 +76,7 @@ public void print(PrintWriter pw, Format format, boolean isZip) { } private void asyncLanesInfo(PrinterOutput po) { - List asyncLanes = ImmutableList.copyOf(asyncIndexInfoService.getAsyncLanes()); + List asyncLanes = CollectionUtils.toList(asyncIndexInfoService.getAsyncLanes()); po.startSection("Async Indexers State", true); po.text("Number of async indexer lanes", asyncLanes.size()); diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexProvider.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexProvider.java index d4e714ef1a3..6c33bda9cf3 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexProvider.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexProvider.java @@ -27,7 +27,6 @@ import org.apache.jackrabbit.oak.spi.state.NodeState; import org.jetbrains.annotations.NotNull; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; @@ -45,7 +44,7 @@ public class NodeTypeIndexProvider implements QueryIndexProvider { @NotNull @Override public List getQueryIndexes(NodeState nodeState) { - return ImmutableList.of(new NodeTypeIndex(mountInfoProvider)); + return List.of(new NodeTypeIndex(mountInfoProvider)); } public NodeTypeIndexProvider with(MountInfoProvider mountInfoProvider) { diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexProvider.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexProvider.java index dd17f395764..81b0e69bcba 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexProvider.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexProvider.java @@ -25,7 +25,6 @@ import org.apache.jackrabbit.oak.spi.state.NodeState; import org.jetbrains.annotations.NotNull; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; @@ -45,7 +44,7 @@ public class PropertyIndexProvider implements QueryIndexProvider { @Override @NotNull public List getQueryIndexes(NodeState state) { - return ImmutableList.of(new PropertyIndex(mountInfoProvider)); + return List.of(new PropertyIndex(mountInfoProvider)); } public PropertyIndexProvider with(MountInfoProvider mountInfoProvider) { diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/reference/ReferenceIndexProvider.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/reference/ReferenceIndexProvider.java index 8ba8db6b629..1a941baa6ec 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/reference/ReferenceIndexProvider.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/reference/ReferenceIndexProvider.java @@ -25,7 +25,6 @@ import org.apache.jackrabbit.oak.spi.state.NodeState; import org.jetbrains.annotations.NotNull; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; @@ -41,7 +40,7 @@ public class ReferenceIndexProvider implements QueryIndexProvider { @Override @NotNull public List getQueryIndexes(NodeState state) { - return ImmutableList. of(new ReferenceIndex(mountInfoProvider)); + return List.of(new ReferenceIndex(mountInfoProvider)); } public ReferenceIndexProvider with(MountInfoProvider mountInfoProvider) { diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/filter/FilterBuilder.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/filter/FilterBuilder.java index a0ce27d2fcf..229f34c8638 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/filter/FilterBuilder.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/filter/FilterBuilder.java @@ -39,7 +39,6 @@ import java.util.function.Predicate; import java.util.regex.Pattern; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate; @@ -127,7 +126,7 @@ public FilterBuilder addPathsForMBean(@NotNull Set paths) { */ @NotNull private Iterable getSubTrees() { - return subTrees.isEmpty() ? ImmutableList.of("/") : subTrees; + return subTrees.isEmpty() ? List.of("/") : subTrees; } public FilterBuilder aggregator(EventAggregator aggregator) { diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java index 0e3766cf2a7..f40dcddd71a 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java @@ -27,7 +27,6 @@ import java.util.Set; import javax.jcr.RepositoryException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; @@ -436,7 +435,7 @@ private void createVersion(@NotNull NodeBuilder vHistory, Validate.checkState(versionable.hasProperty(JCR_PREDECESSORS)); PropertyState state = versionable.getProperty(JCR_PREDECESSORS); - List predecessors = ImmutableList.copyOf(state.getValue(Type.REFERENCES)); + List predecessors = CollectionUtils.toList(state.getValue(Type.REFERENCES)); NodeBuilder version = vHistory.child(calculateVersion(vHistory, versionable)); String versionUUID = UUIDUtils.generateUUID(); diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/UnionQueryImpl.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/UnionQueryImpl.java index 5e500a9b36e..cc18e911e59 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/UnionQueryImpl.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/UnionQueryImpl.java @@ -40,7 +40,6 @@ import org.slf4j.LoggerFactory; import org.apache.jackrabbit.guava.common.collect.AbstractIterator; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.guava.common.collect.PeekingIterator; @@ -329,7 +328,7 @@ public Iterator getRows() { } else { // This would suggest either the sub queries are sorted by index or explicitly by QueryImpl (in case of traversing index) // So use mergeSorted here. - it = Iterators.mergeSorted(ImmutableList.of(leftIter, rightIter), orderBy); + it = Iterators.mergeSorted(List.of(leftIter, rightIter), orderBy); } it = FilterIterators.newCombinedFilter(it, distinct, limit.orElse(Long.MAX_VALUE), offset.orElse(0L), null, settings); diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenConfigurationImpl.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenConfigurationImpl.java index 77ffd3eeb18..0db3e94a5ea 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenConfigurationImpl.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenConfigurationImpl.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authentication.token; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.spi.commit.MoveTracker; @@ -146,7 +145,7 @@ public String getName() { @Override public List getValidators(@NotNull String workspaceName, @NotNull Set principals, @NotNull MoveTracker moveTracker) { ValidatorProvider vp = new TokenValidatorProvider(getSecurityProvider().getParameters(UserConfiguration.NAME), getTreeProvider()); - return ImmutableList.of(vp); + return List.of(vp); } @Override diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationConfigurationImpl.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationConfigurationImpl.java index 1be607345b9..f500dd21d9f 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationConfigurationImpl.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationConfigurationImpl.java @@ -23,7 +23,6 @@ import java.util.Set; import javax.jcr.security.AccessControlManager; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.namepath.NamePathMapper; import org.apache.jackrabbit.oak.security.authorization.monitor.AuthorizationMonitor; @@ -159,7 +158,7 @@ public WorkspaceInitializer getWorkspaceInitializer() { @NotNull @Override public List getCommitHooks(@NotNull String workspaceName) { - return ImmutableList.of( + return List.of( new VersionablePathHook(workspaceName, this), new PermissionHook(workspaceName, getRestrictionProvider(), this)); } @@ -167,7 +166,7 @@ public List getCommitHooks(@NotNull String workspaceName) @NotNull @Override public List getValidators(@NotNull String workspaceName, @NotNull Set principals, @NotNull MoveTracker moveTracker) { - return ImmutableList.of( + return List.of( new PermissionStoreValidatorProvider(), new PermissionValidatorProvider(workspaceName, principals, moveTracker, this), new AccessControlValidatorProvider(this)); @@ -176,7 +175,7 @@ public List getValidators(@NotNull String workspaceName, @Not @NotNull @Override public List getProtectedItemImporters() { - return ImmutableList.of(new AccessControlImporter()); + return List.of(new AccessControlImporter()); } @NotNull diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationInitializer.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationInitializer.java index 834e182c32e..c1bde4d1d4b 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationInitializer.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationInitializer.java @@ -16,7 +16,8 @@ */ package org.apache.jackrabbit.oak.security.authorization; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import java.util.List; + import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.index.IndexUtils; @@ -56,8 +57,8 @@ public void initialize(NodeBuilder builder, String workspaceName) { NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder); if (!index.hasChildNode("acPrincipalName")) { NodeBuilder acPrincipalName = IndexUtils.createIndexDefinition(index, "acPrincipalName", true, false, - ImmutableList.of(REP_PRINCIPAL_NAME), - ImmutableList.of(NT_REP_DENY_ACE, NT_REP_GRANT_ACE, NT_REP_ACE)); + List.of(REP_PRINCIPAL_NAME), + List.of(NT_REP_DENY_ACE, NT_REP_GRANT_ACE, NT_REP_ACE)); acPrincipalName.setProperty("info", "Oak index used by authorization to quickly search a principal by name."); } diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeAccessControlManager.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeAccessControlManager.java index 0c68a5e0477..023f3f18437 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeAccessControlManager.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeAccessControlManager.java @@ -18,6 +18,7 @@ import java.security.Principal; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -30,7 +31,6 @@ import javax.jcr.security.AccessControlPolicyIterator; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager; @@ -81,24 +81,23 @@ public Privilege[] getSupportedPrivileges(String absPath) throws RepositoryExcep @Override public AccessControlPolicy[] getPolicies(String absPath) throws RepositoryException { - ImmutableList.Builder policies = ImmutableList.builder(); + List policies = new ArrayList<>(); for (AccessControlManager acMgr : acMgrs) { - policies.add(acMgr.getPolicies(absPath)); + policies.addAll(Arrays.asList(acMgr.getPolicies(absPath))); } - List l = policies.build(); - return l.toArray(new AccessControlPolicy[0]); + return policies.toArray(new AccessControlPolicy[0]); } @Override public AccessControlPolicy[] getEffectivePolicies(String absPath) throws RepositoryException { - ImmutableList.Builder policies = ImmutableList.builder(); + List policies = new ArrayList<>(); for (AccessControlManager acMgr : acMgrs) { - policies.add(acMgr.getEffectivePolicies(absPath)); + policies.addAll(Arrays.asList(acMgr.getEffectivePolicies(absPath))); if (aggregationFilter.stop(acMgr, absPath)) { break; } } - return policies.build().stream().distinct().toArray(AccessControlPolicy[]::new); + return policies.stream().distinct().toArray(AccessControlPolicy[]::new); } @Override @@ -138,49 +137,46 @@ public void removePolicy(String absPath, AccessControlPolicy policy) throws Repo @NotNull @Override public JackrabbitAccessControlPolicy[] getApplicablePolicies(@NotNull Principal principal) throws RepositoryException { - ImmutableList.Builder policies = ImmutableList.builder(); + List policies = new ArrayList<>(); for (AccessControlManager acMgr : acMgrs) { if (acMgr instanceof JackrabbitAccessControlManager && acMgr instanceof PolicyOwner) { - policies.add(((JackrabbitAccessControlManager) acMgr).getApplicablePolicies(principal)); + policies.addAll(Arrays.asList(((JackrabbitAccessControlManager) acMgr).getApplicablePolicies(principal))); } } - List l = policies.build(); - return l.toArray(new JackrabbitAccessControlPolicy[0]); + return policies.toArray(new JackrabbitAccessControlPolicy[0]); } @NotNull @Override public JackrabbitAccessControlPolicy[] getPolicies(@NotNull Principal principal) throws RepositoryException { - ImmutableList.Builder policies = ImmutableList.builder(); + List policies = new ArrayList<>(); for (AccessControlManager acMgr : acMgrs) { if (acMgr instanceof JackrabbitAccessControlManager) { - policies.add(((JackrabbitAccessControlManager) acMgr).getPolicies(principal)); + policies.addAll(Arrays.asList(((JackrabbitAccessControlManager) acMgr).getPolicies(principal))); } } - List l = policies.build(); - return l.toArray(new JackrabbitAccessControlPolicy[0]); + return policies.toArray(new JackrabbitAccessControlPolicy[0]); } @NotNull @Override public AccessControlPolicy[] getEffectivePolicies(@NotNull Set principals) throws RepositoryException { - ImmutableList.Builder policies = ImmutableList.builder(); + List policies = new ArrayList<>(); for (AccessControlManager acMgr : acMgrs) { if (acMgr instanceof JackrabbitAccessControlManager) { JackrabbitAccessControlManager jAcMgr = (JackrabbitAccessControlManager) acMgr; - policies.add(jAcMgr.getEffectivePolicies(principals)); + policies.addAll(Arrays.asList(jAcMgr.getEffectivePolicies(principals))); if (aggregationFilter.stop(jAcMgr, principals)) { break; } } } - List l = policies.build(); - return l.toArray(new AccessControlPolicy[0]); + return policies.toArray(new AccessControlPolicy[0]); } @Override public @NotNull Iterator getEffectivePolicies(@NotNull Set principals, @Nullable String... absPaths) throws AccessDeniedException, AccessControlException, UnsupportedRepositoryOperationException, RepositoryException { - ImmutableList.Builder> iterators = ImmutableList.builder(); + List> iterators = new ArrayList<>(); for (AccessControlManager acMgr : acMgrs) { if (acMgr instanceof JackrabbitAccessControlManager) { JackrabbitAccessControlManager jAcMgr = (JackrabbitAccessControlManager) acMgr; @@ -190,6 +186,6 @@ public AccessControlPolicy[] getEffectivePolicies(@NotNull Set princi } } } - return Iterators.concat(iterators.build().toArray(new Iterator[0])); + return Iterators.concat(iterators.toArray(new Iterator[0])); } } diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserConfigurationImpl.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserConfigurationImpl.java index b01b11d45f3..35cdf2c5e08 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserConfigurationImpl.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserConfigurationImpl.java @@ -23,7 +23,6 @@ import java.util.Map; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.user.UserManager; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.blob.BlobAccessProvider; @@ -274,13 +273,13 @@ public WorkspaceInitializer getWorkspaceInitializer() { @NotNull @Override public List getValidators(@NotNull String workspaceName, @NotNull Set principals, @NotNull MoveTracker moveTracker) { - return ImmutableList.of(new UserValidatorProvider(getParameters(), getRootProvider(), getTreeProvider()), new CacheValidatorProvider(principals, getTreeProvider())); + return List.of(new UserValidatorProvider(getParameters(), getRootProvider(), getTreeProvider()), new CacheValidatorProvider(principals, getTreeProvider())); } @NotNull @Override public List getConflictHandlers() { - return ImmutableList.of(new RepMembersConflictHandler(), new CacheConflictHandler()); + return List.of(new RepMembersConflictHandler(), new CacheConflictHandler()); } @NotNull diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/core/SecureNodeBuilderTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/core/SecureNodeBuilderTest.java index 3eb02946fe9..76b232d885a 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/core/SecureNodeBuilderTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/core/SecureNodeBuilderTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.core; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.LazyValue; @@ -31,6 +30,8 @@ import org.junit.Before; import org.junit.Test; +import java.util.List; + import static org.apache.jackrabbit.oak.core.TestPermissionProvider.NAME_ACCESSIBLE; import static org.apache.jackrabbit.oak.core.TestPermissionProvider.NAME_NON_ACCESSIBLE; import static org.apache.jackrabbit.oak.core.TestPermissionProvider.NAME_NON_EXISTING; @@ -266,7 +267,7 @@ public void testGetPropertiesCanReadProperties() { @Test public void testGetPropertiesAfterSet() { - secureNodeBuilder.setProperty(PropertyStates.createProperty("another", ImmutableList.of("v", "v2"), Type.STRINGS)); + secureNodeBuilder.setProperty(PropertyStates.createProperty("another", List.of("v", "v2"), Type.STRINGS)); assertEquals(2, Iterables.size(secureNodeBuilder.getProperties())); } @@ -291,7 +292,7 @@ public void testGetBooleanTypeBoolean() { @Test public void testGetBooleanTypeBooleans() { - secureNodeBuilder.setProperty("booleans", ImmutableList.of(true, false), Type.BOOLEANS); + secureNodeBuilder.setProperty("booleans", List.of(true, false), Type.BOOLEANS); assertFalse(secureNodeBuilder.getBoolean("booleans")); } @@ -304,7 +305,7 @@ public void testGetString() { @Test public void testGetStringTypeStrings() { - secureNodeBuilder.setProperty("strings", ImmutableList.of("a", "b"), Type.STRINGS); + secureNodeBuilder.setProperty("strings", List.of("a", "b"), Type.STRINGS); assertNull(secureNodeBuilder.getString("strings")); } @@ -323,7 +324,7 @@ public void testGetName() { @Test public void testGetNameTypeNames() { - secureNodeBuilder.setProperty("names", ImmutableList.of("a", "b"), Type.NAMES); + secureNodeBuilder.setProperty("names", List.of("a", "b"), Type.NAMES); assertNull(secureNodeBuilder.getName("names")); } @@ -342,7 +343,7 @@ public void testGetNames() { @Test public void testGetNamesTypeNames() { - Iterable names = ImmutableList.of("a", "b"); + Iterable names = List.of("a", "b"); secureNodeBuilder.setProperty("names", names, Type.NAMES); assertTrue(Iterables.elementsEqual(names, secureNodeBuilder.getNames("names"))); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/atomic/AtomicCounterEditorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/atomic/AtomicCounterEditorTest.java index a68a3d08474..0c4f1df13f5 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/atomic/AtomicCounterEditorTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/atomic/AtomicCounterEditorTest.java @@ -17,7 +17,7 @@ package org.apache.jackrabbit.oak.plugins.atomic; import static java.util.Objects.requireNonNull; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; + import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES; import static org.apache.jackrabbit.oak.api.Type.LONG; import static org.apache.jackrabbit.oak.api.Type.NAMES; @@ -213,7 +213,7 @@ private static void assertTotalCountersValue(@NotNull final Iterableof(v)); + async.setValidatorProviders(List.of(v)); async.run(); assertFalse(v.visitedPaths.isEmpty()); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java index cb2e87faaf8..30931b342c0 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java @@ -44,12 +44,12 @@ import java.util.Calendar; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import ch.qos.logback.classic.Level; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; @@ -554,15 +554,15 @@ public void testMissingProviderWithAsyncDef() throws Exception { // create async defs with nrt and sync mixed in createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "asyncIndex", true, false, Set.of("foo"), null) - .setProperty(ASYNC_PROPERTY_NAME, ImmutableList.of("async-run"), Type.STRINGS) + .setProperty(ASYNC_PROPERTY_NAME, List.of("async-run"), Type.STRINGS) .setProperty(REINDEX_PROPERTY_NAME, false); createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "nrtIndex", true, false, Set.of("foo"), null) - .setProperty(ASYNC_PROPERTY_NAME, ImmutableList.of("async-run", "nrt"), Type.STRINGS) + .setProperty(ASYNC_PROPERTY_NAME, List.of("async-run", "nrt"), Type.STRINGS) .setProperty(REINDEX_PROPERTY_NAME, false); createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "asyncSyncIndex", true, false, Set.of("foo"), null) - .setProperty(ASYNC_PROPERTY_NAME, ImmutableList.of("async-run", "sync"), Type.STRINGS) + .setProperty(ASYNC_PROPERTY_NAME, List.of("async-run", "sync"), Type.STRINGS) .setProperty(REINDEX_PROPERTY_NAME, false); // node states to run hook on diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexDefinitionUpdaterTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexDefinitionUpdaterTest.java index 2ace0da3ade..dac5aa14990 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexDefinitionUpdaterTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexDefinitionUpdaterTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.importer; import java.io.File; @@ -27,12 +26,12 @@ import java.util.List; import java.util.Map; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.felix.inventory.Format; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.index.inventory.IndexDefinitionPrinter; import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore; import org.apache.jackrabbit.oak.plugins.tree.factories.TreeFactory; @@ -144,7 +143,7 @@ public void newIndexAndOrderableChildren() throws Exception{ NodeBuilder idxBuilder = updater.apply(builder, "/oak:index/barIndex"); PropertyState childOrder = builder.getChildNode("oak:index").getProperty(":childOrder"); - List names = ImmutableList.copyOf(childOrder.getValue(Type.NAMES)); + List names = CollectionUtils.toList(childOrder.getValue(Type.NAMES)); assertEquals(asList("fooIndex", "barIndex"), names); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexQueryTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexQueryTest.java index b641d3bb322..750c36ae2f3 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexQueryTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexQueryTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.plugins.index.nodetype; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.createIndexDefinition; @@ -62,7 +61,7 @@ private static Tree child(Tree t, String n, String type) { private static void mixLanguage(Tree t, String n) { Tree c = t.addChild(n); c.setProperty(JCR_PRIMARYTYPE, "nt:unstructured", Type.NAME); - c.setProperty(JCR_MIXINTYPES, of("mix:language"), Type.NAMES); + c.setProperty(JCR_MIXINTYPES, List.of("mix:language"), Type.NAMES); } @Test @@ -86,8 +85,8 @@ public void query() throws Exception { assertQuery("select [jcr:path] from [nt:unstructured] ", new ArrayList()); - assertQuery("select [jcr:path] from [nt:folder] ", of("/c", "/d")); - assertQuery("select [jcr:path] from [mix:language] ", of("/e", "/f")); + assertQuery("select [jcr:path] from [nt:folder] ", List.of("/c", "/d")); + assertQuery("select [jcr:path] from [mix:language] ", List.of("/e", "/f")); setTraversalEnabled(true); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultiPropertyOrTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultiPropertyOrTest.java index b10262c6a2a..31df7419fe3 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultiPropertyOrTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultiPropertyOrTest.java @@ -30,7 +30,6 @@ import javax.jcr.query.Query; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Maps; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.api.ContentRepository; @@ -61,7 +60,7 @@ public void initialize(@NotNull NodeBuilder builder) { NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder); IndexUtils.createIndexDefinition( index, "xyz", true, false, - ImmutableList.of("x", "y", "z", "w"), null); + List.of("x", "y", "z", "w"), null); } }) .with(new OpenSecurityProvider()) @@ -79,7 +78,7 @@ public void query() throws Exception { root.commit(); setTraversalEnabled(false); assertQuery("select [jcr:path] from [nt:base] where [x] is not null", - ImmutableList.of("/a")); + List.of("/a")); List lines = executeQuery( "explain select [jcr:path] from [nt:base] where [x] is not null", @@ -105,13 +104,13 @@ public void query() throws Exception { assertQuery( "select [jcr:path] from [nt:base] where [x] = 'foo' OR [y] = 'foo'", - ImmutableList.of("/a")); + List.of("/a")); assertQuery( "select [jcr:path] from [nt:base] where [x] = 'foo' OR [z] = 'foo'", - ImmutableList.of("/a", "/c")); + List.of("/a", "/c")); assertQuery( "select [jcr:path] from [nt:base] where [x] = 'foo' OR [y] = 'bar'", - ImmutableList.of("/a", "/b")); + List.of("/a", "/b")); setTraversalEnabled(false); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultipleIndicesTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultipleIndicesTest.java index baac33ba97f..58cd459cad9 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultipleIndicesTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/MultipleIndicesTest.java @@ -20,6 +20,7 @@ import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.getOrCreateOakIndex; import java.util.ArrayList; +import java.util.List; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.api.CommitFailedException; @@ -33,8 +34,6 @@ import org.jetbrains.annotations.NotNull; import org.junit.Test; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - public class MultipleIndicesTest extends AbstractQueryTest { @Override @@ -46,10 +45,10 @@ protected ContentRepository createRepository() { public void initialize(@NotNull NodeBuilder builder) { createIndexDefinition( getOrCreateOakIndex(builder), "pid", - true, false, ImmutableList.of("pid"), null); + true, false, List.of("pid"), null); createIndexDefinition( getOrCreateOakIndex(builder.child("content")), - "pid", true, false, ImmutableList.of("pid"), + "pid", true, false, List.of("pid"), null); } }) @@ -80,13 +79,13 @@ public void query() throws Exception { new ArrayList()); assertQuery("select [jcr:path] from [nt:base] where [pid] = 'foo'", - ImmutableList.of("/", "/a", "/c", "/content/x")); + List.of("/", "/a", "/c", "/content/x")); assertQuery("select [jcr:path] from [nt:base] where [pid] = 'bar'", - ImmutableList.of("/b", "/content/z")); + List.of("/b", "/content/z")); assertQuery("select [jcr:path] from [nt:base] where [pid] = 'baz'", - ImmutableList.of("/content/y")); + List.of("/content/y")); setTraversalEnabled(true); } @@ -109,11 +108,11 @@ public void emptyStringValue() throws CommitFailedException { setTraversalEnabled(false); assertQuery("select [jcr:path] from [nt:base] where [pid] = 'value'", - ImmutableList.of("/node-1")); + List.of("/node-1")); assertQuery("select [jcr:path] from [nt:base] where [pid] = ''", - ImmutableList.of("/node-2")); + List.of("/node-2")); assertQuery("select [jcr:path] from [nt:base] where [pid] = ':'", - ImmutableList.of("/node-3")); + List.of("/node-3")); setTraversalEnabled(true); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProviderTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProviderTest.java index 7e64b603aff..e594b0d9cef 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProviderTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/OrderedPropertyIndexEditorProviderTest.java @@ -30,7 +30,6 @@ import javax.jcr.RepositoryException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.commons.junit.LogCustomizer; import org.apache.jackrabbit.oak.plugins.index.IndexConstants; @@ -60,7 +59,7 @@ public class OrderedPropertyIndexEditorProviderTest { private NodeBuilder createIndexDef(NodeBuilder root) throws RepositoryException { return IndexUtils.createIndexDefinition( root.child(IndexConstants.INDEX_DEFINITIONS_NAME), indexName, false, - ImmutableList.of(indexedProperty), null, OrderedIndex.TYPE, null); + List.of(indexedProperty), null, OrderedIndex.TYPE, null); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java index aa1269a518d..d977728e409 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java @@ -23,7 +23,6 @@ import javax.jcr.query.Query; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.api.ContentRepository; import org.apache.jackrabbit.oak.api.Tree; @@ -49,7 +48,7 @@ protected ContentRepository createRepository() { public void initialize(@NotNull NodeBuilder builder) { NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder); IndexUtils.createIndexDefinition(index, "myProp", true, - false, ImmutableList.of("myProp"), null); + false, List.of("myProp"), null); } }) .with(new OpenSecurityProvider()) @@ -68,7 +67,7 @@ public void query() throws Exception { root.commit(); setTraversalEnabled(false); assertQuery("select [jcr:path] from [nt:base] where [n/myProp] is not null", - ImmutableList.of("/a", "/b")); + List.of("/a", "/b")); List lines = executeQuery( "explain select [jcr:path] from [nt:base] where [n/myProp] is not null", @@ -79,7 +78,7 @@ public void query() throws Exception { assertQuery( "select [jcr:path] from [nt:base] where [n/myProp] = 'foo'", - ImmutableList.of("/a")); + List.of("/a")); setTraversalEnabled(false); } } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/SinglePropertyIndexQueryTests.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/SinglePropertyIndexQueryTests.java index 9086156f8c7..3e55d5d2d34 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/SinglePropertyIndexQueryTests.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/SinglePropertyIndexQueryTests.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.plugins.index.property; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.oak.api.Type.NAMES; import static org.apache.jackrabbit.oak.api.Type.STRINGS; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.PROPERTY_NAMES; @@ -49,7 +48,7 @@ protected ContentRepository createRepository() { @Override protected void createTestIndexNode() throws Exception { Tree index = super.createTestIndexNode(root.getTree("/"), TYPE); - index.setProperty(PROPERTY_NAMES, of(INDEXED_PROPERTY), NAMES); + index.setProperty(PROPERTY_NAMES, List.of(INDEXED_PROPERTY), NAMES); index.setProperty(REINDEX_PROPERTY_NAME, true); root.commit(); } @@ -66,19 +65,19 @@ public void oak2146() throws Exception { // adding /content/node1 { a, b } Tree node = content.addChild("node1"); - node.setProperty(INDEXED_PROPERTY, of("a", "b"), STRINGS); + node.setProperty(INDEXED_PROPERTY, List.of("a", "b"), STRINGS); expected.add(node.getPath()); // adding /content/node2 { c, d } node = content.addChild("node2"); - node.setProperty(INDEXED_PROPERTY, of("c", "d"), STRINGS); + node.setProperty(INDEXED_PROPERTY, List.of("c", "d"), STRINGS); expected.add(node.getPath()); // adding nodes with {a, x} and {c, x} these should not be returned node = content.addChild("node3"); - node.setProperty(INDEXED_PROPERTY, of("a", "x"), STRINGS); + node.setProperty(INDEXED_PROPERTY, List.of("a", "x"), STRINGS); node = content.addChild("node4"); - node.setProperty(INDEXED_PROPERTY, of("c", "x"), STRINGS); + node.setProperty(INDEXED_PROPERTY, List.of("c", "x"), STRINGS); root.commit(); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/ValuePatternPropertyIndexTests.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/ValuePatternPropertyIndexTests.java index bf86b4d5ba9..49eb50bd37d 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/ValuePatternPropertyIndexTests.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/ValuePatternPropertyIndexTests.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.plugins.index.property; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.oak.api.Type.NAMES; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.PROPERTY_NAMES; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_PROPERTY_NAME; @@ -34,6 +33,8 @@ import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; import org.junit.Test; +import java.util.List; + public class ValuePatternPropertyIndexTests extends AbstractQueryTest { private static final String INDEXED_PROPERTY = "indexedProperty"; @@ -57,7 +58,7 @@ public void valuePattern() throws Exception { private void valuePattern(String middle, String plan) throws Exception { Tree index = super.createTestIndexNode(root.getTree("/"), TYPE); - index.setProperty(PROPERTY_NAMES, of(INDEXED_PROPERTY), NAMES); + index.setProperty(PROPERTY_NAMES, List.of(INDEXED_PROPERTY), NAMES); index.setProperty(IndexConstants.VALUE_INCLUDED_PREFIXES, "hello" + middle + "world"); index.setProperty(REINDEX_PROPERTY_NAME, true); root.commit(); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategyTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategyTest.java index f00db7a58bd..97ad3cce87d 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategyTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/strategy/ContentMirrorStoreStrategyTest.java @@ -16,9 +16,9 @@ */ package org.apache.jackrabbit.oak.plugins.index.property.strategy; -import static org.apache.jackrabbit.guava.common.base.Suppliers.memoize; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static java.util.Arrays.asList; + +import static org.apache.jackrabbit.guava.common.base.Suppliers.memoize; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.ENTRY_COUNT_PROPERTY_NAME; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_CONTENT_NODE_NAME; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.KEY_COUNT_PROPERTY_NAME; @@ -31,12 +31,14 @@ import java.util.Collections; import java.util.HashSet; +import java.util.List; import java.util.Set; import java.util.function.Supplier; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.query.index.FilterImpl; import org.apache.jackrabbit.oak.spi.query.Filter; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; @@ -306,21 +308,21 @@ public void nonRootStorage() throws Exception{ indexMeta.setChildNode(INDEX_CONTENT_NODE_NAME, builder.getNodeState()); Iterable paths = store.query(filter, null, indexMeta.getNodeState(), KEY); - assertThat(copyOf(paths), containsInAnyOrder("a", "a/c", "b")); + assertThat(CollectionUtils.toList(paths), containsInAnyOrder("a", "a/c", "b")); FilterImpl filter2 = FilterImpl.newTestInstance(); filter2.restrictPath("/content/a", Filter.PathRestriction.ALL_CHILDREN); paths = store.query(filter2, null, indexMeta.getNodeState(), KEY); - assertThat(copyOf(paths), containsInAnyOrder("a", "a/c")); + assertThat(CollectionUtils.toList(paths), containsInAnyOrder("a", "a/c")); store = new ContentMirrorStoreStrategy(INDEX_CONTENT_NODE_NAME, "/content", true); paths = store.query(filter, null, indexMeta.getNodeState(), KEY); - assertThat(copyOf(paths), containsInAnyOrder("/content/a", "/content/a/c", "/content/b")); + assertThat(CollectionUtils.toList(paths), containsInAnyOrder("/content/a", "/content/a/c", "/content/b")); paths = store.query(filter2, null, indexMeta.getNodeState(), KEY); - assertThat(copyOf(paths), containsInAnyOrder("/content/a", "/content/a/c")); + assertThat(CollectionUtils.toList(paths), containsInAnyOrder("/content/a", "/content/a/c")); } private static void assertInRange(String msg, double expected, double actual) { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/reference/ReferenceIndexTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/reference/ReferenceIndexTest.java index c68b1caf3ac..4179578b1e3 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/reference/ReferenceIndexTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/reference/ReferenceIndexTest.java @@ -47,7 +47,6 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.JcrConstants.JCR_UUID; import static org.apache.jackrabbit.JcrConstants.NT_BASE; import static org.apache.jackrabbit.oak.plugins.memory.PropertyStates.createProperty; @@ -80,11 +79,11 @@ public void basicReferenceHandling() throws Exception{ FilterImpl f = createFilter(indexed, NT_BASE); f.restrictProperty("*", Operator.EQUAL, newReference("u1"), PropertyType.REFERENCE); - assertFilter(f, new ReferenceIndex(), indexed, of("/a", "/b")); + assertFilter(f, new ReferenceIndex(), indexed, List.of("/a", "/b")); FilterImpl f2 = createFilter(indexed, NT_BASE); f2.restrictProperty("*", Operator.EQUAL, newReference("u2"), PropertyType.WEAKREFERENCE); - assertFilter(f2, new ReferenceIndex(), indexed, of("/c")); + assertFilter(f2, new ReferenceIndex(), indexed, List.of("/c")); } @Test @@ -117,11 +116,11 @@ public void referenceHandlingWithMounts() throws Exception{ f.restrictProperty("*", Operator.EQUAL, newReference("u1"), PropertyType.REFERENCE); // System.out.println(NodeStateUtils.toString(NodeStateUtils.getNode(indexed, "/oak:index/reference"))); - assertFilter(f, referenceIndex, indexed, of("/a/x", "/b")); + assertFilter(f, referenceIndex, indexed, List.of("/a/x", "/b")); FilterImpl f2 = createFilter(indexed, NT_BASE); f2.restrictProperty("*", Operator.EQUAL, newReference("u1"), PropertyType.WEAKREFERENCE); - assertFilter(f2, referenceIndex, indexed, of("/c", "/a/y")); + assertFilter(f2, referenceIndex, indexed, List.of("/c", "/a/y")); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditorTest.java index 1a1102c218d..55bd4b463b4 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditorTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/TypeEditorTest.java @@ -30,8 +30,8 @@ import static org.junit.Assert.fail; import java.util.Collections; +import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; @@ -129,7 +129,7 @@ public void addNamedPropertyWithBadRequiredType() { NodeBuilder testNode = builder.child("testNode"); testNode.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, Type.NAME); - testNode.setProperty(JCR_MIXINTYPES, ImmutableList.of("mix:title"), Type.NAMES); + testNode.setProperty(JCR_MIXINTYPES, List.of("mix:title"), Type.NAMES); testNode.setProperty("jcr:title", true); try { @@ -148,7 +148,7 @@ public void changeNamedPropertyToBadRequiredType() { NodeBuilder builder = root.builder(); NodeBuilder testNode = builder.child("testNode"); testNode.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, Type.NAME); - testNode.setProperty(JCR_MIXINTYPES, ImmutableList.of("mix:title"), Type.NAMES); + testNode.setProperty(JCR_MIXINTYPES, List.of("mix:title"), Type.NAMES); testNode.setProperty("jcr:title", "title"); NodeState before = builder.getNodeState(); @@ -177,7 +177,7 @@ public void addMandatoryPropertyWithBadRequiredType() { NodeBuilder ace = acl.child("first"); ace.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_GRANT_ACE, Type.NAME); ace.setProperty(AccessControlConstants.REP_PRINCIPAL_NAME, EveryonePrincipal.NAME); - ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.STRINGS); + ace.setProperty(AccessControlConstants.REP_PRIVILEGES, List.of(PrivilegeConstants.JCR_READ), Type.STRINGS); try { hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY); @@ -199,12 +199,12 @@ public void changeMandatoryPropertyToBadRequiredType() { NodeBuilder ace = acl.child("first"); ace.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_GRANT_ACE, Type.NAME); ace.setProperty(AccessControlConstants.REP_PRINCIPAL_NAME, EveryonePrincipal.NAME); - ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.NAMES); + ace.setProperty(AccessControlConstants.REP_PRIVILEGES, List.of(PrivilegeConstants.JCR_READ), Type.NAMES); NodeState before = builder.getNodeState(); // change to invalid type - ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.STRINGS); + ace.setProperty(AccessControlConstants.REP_PRIVILEGES, List.of(PrivilegeConstants.JCR_READ), Type.STRINGS); try { hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY); @@ -316,7 +316,7 @@ public void malformedUUID() throws CommitFailedException { builder = root.builder(); before = builder.getNodeState(); - builder.child("testcontent").setProperty(JCR_MIXINTYPES, ImmutableList.of(MIX_REFERENCEABLE), Type.NAMES); + builder.child("testcontent").setProperty(JCR_MIXINTYPES, List.of(MIX_REFERENCEABLE), Type.NAMES); try { hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY); fail("should not be able to change mixin due to illegal uuid format"); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeRegistryTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeRegistryTest.java index ee0cde6907a..2f878c65dae 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeRegistryTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeRegistryTest.java @@ -19,7 +19,6 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Objects.requireNonNull; import static org.apache.jackrabbit.oak.commons.conditions.Validate.checkArgument; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.JcrConstants.NT_BASE; @@ -143,7 +142,7 @@ public void oakIndexableSuccessful() throws IOException, CommitFailedException { Tree test = root.getTree("/").addChild("test"); test.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, NAME); - test.setProperty(JCR_MIXINTYPES, of(MIX_INDEXABLE), Type.NAMES); + test.setProperty(JCR_MIXINTYPES, List.of(MIX_INDEXABLE), Type.NAMES); test.addChild("oak:index").setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, NAME); root.commit(); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/PropertyInexistenceTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/PropertyInexistenceTest.java index 8aecb03eca3..5d6f4ff9fdf 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/PropertyInexistenceTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/PropertyInexistenceTest.java @@ -16,10 +16,8 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.query; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.InitialContent; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.api.ContentRepository; @@ -64,10 +62,10 @@ public void inexistence() throws Exception { root.commit(); String query1 = "SELECT * FROM [nt:base] WHERE ISDESCENDANTNODE('/a') AND [z] IS NULL"; - List expected1 = ImmutableList.of("/a/x", "/a/x/y"); + List expected1 = List.of("/a/x", "/a/x/y"); String query2 = "SELECT * FROM [nt:base] WHERE ISDESCENDANTNODE('/a/x') AND [z] IS NULL"; - List expected2 = ImmutableList.of("/a/x/y"); + List expected2 = List.of("/a/x/y"); assertQuery(query1, expected1); assertQuery(query2, expected2); @@ -88,12 +86,12 @@ public void relativeInexistence() throws Exception { root.commit(); String query1 = "SELECT * FROM [nt:base] WHERE ISDESCENDANTNODE('/a') AND [y/z] IS NULL"; - List expected1 = ImmutableList.of("/a/x", "/a/x/y", "/a/x1"); - List expectedOld1 = ImmutableList.of("/a/x"); + List expected1 = List.of("/a/x", "/a/x/y", "/a/x1"); + List expectedOld1 = List.of("/a/x"); String query2 = "SELECT * FROM [nt:base] WHERE ISDESCENDANTNODE('/a/x') AND [y/z] IS NULL"; - List expected2 = ImmutableList.of("/a/x/y"); - List expectedOld2 = ImmutableList.of(); + List expected2 = List.of("/a/x/y"); + List expectedOld2 = List.of(); assertQuery(query1, expected1); assertQuery(query2, expected2); @@ -112,8 +110,8 @@ public void relativeInexistence() throws Exception { System.setProperty("oak.useOldInexistenceCheck", "false"); String query3 = "SELECT * FROM [nt:base] WHERE ISDESCENDANTNODE('/a/x2') AND [y/z] IS NULL"; - List expected3 = ImmutableList.of("/a/x2/z", "/a/x2/z1/y"); - List expectedOld3 = ImmutableList.of(); + List expected3 = List.of("/a/x2/z", "/a/x2/z1/y"); + List expectedOld3 = List.of(); assertQuery(query3, expected3); @@ -131,8 +129,8 @@ public void deeperRelativeInexistence() throws Exception { root.commit(); String query = "SELECT * FROM [nt:base] WHERE ISDESCENDANTNODE('/a') AND [w/y/z] IS NULL"; - List expected = ImmutableList.of("/a/x", "/a/x1", "/a/x1/w", "/a/x2", "/a/x2/w", "/a/x2/w/y"); - List expectedOld = ImmutableList.of("/a/x2"); + List expected = List.of("/a/x", "/a/x1", "/a/x1/w", "/a/x2", "/a/x2/w", "/a/x2/w/y"); + List expectedOld = List.of("/a/x2"); assertQuery(query, expected); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryCostOverheadTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryCostOverheadTest.java index 24d437e115e..77298990ed1 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryCostOverheadTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/QueryCostOverheadTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.query; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; @@ -29,6 +28,8 @@ import org.apache.jackrabbit.oak.query.ast.OrImpl; import org.junit.Test; +import java.util.List; + public class QueryCostOverheadTest { @Test public void getCostOverhead() { @@ -54,14 +55,14 @@ public void getCostOverhead() { c1 = new ComparisonImpl(null, null, null); c2 = new FullTextSearchImpl(null, null, null); c3 = new FullTextSearchImpl(null, null, null); - c = new OrImpl(of(c1, c2, c3)); + c = new OrImpl(List.of(c1, c2, c3)); query = createQuery(c); assertTrue(query.containsUnfilteredFullTextCondition()); c2 = new FullTextSearchImpl(null, null, null); c3 = new FullTextSearchImpl(null, null, null); c4 = new ComparisonImpl(null, null, null); - c1 = new OrImpl(of(c2, c3, c4)); + c1 = new OrImpl(List.of(c2, c3, c4)); c5 = mock(DescendantNodeImpl.class); c = new AndImpl(c1, c5); query = createQuery(c); @@ -74,20 +75,20 @@ public void getCostOverhead() { c1 = new FullTextSearchImpl(null, null, null); c2 = new FullTextSearchImpl(null, null, null); c3 = new FullTextSearchImpl(null, null, null); - c = new OrImpl(of(c1, c2, c3)); + c = new OrImpl(List.of(c1, c2, c3)); query = createQuery(c); assertFalse(query.containsUnfilteredFullTextCondition()); c1 = new ComparisonImpl(null, null, null); c2 = new FullTextSearchImpl(null, null, null); c3 = new FullTextSearchImpl(null, null, null); - c = new AndImpl(of(c1, c2, c3)); + c = new AndImpl(List.of(c1, c2, c3)); query = createQuery(c); assertFalse(query.containsUnfilteredFullTextCondition()); c1 = new ComparisonImpl(null, null, null); c2 = new ComparisonImpl(null, null, null); - c = new AndImpl(of(c1, c2, c3)); + c = new AndImpl(List.of(c1, c2, c3)); query = createQuery(c); assertFalse(query.containsUnfilteredFullTextCondition()); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2OptimiseQueryTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2OptimiseQueryTest.java index f8685022ec9..8092a1f1913 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2OptimiseQueryTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2OptimiseQueryTest.java @@ -16,9 +16,7 @@ */ package org.apache.jackrabbit.oak.query; -import static java.util.Objects.requireNonNull; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; -import static javax.jcr.query.Query.JCR_SQL2; +import static java.util.Objects.requireNonNull;import static javax.jcr.query.Query.JCR_SQL2; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.oak.api.Type.NAME; import static org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants.NT_OAK_UNSTRUCTURED; @@ -125,7 +123,7 @@ public void orToUnions() throws RepositoryException, CommitFailedException { statement = String.format("SELECT * FROM [%s] WHERE p = 'a' OR p = 'b'", NT_OAK_UNSTRUCTURED); - expected = of("/test/a", "/test/b", "/test2/a"); + expected = List.of("/test/a", "/test/b", "/test2/a"); setQuerySelectionMode(ORIGINAL); original = executeQuery(statement, JCR_SQL2, true); setQuerySelectionMode(ALTERNATIVE); @@ -137,7 +135,7 @@ public void orToUnions() throws RepositoryException, CommitFailedException { statement = String.format( "SELECT * FROM [%s] WHERE p = 'a' OR p = 'b' OR p = 'c' OR p = 'd' OR p = 'e' ", NT_OAK_UNSTRUCTURED); - expected = of("/test/a", "/test/b", "/test/c", "/test/d", "/test/e", "/test2/a"); + expected = List.of("/test/a", "/test/b", "/test/c", "/test/d", "/test/e", "/test2/a"); setQuerySelectionMode(ORIGINAL); original = executeQuery(statement, JCR_SQL2, true); setQuerySelectionMode(ALTERNATIVE); @@ -149,7 +147,7 @@ public void orToUnions() throws RepositoryException, CommitFailedException { statement = String.format( "SELECT * FROM [%s] WHERE (p = 'a' OR p = 'b') AND (p1 = 'a1' OR p1 = 'b1')", NT_OAK_UNSTRUCTURED); - expected = of("/test/a", "/test/b"); + expected = List.of("/test/a", "/test/b"); setQuerySelectionMode(ORIGINAL); original = executeQuery(statement, JCR_SQL2, true); setQuerySelectionMode(ALTERNATIVE); @@ -161,7 +159,8 @@ public void orToUnions() throws RepositoryException, CommitFailedException { statement = String.format( "SELECT * FROM [%s] WHERE (p = 'a' AND p1 = 'a1') OR (p = 'b' AND p1 = 'b1')", NT_OAK_UNSTRUCTURED); - expected = of("/test/a", "/test/b"); + expected = List.of("/test/a", "/test/b"); + expected = List.of("/test/a", "/test/b"); setQuerySelectionMode(ORIGINAL); original = executeQuery(statement, JCR_SQL2, true); setQuerySelectionMode(ALTERNATIVE); @@ -176,7 +175,7 @@ public void orToUnions() throws RepositoryException, CommitFailedException { + "OR c.[p3] = 'a') " + "AND ISDESCENDANTNODE(c, '/test') " + "ORDER BY added DESC"; - expected = of("/test/a", "/test/b", "/test/c"); + expected = List.of("/test/a", "/test/b", "/test/c"); setQuerySelectionMode(ORIGINAL); original = executeQuery(statement, JCR_SQL2, true); setQuerySelectionMode(ALTERNATIVE); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/TraversalAvoidanceTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/TraversalAvoidanceTest.java index fc39b400575..f3e02547dca 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/TraversalAvoidanceTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/TraversalAvoidanceTest.java @@ -44,8 +44,6 @@ import org.junit.Before; import org.junit.Test; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - public class TraversalAvoidanceTest extends AbstractQueryTest { Whiteboard wb; @@ -192,7 +190,7 @@ void restPlans() { @NotNull @Override public List getQueryIndexes(NodeState nodeState) { - return ImmutableList.of(queryIndex); + return List.of(queryIndex); } } @@ -248,7 +246,7 @@ public String getIndexName() { @Override public List getPlans(Filter filter, List sortOrder, NodeState rootState) { - return ImmutableList.copyOf(plans); + return List.copyOf(plans); } @Override diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/IndexSelectionTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/IndexSelectionTest.java index a6afdcbb304..ca77a4f17a0 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/IndexSelectionTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/IndexSelectionTest.java @@ -16,13 +16,11 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.query.index; import java.util.List; import java.util.UUID; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.api.ContentRepository; @@ -64,7 +62,7 @@ public void uuidIndexQuery() throws Exception{ root.commit(); assertQuery("SELECT * FROM [nt:base] WHERE [jcr:uuid] = '"+uuid+"' ", - ImmutableList.of("/")); + List.of("/")); assertEquals("Test index plan should not be invoked", 0, testIndexProvider.index.invocationCount); } @@ -77,7 +75,7 @@ public void uuidIndexNotNullQuery() throws Exception{ root.commit(); assertQuery("SELECT * FROM [nt:base] WHERE [jcr:uuid] is not null", - ImmutableList.of("/")); + List.of("/")); assertEquals("Test index plan should be invoked", 1, testIndexProvider.index.invocationCount); } @@ -91,7 +89,7 @@ public void uuidIndexInListQuery() throws Exception{ root.commit(); assertQuery("SELECT * FROM [nt:base] WHERE [jcr:uuid] in('" + uuid + "', '" + uuid2 + "')", - ImmutableList.of("/")); + List.of("/")); assertEquals("Test index plan should be invoked", 1, testIndexProvider.index.invocationCount); } @@ -101,7 +99,7 @@ private static class TestIndexProvider implements QueryIndexProvider { @NotNull @Override public List getQueryIndexes(NodeState nodeState) { - return ImmutableList.of(index); + return List.of(index); } } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java index 69f5973a6d0..07f17b34199 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java @@ -14,7 +14,7 @@ package org.apache.jackrabbit.oak.query.index; import static java.util.Objects.requireNonNull; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; + import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED; import static org.apache.jackrabbit.oak.api.Type.LONG; @@ -37,8 +37,6 @@ import org.junit.Ignore; import org.junit.Test; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - /** * Tests the query engine using the default index implementation: the * {@link TraversingIndex} @@ -71,7 +69,7 @@ public void testFullTextTerm() throws Exception { node.setProperty("jcr:mimeType", "text/plain"); root.commit(); assertQuery("//*[jcr:contains(., 'text/plain')]", "xpath", - ImmutableList.of("/content")); + List.of("/content")); } @Test @@ -83,10 +81,10 @@ public void testFullTextTermName() throws Exception { root.commit(); assertQuery("//*[jcr:contains(., 'testFullTextTermNameSimple')]", "xpath", - ImmutableList.of("/content/testFullTextTermNameSimple")); + List.of("/content/testFullTextTermNameSimple")); assertQuery("//*[jcr:contains(., 'testFullTextTermNameFile.txt')]", "xpath", - ImmutableList.of("/content/testFullTextTermNameFile.txt")); + List.of("/content/testFullTextTermNameFile.txt")); } @Test @@ -95,13 +93,13 @@ public void testMultiNotEqual() throws Exception { c.addChild("one").setProperty("prop", "value"); c.addChild("two").setProperty("prop", - ImmutableList.of("aaa", "value", "bbb"), Type.STRINGS); + List.of("aaa", "value", "bbb"), Type.STRINGS); c.addChild("three").setProperty("prop", - ImmutableList.of("aaa", "bbb", "ccc"), Type.STRINGS); + List.of("aaa", "bbb", "ccc"), Type.STRINGS); root.commit(); assertQuery("//*[@prop != 'value']", "xpath", - ImmutableList.of("/content/two", "/content/three")); + List.of("/content/two", "/content/three")); } @Test @@ -110,13 +108,13 @@ public void testMultiAndEquals() throws Exception { c.addChild("one").setProperty("prop", "aaa"); c.addChild("two").setProperty("prop", - ImmutableList.of("aaa", "bbb", "ccc"), Type.STRINGS); - c.addChild("three").setProperty("prop", ImmutableList.of("aaa", "bbb"), + List.of("aaa", "bbb", "ccc"), Type.STRINGS); + c.addChild("three").setProperty("prop", List.of("aaa", "bbb"), Type.STRINGS); root.commit(); assertQuery("//*[(@prop = 'aaa' and @prop = 'bbb' and @prop = 'ccc')]", - "xpath", ImmutableList.of("/content/two")); + "xpath", List.of("/content/two")); } @Test @@ -125,13 +123,13 @@ public void testMultiAndLike() throws Exception { c.addChild("one").setProperty("prop", "aaaBoom"); c.addChild("two").setProperty("prop", - ImmutableList.of("aaaBoom", "bbbBoom", "cccBoom"), Type.STRINGS); - c.addChild("three").setProperty("prop", ImmutableList.of("aaaBoom", "bbbBoom"), + List.of("aaaBoom", "bbbBoom", "cccBoom"), Type.STRINGS); + c.addChild("three").setProperty("prop", List.of("aaaBoom", "bbbBoom"), Type.STRINGS); root.commit(); assertQuery("//*[(jcr:like(@prop, 'aaa%') and jcr:like(@prop, 'bbb%') and jcr:like(@prop, 'ccc%'))]", - "xpath", ImmutableList.of("/content/two")); + "xpath", List.of("/content/two")); } @Test @@ -141,17 +139,17 @@ public void testSubPropertyMultiAndEquals() throws Exception { c.addChild("one").addChild("child").setProperty("prop", "aaa"); c.addChild("two") .addChild("child") - .setProperty("prop", ImmutableList.of("aaa", "bbb", "ccc"), + .setProperty("prop", List.of("aaa", "bbb", "ccc"), Type.STRINGS); c.addChild("three") .addChild("child") - .setProperty("prop", ImmutableList.of("aaa", "bbb"), + .setProperty("prop", List.of("aaa", "bbb"), Type.STRINGS); root.commit(); assertQuery( "//*[(child/@prop = 'aaa' and child/@prop = 'bbb' and child/@prop = 'ccc')]", - "xpath", ImmutableList.of("/content/two")); + "xpath", List.of("/content/two")); } @Test @@ -161,17 +159,17 @@ public void testSubPropertyMultiAndLike() throws Exception { c.addChild("one").addChild("child").setProperty("prop", "aaaBoom"); c.addChild("two") .addChild("child") - .setProperty("prop", ImmutableList.of("aaaBoom", "bbbBoom", "cccBoom"), + .setProperty("prop", List.of("aaaBoom", "bbbBoom", "cccBoom"), Type.STRINGS); c.addChild("three") .addChild("child") - .setProperty("prop", ImmutableList.of("aaaBoom", "bbbBoom"), + .setProperty("prop", List.of("aaaBoom", "bbbBoom"), Type.STRINGS); root.commit(); assertQuery( "//*[(jcr:like(child/@prop, 'aaa%') and jcr:like(child/@prop, 'bbb%') and jcr:like(child/@prop, 'ccc%'))]", - "xpath", ImmutableList.of("/content/two")); + "xpath", List.of("/content/two")); } @Test @@ -204,8 +202,7 @@ public void testOak1301() throws Exception { assertQuery( "/jcr:root/home//*[@id='socialgraph_test_group']", "xpath", - ImmutableList - .of("/home/users/testing/socialgraph_test_user_4/social/relationships/friend/socialgraph_test_group")); + List.of("/home/users/testing/socialgraph_test_user_4/social/relationships/friend/socialgraph_test_group")); // sql2 select c.[jcr:path] as [jcr:path], c.[jcr:score] as [jcr:score], // c.* from [nt:base] as a inner join [nt:base] as b on ischildnode(b, @@ -217,8 +214,7 @@ public void testOak1301() throws Exception { assertQuery( "/jcr:root/home//social/relationships//*[@id='socialgraph_test_group']", "xpath", - ImmutableList - .of("/home/users/testing/socialgraph_test_user_4/social/relationships/friend/socialgraph_test_group")); + List.of("/home/users/testing/socialgraph_test_user_4/social/relationships/friend/socialgraph_test_group")); } @@ -229,22 +225,22 @@ public void testRelativeProperties() throws Exception { root.commit(); assertQuery("//*[(@prop > 1)]", "xpath", - ImmutableList.of("/content/node1")); + List.of("/content/node1")); assertQuery("//*[(@prop > 2)]", "xpath", - ImmutableList.of("/content/node1")); + List.of("/content/node1")); assertQuery("//*[(@prop > 20)]", "xpath", - ImmutableList.of("/content/node1")); + List.of("/content/node1")); assertQuery("//*[(@prop > 100)]", "xpath", - ImmutableList.of("/content/node1")); + List.of("/content/node1")); assertQuery("//*[(@prop > 200)]", "xpath", new ArrayList()); assertQuery("//*[(@prop > 1000)]", "xpath", new ArrayList()); - assertQuery("//*[(*/@prop > 1)]", "xpath", ImmutableList.of("/content")); - assertQuery("//*[(*/@prop > 2)]", "xpath", ImmutableList.of("/content")); + assertQuery("//*[(*/@prop > 1)]", "xpath", List.of("/content")); + assertQuery("//*[(*/@prop > 2)]", "xpath", List.of("/content")); assertQuery("//*[(*/@prop > 20)]", "xpath", - ImmutableList.of("/content")); + List.of("/content")); assertQuery("//*[(*/@prop > 100)]", "xpath", - ImmutableList.of("/content")); + List.of("/content")); assertQuery("//*[(*/@prop > 200)]", "xpath", new ArrayList()); assertQuery("//*[(*/@prop > 1000)]", "xpath", new ArrayList()); } @@ -271,35 +267,35 @@ public void testRelativeProperties2() throws Exception { root.commit(); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 9)]", "xpath", - ImmutableList.of("/content/nodes/a")); + List.of("/content/nodes/a")); assertQuery( "/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 9)]", - "xpath", ImmutableList.of("/content/nodes/a")); + "xpath", List.of("/content/nodes/a")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 10)]", "xpath", - ImmutableList.of("/content/nodes/a")); + List.of("/content/nodes/a")); assertQuery( "/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 10)]", - "xpath", ImmutableList.of("/content/nodes/a")); + "xpath", List.of("/content/nodes/a")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 15)]", "xpath", - ImmutableList.of("/content/nodes/a")); + List.of("/content/nodes/a")); assertQuery( "/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 15)]", - "xpath", ImmutableList.of("/content/nodes/a")); + "xpath", List.of("/content/nodes/a")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 20)]", "xpath", - ImmutableList.of("/content/nodes/a")); + List.of("/content/nodes/a")); assertQuery( "/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 20)]", - "xpath", ImmutableList.of("/content/nodes/a")); + "xpath", List.of("/content/nodes/a")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 30)]", "xpath", - ImmutableList.of("/content/nodes/a")); + List.of("/content/nodes/a")); assertQuery( "/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 30)]", - "xpath", ImmutableList.of("/content/nodes/a")); + "xpath", List.of("/content/nodes/a")); } /** @@ -377,53 +373,53 @@ public void testRangeRelativeProperties() throws CommitFailedException { root.commit(); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 9)]", "xpath", - of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20", + List.of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20", "/content/nodes/a30")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 10)]", "xpath", - of("/content/nodes/a10", "/content/nodes/a20", "/content/nodes/a30")); + List.of("/content/nodes/a10", "/content/nodes/a20", "/content/nodes/a30")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 20)]", "xpath", - of("/content/nodes/a20", "/content/nodes/a30")); + List.of("/content/nodes/a20", "/content/nodes/a30")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 30)]", "xpath", - of("/content/nodes/a30")); + List.of("/content/nodes/a30")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop >= 40)]", "xpath", emptyList); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop <= 8)]", "xpath", emptyList); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop <= 9)]", "xpath", - of("/content/nodes/a9")); + List.of("/content/nodes/a9")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop <= 10)]", "xpath", - of("/content/nodes/a9", "/content/nodes/a10")); + List.of("/content/nodes/a9", "/content/nodes/a10")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop <= 20)]", "xpath", - of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20")); + List.of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20")); assertQuery("/jcr:root/content/nodes//*[(*/*/*/@prop <= 30)]", "xpath", - of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20", + List.of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20", "/content/nodes/a30")); assertQuery( "/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 9)]", "xpath", - of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20", + List.of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20", "/content/nodes/a30")); assertQuery("/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 10)]", - "xpath", of("/content/nodes/a10", "/content/nodes/a20", "/content/nodes/a30")); + "xpath", List.of("/content/nodes/a10", "/content/nodes/a20", "/content/nodes/a30")); assertQuery("/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 20)]", - "xpath", of("/content/nodes/a20", "/content/nodes/a30")); + "xpath", List.of("/content/nodes/a20", "/content/nodes/a30")); assertQuery("/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 30)]", - "xpath", of("/content/nodes/a30")); + "xpath", List.of("/content/nodes/a30")); assertQuery("/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop >= 40)]", "xpath", emptyList); assertQuery("/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop <= 8)]", "xpath", emptyList); assertQuery("/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop <= 9)]", - "xpath", of("/content/nodes/a9")); + "xpath", List.of("/content/nodes/a9")); assertQuery("/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop <= 10)]", - "xpath", of("/content/nodes/a9", "/content/nodes/a10")); + "xpath", List.of("/content/nodes/a9", "/content/nodes/a10")); assertQuery("/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop <= 20)]", - "xpath", of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20")); + "xpath", List.of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20")); assertQuery( "/jcr:root/content/nodes//element(*, nt:unstructured)[(*/*/*/@prop <= 30)]", "xpath", - of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20", + List.of("/content/nodes/a9", "/content/nodes/a10", "/content/nodes/a20", "/content/nodes/a30")); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/stats/QuerySimilarCostTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/stats/QuerySimilarCostTest.java index 63eb9fc195a..8a479a197a4 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/stats/QuerySimilarCostTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/stats/QuerySimilarCostTest.java @@ -46,8 +46,6 @@ import org.junit.Test; import org.slf4j.event.Level; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - /** * Tests for cases where two or more indices return a similar cost estimation for the same query */ @@ -101,7 +99,7 @@ private static class TestIndexProvider implements QueryIndexProvider { @Override public @NotNull List getQueryIndexes(NodeState nodeState) { - return ImmutableList.of(index); + return List.of(index); } } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationConfigurationImplOSGiTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationConfigurationImplOSGiTest.java index ea224f0c092..c7308ec5607 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationConfigurationImplOSGiTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationConfigurationImplOSGiTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.security.authorization.accesscontrol.AccessControlImporter; @@ -101,13 +100,13 @@ public void testGetWorkspaceInitializer() { @Test public void testGetCommitHooks() { - List expected = ImmutableList.of(VersionablePathHook.class, PermissionHook.class); + List expected = List.of(VersionablePathHook.class, PermissionHook.class); assertTrue(Iterables.elementsEqual(expected, Iterables.transform(authorizationConfiguration.getCommitHooks(adminSession.getWorkspaceName()), commitHook -> commitHook.getClass()))); } @Test public void testGetValidators() { - List expected = ImmutableList.of(PermissionStoreValidatorProvider.class, PermissionValidatorProvider.class, AccessControlValidatorProvider.class); + List expected = List.of(PermissionStoreValidatorProvider.class, PermissionValidatorProvider.class, AccessControlValidatorProvider.class); assertTrue(Iterables.elementsEqual(expected, Iterables.transform(authorizationConfiguration.getValidators(adminSession.getWorkspaceName(), Set.of(), new MoveTracker()), commitHook -> commitHook.getClass()))); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationContextTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationContextTest.java index 306938e67f9..526b88a0872 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationContextTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationContextTest.java @@ -22,7 +22,6 @@ import javax.jcr.security.AccessControlList; import javax.jcr.security.AccessControlManager; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; @@ -127,7 +126,7 @@ public void testLocation() throws Exception { assertTrue(ctx.definesLocation(TreeLocation.create(root, policyPath + "/allow/" + AccessControlConstants.REP_PRINCIPAL_NAME))); assertTrue(ctx.definesLocation(TreeLocation.create(root, policyPath + "/allow/" + AccessControlConstants.REP_PRIVILEGES))); - List existingRegular = ImmutableList.of( + List existingRegular = List.of( "/", "/jcr:system" ); @@ -136,7 +135,7 @@ public void testLocation() throws Exception { assertFalse(path, ctx.definesLocation(TreeLocation.create(root, PathUtils.concat(path, JcrConstants.JCR_PRIMARYTYPE)))); } - List nonExistingItem = ImmutableList.of( + List nonExistingItem = List.of( '/' + AccessControlConstants.REP_REPO_POLICY, "/content/" + AccessControlConstants.REP_POLICY, "/content/" + AccessControlConstants.REP_PRIVILEGES, diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/ACLTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/ACLTest.java index 877e05ee0a3..d0799150de6 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/ACLTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/ACLTest.java @@ -34,7 +34,6 @@ import javax.jcr.security.AccessControlException; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry; @@ -115,7 +114,7 @@ private List createTestEntries() throws RepositoryException { @Test public void testGetNamePathMapper() { assertSame(getNamePathMapper(), acl.getNamePathMapper()); - assertSame(NamePathMapper.DEFAULT, createACL(TEST_PATH, ImmutableList.of(), NamePathMapper.DEFAULT).getNamePathMapper()); + assertSame(NamePathMapper.DEFAULT, createACL(TEST_PATH, List.of(), NamePathMapper.DEFAULT).getNamePathMapper()); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterAbortTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterAbortTest.java index d4d689b80b6..0d05bff559b 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterAbortTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterAbortTest.java @@ -18,7 +18,8 @@ import javax.jcr.security.AccessControlException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import java.util.List; + import org.apache.jackrabbit.oak.spi.xml.ImportBehavior; import org.junit.Test; @@ -33,6 +34,6 @@ String getImportBehavior() { public void testStartAceChildInfoUnknownPrincipal() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(unknownPrincipalInfo)); + importer.startChildInfo(aceGrantInfo, List.of(unknownPrincipalInfo)); } } \ No newline at end of file diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterBaseTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterBaseTest.java index e390978ed5c..39380380d81 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterBaseTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterBaseTest.java @@ -16,9 +16,7 @@ */ package org.apache.jackrabbit.oak.security.authorization.accesscontrol; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; @@ -72,9 +70,9 @@ public abstract class AccessControlImporterBaseTest extends AbstractSecurityTest implements AccessControlConstants { - final NodeInfo aceGrantInfo = new NodeInfo("grantAceName", NT_REP_GRANT_ACE, ImmutableList.of(), null); - private final NodeInfo aceDenyInfo = new NodeInfo("denyAceName", NT_REP_DENY_ACE, ImmutableList.of(), null); - private final NodeInfo restrInfo = new NodeInfo("anyRestrName", NT_REP_RESTRICTIONS, ImmutableList.of(), null); + final NodeInfo aceGrantInfo = new NodeInfo("grantAceName", NT_REP_GRANT_ACE, List.of(), null); + private final NodeInfo aceDenyInfo = new NodeInfo("denyAceName", NT_REP_DENY_ACE, List.of(), null); + private final NodeInfo restrInfo = new NodeInfo("anyRestrName", NT_REP_RESTRICTIONS, List.of(), null); final PropInfo unknownPrincipalInfo = new PropInfo(REP_PRINCIPAL_NAME, PropertyType.STRING, createTextValue("unknownPrincipal")); private Tree accessControlledTree; @@ -328,38 +326,38 @@ public void testProcessReferencesIsNoOp() { @Test(expected = IllegalStateException.class) public void testStartChildInfoNotInitialized() throws Exception { - importer.startChildInfo(mock(NodeInfo.class), ImmutableList.of()); + importer.startChildInfo(mock(NodeInfo.class), List.of()); } @Test(expected = ConstraintViolationException.class) public void testStartChildInfoUnknownType() throws Exception { - NodeInfo invalidChildInfo = new NodeInfo("anyName", NT_OAK_UNSTRUCTURED, ImmutableList.of(), null); + NodeInfo invalidChildInfo = new NodeInfo("anyName", NT_OAK_UNSTRUCTURED, List.of(), null); init(); importer.start(aclTree); - importer.startChildInfo(invalidChildInfo, ImmutableList.of()); + importer.startChildInfo(invalidChildInfo, List.of()); } @Test(expected = ConstraintViolationException.class) public void testStartNestedAceChildInfo() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of()); - importer.startChildInfo(aceDenyInfo, ImmutableList.of()); + importer.startChildInfo(aceGrantInfo, List.of()); + importer.startChildInfo(aceDenyInfo, List.of()); } @Test(expected = ConstraintViolationException.class) public void testStartRestrictionChildInfoWithoutAce() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(restrInfo, ImmutableList.of()); + importer.startChildInfo(restrInfo, List.of()); } @Test public void testStartAceAndRestrictionChildInfo() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of()); - importer.startChildInfo(restrInfo, ImmutableList.of()); + importer.startChildInfo(aceGrantInfo, List.of()); + importer.startChildInfo(restrInfo, List.of()); } @Test(expected = AccessControlException.class) @@ -367,7 +365,7 @@ public void testStartAceChildInfoInvalidPrivilege() throws Exception { init(); importer.start(aclTree); PropInfo invalidPrivInfo = new PropInfo(REP_PRIVILEGES, PropertyType.NAME, createTextValues("jcr:invalidPrivilege"), PropInfo.MultipleStatus.MULTIPLE); - importer.startChildInfo(aceDenyInfo, ImmutableList.of(invalidPrivInfo)); + importer.startChildInfo(aceDenyInfo, List.of(invalidPrivInfo)); } //-------------------------------------------------------< endChildInfo >--- @@ -388,7 +386,7 @@ public void testEndChildInfoWithoutStart() throws Exception { public void testEndChildInfoIncompleteAce() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of()); + importer.startChildInfo(aceGrantInfo, List.of()); importer.endChildInfo(); } @@ -419,10 +417,10 @@ public void testEndWithoutChildInfo() throws Exception { public void testInvalidRestriction() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(principalInfo, privInfo)); + importer.startChildInfo(aceGrantInfo, List.of(principalInfo, privInfo)); PropInfo invalidRestrProp = new PropInfo(REP_GLOB, PropertyType.NAME, createTextValues("glob1", "glob2"), PropInfo.MultipleStatus.MULTIPLE); - importer.startChildInfo(restrInfo, ImmutableList.of(invalidRestrProp)); + importer.startChildInfo(restrInfo, List.of(invalidRestrProp)); importer.endChildInfo(); importer.endChildInfo(); importer.end(aclTree); @@ -432,10 +430,10 @@ public void testInvalidRestriction() throws Exception { public void testUnknownRestriction() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(principalInfo, privInfo)); + importer.startChildInfo(aceGrantInfo, List.of(principalInfo, privInfo)); PropInfo invalidRestrProp = new PropInfo("unknown", PropertyType.STRING, createTextValue("val")); - importer.startChildInfo(restrInfo, ImmutableList.of(invalidRestrProp)); + importer.startChildInfo(restrInfo, List.of(invalidRestrProp)); importer.endChildInfo(); importer.endChildInfo(); importer.end(aclTree); @@ -445,7 +443,7 @@ public void testUnknownRestriction() throws Exception { public void testImportSimple() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(principalInfo, privInfo)); + importer.startChildInfo(aceGrantInfo, List.of(principalInfo, privInfo)); importer.endChildInfo(); importer.end(aclTree); @@ -470,7 +468,7 @@ public void testImportWithRestrictions() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(principalInfo, privInfo, globInfo, ntNamesInfo, itemNamesInfo)); + importer.startChildInfo(aceGrantInfo, List.of(principalInfo, privInfo, globInfo, ntNamesInfo, itemNamesInfo)); importer.endChildInfo(); importer.end(aclTree); @@ -488,8 +486,8 @@ public void testImportWithRestrictionNodeInfo() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(principalInfo, privInfo)); - importer.startChildInfo(restrInfo, ImmutableList.of(globInfo, ntNamesInfo, itemNamesInfo)); + importer.startChildInfo(aceGrantInfo, List.of(principalInfo, privInfo)); + importer.startChildInfo(restrInfo, List.of(globInfo, ntNamesInfo, itemNamesInfo)); importer.endChildInfo(); importer.endChildInfo(); importer.end(aclTree); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterBesteffortTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterBesteffortTest.java index cf08ac1038f..77a725d1697 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterBesteffortTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterBesteffortTest.java @@ -18,7 +18,6 @@ import javax.jcr.PropertyType; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants; import org.apache.jackrabbit.oak.spi.xml.ImportBehavior; @@ -26,6 +25,8 @@ import org.apache.jackrabbit.oak.plugins.tree.TreeUtil; import org.junit.Test; +import java.util.List; + import static org.junit.Assert.assertEquals; public class AccessControlImporterBesteffortTest extends AccessControlImporterBaseTest{ @@ -39,7 +40,7 @@ String getImportBehavior() { public void testStartAceChildInfoUnknownPrincipal() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(unknownPrincipalInfo)); + importer.startChildInfo(aceGrantInfo, List.of(unknownPrincipalInfo)); } @Test @@ -48,7 +49,7 @@ public void testImportWithUnknownPrincipal() throws Exception { importer.start(aclTree); PropInfo privs = new PropInfo(REP_PRIVILEGES, PropertyType.NAME, createTextValues(PrivilegeConstants.JCR_READ)); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(unknownPrincipalInfo, privs)); + importer.startChildInfo(aceGrantInfo, List.of(unknownPrincipalInfo, privs)); importer.endChildInfo(); importer.end(aclTree); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterIgnoreTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterIgnoreTest.java index 3075ef731ae..37cc4c5d928 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterIgnoreTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlImporterIgnoreTest.java @@ -18,12 +18,13 @@ import javax.jcr.PropertyType; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants; import org.apache.jackrabbit.oak.spi.xml.ImportBehavior; import org.apache.jackrabbit.oak.spi.xml.PropInfo; import org.junit.Test; +import java.util.List; + import static org.junit.Assert.assertFalse; public class AccessControlImporterIgnoreTest extends AccessControlImporterBaseTest{ @@ -37,7 +38,7 @@ String getImportBehavior() { public void testStartAceChildInfoUnknownPrincipal() throws Exception { init(); importer.start(aclTree); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(unknownPrincipalInfo)); + importer.startChildInfo(aceGrantInfo, List.of(unknownPrincipalInfo)); } @Test @@ -46,7 +47,7 @@ public void testImportWithUnknownPrincipal() throws Exception { importer.start(aclTree); PropInfo privs = new PropInfo(REP_PRIVILEGES, PropertyType.NAME, createTextValues(PrivilegeConstants.JCR_READ)); - importer.startChildInfo(aceGrantInfo, ImmutableList.of(unknownPrincipalInfo, privs)); + importer.startChildInfo(aceGrantInfo, List.of(unknownPrincipalInfo, privs)); importer.endChildInfo(); importer.end(aclTree); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImplTest.java index 1de18efa535..8db506f5bad 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerImplTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.accesscontrol; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.JcrConstants; @@ -642,7 +641,7 @@ public void testGetApplicablePolicies() throws Exception { @Test public void testGetApplicablePoliciesOnAccessControllable() throws Exception { Tree node = root.getTree(testPath); - node.setProperty(JcrConstants.JCR_MIXINTYPES, ImmutableList.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); + node.setProperty(JcrConstants.JCR_MIXINTYPES, List.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); AccessControlPolicyIterator itr = acMgr.getApplicablePolicies(testPath); @@ -785,7 +784,7 @@ public void testGetPolicyWithInvalidPrincipal() throws Exception { Tree aclNode = root.getTree(testPath + '/' + REP_POLICY); Tree aceNode = TreeUtil.addChild(aclNode, "testACE", NT_REP_DENY_ACE); aceNode.setProperty(REP_PRINCIPAL_NAME, "invalidPrincipal"); - aceNode.setProperty(REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.NAMES); + aceNode.setProperty(REP_PRIVILEGES, List.of(PrivilegeConstants.JCR_READ), Type.NAMES); // reading policies with unknown principal name should not fail. AccessControlPolicy[] policies = acMgr.getPolicies(testPath); @@ -1486,7 +1485,7 @@ public void testGetApplicablePoliciesNullPrincipal() throws Exception { @Test public void testGetApplicablePoliciesByPrincipal() throws Exception { - List principals = ImmutableList.of(testPrincipal, EveryonePrincipal.getInstance()); + List principals = List.of(testPrincipal, EveryonePrincipal.getInstance()); for (Principal principal : principals) { AccessControlPolicy[] applicable = acMgr.getApplicablePolicies(principal); assertPolicies(applicable, 1); @@ -1516,7 +1515,7 @@ public void testGetPoliciesNullPrincipal() throws Exception { @Test public void testGetPoliciesByPrincipal() throws Exception { - List principals = ImmutableList.of(testPrincipal, EveryonePrincipal.getInstance()); + List principals = List.of(testPrincipal, EveryonePrincipal.getInstance()); for (Principal principal : principals) { assertPolicies(acMgr.getPolicies(principal), 0); } @@ -1719,7 +1718,7 @@ public void testEffectivePoliciesFiltering() throws Exception { // different ways to create the principal-set to make sure the filtering // doesn't rely on principal equality but rather on the name. - List principals = ImmutableList.of( + List principals = List.of( testPrincipal, new PrincipalImpl(testPrincipal.getName()), () -> testPrincipal.getName()); @@ -1746,7 +1745,7 @@ public void testEffectivePolicyIsolatedAce() throws Exception { Tree testTree = r.getTree(testPath); Tree ace = TreeUtil.addChild(testTree, "ace", NT_REP_GRANT_ACE); ace.setProperty(REP_PRINCIPAL_NAME, testPrincipal.getName()); - ace.setProperty(REP_PRIVILEGES, ImmutableList.of(JCR_READ), Type.NAMES); + ace.setProperty(REP_PRIVILEGES, List.of(JCR_READ), Type.NAMES); QueryEngine qe = mockQueryEngine(ace); when(r.getQueryEngine()).thenReturn(qe); @@ -1766,7 +1765,7 @@ public void testEffectivePolicyWrongPrimaryType() throws Exception { Tree aclWithWrongType = TreeUtil.addChild(testTree, REP_POLICY, NT_OAK_UNSTRUCTURED); Tree ace = TreeUtil.addChild(aclWithWrongType, "ace", NT_REP_GRANT_ACE); ace.setProperty(REP_PRINCIPAL_NAME, testPrincipal.getName()); - ace.setProperty(REP_PRIVILEGES, ImmutableList.of(JCR_READ), Type.NAMES); + ace.setProperty(REP_PRIVILEGES, List.of(JCR_READ), Type.NAMES); QueryEngine qe = mockQueryEngine(ace); when(r.getQueryEngine()).thenReturn(qe); @@ -1778,7 +1777,7 @@ public void testEffectivePolicyWrongPrimaryType() throws Exception { private static QueryEngine mockQueryEngine(@NotNull Tree aceTree) throws Exception { ResultRow row = when(mock(ResultRow.class).getTree(null)).thenReturn(aceTree).getMock(); - Iterable rows = ImmutableList.of(row); + Iterable rows = List.of(row); Result res = mock(Result.class); when(res.getRows()).thenReturn(rows).getMock(); QueryEngine qe = mock(QueryEngine.class); @@ -1795,7 +1794,7 @@ public void testEffectivePolicyFailingQuery() throws Exception { Tree testTree = r.getTree(testPath); Tree ace = TreeUtil.addChild(testTree, "ace", NT_REP_GRANT_ACE); ace.setProperty(REP_PRINCIPAL_NAME, testPrincipal.getName()); - ace.setProperty(REP_PRIVILEGES, ImmutableList.of(JCR_READ), Type.NAMES); + ace.setProperty(REP_PRIVILEGES, List.of(JCR_READ), Type.NAMES); QueryEngine qe = mock(QueryEngine.class); when(qe.executeQuery(anyString(), anyString(), any(Map.class), any(Map.class))).thenThrow(new ParseException("test", 0)); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerLimitedPermissionsTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerLimitedPermissionsTest.java index 4513f5be4c0..075ea823aad 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerLimitedPermissionsTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlManagerLimitedPermissionsTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.accesscontrol; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; @@ -339,7 +338,7 @@ public void testGetApplicablePolicies() throws Exception { root.commit(); testRoot.refresh(); - List principals = ImmutableList.of(testPrincipal, EveryonePrincipal.getInstance()); + List principals = List.of(testPrincipal, EveryonePrincipal.getInstance()); for (Principal principal : principals) { // testRoot can't read access control content -> doesn't see // the existing policies and creates a new applicable policy. @@ -359,7 +358,7 @@ public void testGetPolicies() throws Exception { testRoot.refresh(); PrincipalManager testPrincipalMgr = getPrincipalManager(testRoot); - List principals = ImmutableList.of(testPrincipal, EveryonePrincipal.getInstance()); + List principals = List.of(testPrincipal, EveryonePrincipal.getInstance()); for (Principal principal : principals) { if (testPrincipalMgr.hasPrincipal(principal.getName())) { // testRoot can't read access control content -> doesn't see @@ -419,7 +418,7 @@ public void testGetEffectivePoliciesWithoutPrivilege() throws Exception { testRoot.refresh(); - List paths = ImmutableList.of(testPath, NodeTypeConstants.NODE_TYPES_PATH); + List paths = List.of(testPath, NodeTypeConstants.NODE_TYPES_PATH); for (String path : paths) { assertFalse(testAcMgr.hasPrivileges(path, privilegesFromNames(PrivilegeConstants.JCR_READ_ACCESS_CONTROL))); try { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlValidatorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlValidatorTest.java index 221488a86cd..50d72c9016b 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlValidatorTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/AccessControlValidatorTest.java @@ -16,8 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.accesscontrol; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; @@ -63,7 +61,9 @@ import javax.jcr.ValueFactory; import javax.jcr.security.AccessControlManager; import java.security.Principal; +import java.util.Arrays; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.Set; @@ -148,7 +148,7 @@ private Validator createRootValidator(@NotNull Tree rootTree) { @NotNull private Tree createPolicy(@NotNull Tree tree, boolean createRestrictionNode) throws AccessDeniedException { - tree.setProperty(JCR_MIXINTYPES, ImmutableList.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); + tree.setProperty(JCR_MIXINTYPES, List.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); Tree acl = TreeUtil.addChild(tree, REP_POLICY, NT_REP_ACL); acl.setOrderableChildren(true); @@ -163,7 +163,7 @@ private Tree createPolicy(@NotNull Tree tree, boolean createRestrictionNode) thr private static Tree createACE(@NotNull Tree acl, @NotNull String aceName, @NotNull String ntName, @NotNull String principalName, @NotNull String... privilegeNames) throws AccessDeniedException { Tree ace = TreeUtil.addChild(acl, aceName, ntName); ace.setProperty(REP_PRINCIPAL_NAME, principalName); - ace.setProperty(REP_PRIVILEGES, ImmutableList.copyOf(privilegeNames), Type.NAMES); + ace.setProperty(REP_PRIVILEGES, Arrays.asList(privilegeNames), Type.NAMES); return ace; } @@ -176,7 +176,7 @@ private static CommitFailedException assertCommitFailedException(@NotNull Commit @Test(expected = CommitFailedException.class) public void testPolicyWithOutChildOrder() throws Exception { Tree testRoot = getTestTree(); - testRoot.setProperty(JCR_MIXINTYPES, ImmutableList.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); + testRoot.setProperty(JCR_MIXINTYPES, List.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); TreeUtil.addChild(testRoot, REP_POLICY, NT_REP_ACL); try { @@ -189,7 +189,7 @@ public void testPolicyWithOutChildOrder() throws Exception { @Test(expected = CommitFailedException.class) public void testOnlyRootIsRepoAccessControllable() throws Exception { Tree testRoot = getTestTree(); - testRoot.setProperty(JCR_MIXINTYPES, ImmutableList.of(MIX_REP_REPO_ACCESS_CONTROLLABLE), Type.NAMES); + testRoot.setProperty(JCR_MIXINTYPES, List.of(MIX_REP_REPO_ACCESS_CONTROLLABLE), Type.NAMES); try { root.commit(); @@ -201,7 +201,7 @@ public void testOnlyRootIsRepoAccessControllable() throws Exception { @Test(expected = CommitFailedException.class) public void testAddInvalidRepoPolicy() throws Exception { Tree testRoot = getTestTree(); - testRoot.setProperty(JCR_MIXINTYPES, ImmutableList.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); + testRoot.setProperty(JCR_MIXINTYPES, List.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); TreeUtil.addChild(testRoot, REP_REPO_POLICY, NT_REP_ACL); try { root.commit(); @@ -439,7 +439,7 @@ public void testDuplicateAceWithRestrictions() throws Exception { Tree ace = createDuplicateAceTree(); Tree rest = TreeUtil.addChild(ace, REP_RESTRICTIONS, NT_REP_RESTRICTIONS); rest.setProperty(AccessControlConstants.REP_GLOB, "some/glob", Type.STRING); - rest.setProperty(AccessControlConstants.REP_GLOBS, ImmutableList.of("glob1", "glob2"), Type.STRINGS); + rest.setProperty(AccessControlConstants.REP_GLOBS, List.of("glob1", "glob2"), Type.STRINGS); try { root.commit(); @@ -455,7 +455,7 @@ public void testDuplicateAceWithRestrictions() throws Exception { Tree policy = root.getTree(testPath + "/rep:policy"); Tree ace = TreeUtil.addChild(policy, "duplicateAce", NT_REP_GRANT_ACE); ace.setProperty(REP_PRINCIPAL_NAME, testPrincipal.getName()); - ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_ADD_CHILD_NODES), Type.NAMES); + ace.setProperty(AccessControlConstants.REP_PRIVILEGES, List.of(PrivilegeConstants.JCR_ADD_CHILD_NODES), Type.NAMES); return ace; } @@ -606,7 +606,7 @@ public void testRestrictionsUsedByOtherModule2() throws Exception { @Test(expected = CommitFailedException.class) public void testAddPolicyTreeWithInvalidName() throws Exception { Tree rootTree = root.getTree(PathUtils.ROOT_PATH); - rootTree.setProperty(JCR_MIXINTYPES, ImmutableList.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); + rootTree.setProperty(JCR_MIXINTYPES, List.of(MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES); TreeUtil.addChild(rootTree, "invalidName", NT_REP_ACL); Validator v = createRootValidator(rootTree); @@ -622,7 +622,7 @@ public void testAddEntyWithEmptyPrivileges() throws Exception { Tree rootTree = root.getTree(PathUtils.ROOT_PATH); Tree policy = createPolicy(rootTree, false); Tree entry = policy.getChild(aceName); - entry.setProperty(REP_PRIVILEGES, ImmutableList.of(), Type.NAMES); + entry.setProperty(REP_PRIVILEGES, List.of(), Type.NAMES); Validator v = createRootValidator(rootTree); try { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/RemappedPrivilegeNamesTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/RemappedPrivilegeNamesTest.java index b65918f9750..ea60f63ddfa 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/RemappedPrivilegeNamesTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/accesscontrol/RemappedPrivilegeNamesTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.accesscontrol; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.namepath.NamePathMapper; @@ -90,6 +89,6 @@ public void testWriteEntryWithJcrPrivilegeName() throws Exception { getAccessControlManager(root).setPolicy(acl.getPath(), acl); Tree aceTree = root.getTree(acl.getPath()).getChild(REP_POLICY).getChildren().iterator().next(); Iterable privNames = TreeUtil.getNames(aceTree, PrivilegeConstants.REP_PRIVILEGES); - assertTrue(Iterables.elementsEqual(ImmutableList.of(PrivilegeConstants.JCR_READ), privNames)); + assertTrue(Iterables.elementsEqual(List.of(PrivilegeConstants.JCR_READ), privNames)); } } \ No newline at end of file diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/AbstractCompositeProviderTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/AbstractCompositeProviderTest.java index b19cd3bbeb3..b0a34290e6f 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/AbstractCompositeProviderTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/AbstractCompositeProviderTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.composite; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.JackrabbitSession; @@ -47,6 +46,7 @@ import javax.jcr.Session; import javax.jcr.security.AccessControlManager; import java.security.Principal; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -70,8 +70,8 @@ public abstract class AbstractCompositeProviderTest extends AbstractSecurityTest static final String TEST_PATH_2 = "/test2"; - static final List NODE_PATHS = ImmutableList.of(ROOT_PATH, TEST_PATH, TEST_PATH_2, TEST_CHILD_PATH, TEST_A_PATH, TEST_A_B_PATH, TEST_A_B_C_PATH, TEST_A_B2_PATH); - static final List TP_PATHS = ImmutableList.of(ROOT_PATH, TEST_PATH, TEST_A_PATH, TEST_A_B_PATH, TEST_A_B_C_PATH, TEST_A_B_C_PATH + "/nonexisting"); + static final List NODE_PATHS = List.of(ROOT_PATH, TEST_PATH, TEST_PATH_2, TEST_CHILD_PATH, TEST_A_PATH, TEST_A_B_PATH, TEST_A_B_C_PATH, TEST_A_B2_PATH); + static final List TP_PATHS = List.of(ROOT_PATH, TEST_PATH, TEST_A_PATH, TEST_A_B_PATH, TEST_A_B_C_PATH, TEST_A_B_C_PATH + "/nonexisting"); static final PropertyState PROPERTY_STATE = PropertyStates.createProperty("propName", "val"); @@ -239,14 +239,13 @@ boolean reverseOrder() { List getAggregatedProviders(@NotNull String workspaceName, @NotNull AuthorizationConfiguration config, @NotNull Set principals) { - ImmutableList l = ImmutableList.of( + List l = new ArrayList<>(List.of( (AggregatedPermissionProvider) config.getPermissionProvider(root, workspaceName, principals), - getTestPermissionProvider()); + getTestPermissionProvider())); if (reverseOrder()) { - return l.reverse(); - } else { - return l; + Collections.reverse(l); } + return l; } CompositePermissionProvider createPermissionProvider(Principal... principals) { @@ -573,7 +572,7 @@ public void testGetTreePermissionInstanceOR() throws Exception { @Test public void testTreePermissionGetChild() throws Exception { - List childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting"); + List childNames = List.of("test", "a", "b", "c", "nonexisting"); Tree rootTree = readOnlyRoot.getTree(ROOT_PATH); NodeState ns = getTreeProvider().asNodeState(rootTree); @@ -588,7 +587,7 @@ public void testTreePermissionGetChild() throws Exception { @Test public void testTreePermissionGetChildOR() throws Exception { - List childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting"); + List childNames = List.of("test", "a", "b", "c", "nonexisting"); Tree rootTree = readOnlyRoot.getTree(ROOT_PATH); NodeState ns = getTreeProvider().asNodeState(rootTree); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeAccessControlManagerTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeAccessControlManagerTest.java index ae9cab531ae..58db5f7f823 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeAccessControlManagerTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeAccessControlManagerTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.composite; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.JcrConstants; @@ -45,6 +44,7 @@ import javax.jcr.security.AccessControlPolicyIterator; import javax.jcr.security.Privilege; import java.security.Principal; +import java.util.Arrays; import java.util.Collections; import java.util.Set; @@ -101,7 +101,7 @@ private CompositeAccessControlManager createComposite(@NotNull AccessControlMana @NotNull private CompositeAccessControlManager createComposite(@NotNull AggregationFilter aggregationFilter, @NotNull AccessControlManager... acMgrs) { - return new CompositeAccessControlManager(root, NamePathMapper.DEFAULT, getSecurityProvider(), ImmutableList.copyOf(acMgrs), aggregationFilter); + return new CompositeAccessControlManager(root, NamePathMapper.DEFAULT, getSecurityProvider(), Arrays.asList(acMgrs), aggregationFilter); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositePermissionProviderOrTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositePermissionProviderOrTest.java index 28951c63d4a..11fbf672a5a 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositePermissionProviderOrTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositePermissionProviderOrTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.composite; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; @@ -98,7 +97,7 @@ private CompositePermissionProvider createPermissionProviderOR(Set pr String workspaceName = root.getContentSession().getWorkspaceName(); AuthorizationConfiguration config = getConfig(AuthorizationConfiguration.class); - ImmutableList l = ImmutableList.of( + List l = List.of( (AggregatedPermissionProvider) config.getPermissionProvider(root, workspaceName, principals), new ReadNodeGrantedInSupportedTree()); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCoverageTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCoverageTest.java index 601deece305..6883858d48f 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCoverageTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCoverageTest.java @@ -21,7 +21,6 @@ import java.util.Set; import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.oak.api.PropertyState; @@ -79,7 +78,7 @@ AggregatedPermissionProvider getTestPermissionProvider() { @Override List getAggregatedProviders(@NotNull String workspaceName, @NotNull AuthorizationConfiguration config, @NotNull Set principals) { - return ImmutableList.of(getTestPermissionProvider()); + return List.of(getTestPermissionProvider()); } @Override @@ -111,7 +110,7 @@ public void testGetTreePermissionInstanceOR() throws Exception { @Override @Test public void testTreePermissionGetChild() throws Exception { - List childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting"); + List childNames = List.of("test", "a", "b", "c", "nonexisting"); Tree rootTree = readOnlyRoot.getTree(ROOT_PATH); NodeState ns = getTreeProvider().asNodeState(rootTree); @@ -127,7 +126,7 @@ public void testTreePermissionGetChild() throws Exception { @Override @Test public void testTreePermissionGetChildOR() throws Exception { - List childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting"); + List childNames = List.of("test", "a", "b", "c", "nonexisting"); Tree rootTree = readOnlyRoot.getTree(ROOT_PATH); NodeState ns = getTreeProvider().asNodeState(rootTree); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCustomMixTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCustomMixTest.java index 1121e41e619..68ecb4d0f01 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCustomMixTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderCustomMixTest.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; + import org.apache.jackrabbit.guava.common.collect.Sets; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.oak.AbstractSecurityTest; @@ -232,7 +232,7 @@ private CompositePermissionProvider buildCpp(Set supported1, Set AggregatedPermissionProvider a2 = new CustomProvider(root, supported2, granted2, grantMap); AuthorizationConfiguration config = getConfig(AuthorizationConfiguration.class); - List composite = ImmutableList.of(a1, a2); + List composite = List.of(a1, a2); return CompositePermissionProvider.create(root, composite, config.getContext(), type, getRootProvider(), getTreeProvider()); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderFullScopeTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderFullScopeTest.java index ead95d6ab8b..a47cd60d615 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderFullScopeTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderFullScopeTest.java @@ -16,13 +16,13 @@ */ package org.apache.jackrabbit.oak.security.authorization.composite; +import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PathUtils; @@ -226,7 +226,7 @@ public void testIsGrantedAction() throws Exception { for (String p : defActionsGranted.keySet()) { String[] actions = defActionsGranted.get(p); - if (ImmutableList.copyOf(actions).contains(Session.ACTION_READ)) { + if (Arrays.asList(actions).contains(Session.ACTION_READ)) { TreeLocation tl = TreeLocation.create(readOnlyRoot, p); assertEquals(p, tl.getTree() != null, cppTestUser.isGranted(p, Session.ACTION_READ)); } else { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderGetTreePermissionTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderGetTreePermissionTest.java index 001bc1993b9..e326e7486d3 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderGetTreePermissionTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderGetTreePermissionTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.composite; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Tree; @@ -31,6 +30,8 @@ import org.jetbrains.annotations.NotNull; import org.junit.Test; +import java.util.Arrays; + import static org.apache.jackrabbit.oak.security.authorization.composite.CompositeAuthorizationConfiguration.CompositionType.AND; import static org.apache.jackrabbit.oak.security.authorization.composite.CompositeAuthorizationConfiguration.CompositionType.OR; import static org.junit.Assert.assertSame; @@ -47,7 +48,7 @@ public class CompositeProviderGetTreePermissionTest extends AbstractSecurityTest private CompositePermissionProvider createProvider(@NotNull CompositeAuthorizationConfiguration.CompositionType compositionType, @NotNull AggregatedPermissionProvider... providers) { - return CompositePermissionProvider.create(root, ImmutableList.copyOf(providers), Context.DEFAULT, compositionType, getRootProvider(), getTreeProvider()); + return CompositePermissionProvider.create(root, Arrays.asList(providers), Context.DEFAULT, compositionType, getRootProvider(), getTreeProvider()); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderNoScopeTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderNoScopeTest.java index 5e71f87e761..def4c75b671 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderNoScopeTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderNoScopeTest.java @@ -24,7 +24,6 @@ import java.util.Set; import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.oak.api.ContentSession; import org.apache.jackrabbit.oak.api.Tree; @@ -119,7 +118,7 @@ public void testGetTreePermissionInstanceOR() { @Override @Test public void testTreePermissionGetChild() { - List childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting"); + List childNames = List.of("test", "a", "b", "c", "nonexisting"); Tree rootTree = readOnlyRoot.getTree(ROOT_PATH); NodeState ns = getTreeProvider().asNodeState(rootTree); @@ -136,7 +135,7 @@ public void testTreePermissionGetChild() { @Override @Test public void testTreePermissionGetChildOR() { - List childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting"); + List childNames = List.of("test", "a", "b", "c", "nonexisting"); Tree rootTree = readOnlyRoot.getTree(ROOT_PATH); NodeState ns = getTreeProvider().asNodeState(rootTree); @@ -453,7 +452,7 @@ public void testTreePermissionSize() throws Exception { TreePermission tp = cppTestUser.getTreePermission(rootTree, TreePermission.EMPTY); assertEquals(2, ((TreePermission[]) tpField.get(tp)).length); - List childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting"); + List childNames = List.of("test", "a", "b", "c", "nonexisting"); for (String cName : childNames) { ns = ns.getChildNode(cName); tp = tp.getChildPermission(cName, ns); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderScopeTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderScopeTest.java index 69f1518d3a9..1cdb7c7800d 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderScopeTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderScopeTest.java @@ -23,7 +23,6 @@ import java.util.Set; import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PathUtils; @@ -72,7 +71,7 @@ */ public class CompositeProviderScopeTest extends AbstractCompositeProviderTest { - private static List PATH_OUTSIDE_SCOPE = ImmutableList.of(ROOT_PATH, TEST_PATH, TEST_CHILD_PATH); + private static List PATH_OUTSIDE_SCOPE = List.of(ROOT_PATH, TEST_PATH, TEST_CHILD_PATH); private CompositePermissionProvider cppTestUser; private CompositePermissionProvider cppAdminUser; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderSupportedTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderSupportedTest.java index e3db40fd88c..4100e4ecc98 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderSupportedTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/composite/CompositeProviderSupportedTest.java @@ -16,7 +16,8 @@ */ package org.apache.jackrabbit.oak.security.authorization.composite; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import java.util.Arrays; + import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; @@ -89,7 +90,7 @@ public void before() throws Exception { } private CompositePermissionProvider createProvider(@NotNull CompositeAuthorizationConfiguration.CompositionType compositionType, @NotNull AggregatedPermissionProvider... aggregated) { - return CompositePermissionProvider.create(root, ImmutableList.copyOf(aggregated), Context.DEFAULT, compositionType, getRootProvider(), getTreeProvider()); + return CompositePermissionProvider.create(root, Arrays.asList(aggregated), Context.DEFAULT, compositionType, getRootProvider(), getTreeProvider()); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/ChildOrderPropertyTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/ChildOrderPropertyTest.java index f017dcf4d04..d53620e243b 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/ChildOrderPropertyTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/ChildOrderPropertyTest.java @@ -24,7 +24,6 @@ import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; @@ -98,7 +97,7 @@ public void testChildOrderWithoutPropertyReadAccess() throws Exception { // verify that properties cannot be read: assertFalse(aTree.hasProperty(JcrConstants.JCR_PRIMARYTYPE)); - List expected = ImmutableList.of("/a/bb", "/a/b"); + List expected = List.of("/a/bb", "/a/b"); Iterable childPaths = Iterables.transform(aTree.getChildren(), input -> input.getPath()); assertTrue(childPaths.toString(), Iterables.elementsEqual(expected, childPaths)); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/RootTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/RootTest.java index 3b2cb05b146..fee48b3b4cc 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/RootTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/RootTest.java @@ -18,7 +18,6 @@ import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; @@ -44,7 +43,7 @@ public void testGetTree() throws Exception { Root testRoot = getTestRoot(); - List accessible = ImmutableList.of("/", "/a", "/a/b", "/a/b/c"); + List accessible = List.of("/", "/a", "/a/b", "/a/b/c"); for (String path : accessible) { assertTrue(testRoot.getTree(path).exists()); } @@ -60,12 +59,12 @@ public void testGetTree2() throws Exception { Root testRoot = getTestRoot(); - List notAccessible = ImmutableList.of("/", "/a/b"); + List notAccessible = List.of("/", "/a/b"); for (String path : notAccessible) { assertFalse(path, testRoot.getTree(path).exists()); } - List accessible = ImmutableList.of("/a", "/a/bb", "/a/b/c"); + List accessible = List.of("/a", "/a/bb", "/a/b/c"); for (String path : accessible) { assertTrue(path, testRoot.getTree(path).exists()); } @@ -79,7 +78,7 @@ public void testGetNodeLocation() throws Exception { Root testRoot = getTestRoot(); - List accessible = ImmutableList.of("/", "/a", "/a/b", "/a/b/c"); + List accessible = List.of("/", "/a", "/a/b", "/a/b/c"); for (String path : accessible) { Tree tree = testRoot.getTree(path); assertNotNull(tree); @@ -99,14 +98,14 @@ public void testGetNodeLocation2() throws Exception { Root testRoot = getTestRoot(); - List notAccessible = ImmutableList.of("/", "/a/b"); + List notAccessible = List.of("/", "/a/b"); for (String path : notAccessible) { Tree tree = testRoot.getTree(path); assertNotNull(path, tree); assertFalse(tree.exists()); } - List accessible = ImmutableList.of("/a", "/a/bb", "/a/b/c"); + List accessible = List.of("/a", "/a/bb", "/a/b/c"); for (String path : accessible) { Tree tree = testRoot.getTree(path); assertNotNull(path, tree); @@ -121,7 +120,7 @@ public void testGetNodeLocation3() throws Exception { Root testRoot = getTestRoot(); - List notAccessible = ImmutableList.of("/", "/a", "/a/b", "/a/bb", "/a/b/c"); + List notAccessible = List.of("/", "/a", "/a/b", "/a/bb", "/a/b/c"); for (String path : notAccessible) { Tree tree = testRoot.getTree(path); assertNotNull(path, tree); @@ -135,14 +134,14 @@ public void testGetPropertyLocation() throws Exception { Root testRoot = getTestRoot(); - List accessible = ImmutableList.of("/", "/a", "/a/b", "/a/bb", "/a/b/c"); + List accessible = List.of("/", "/a", "/a/b", "/a/bb", "/a/b/c"); for (String path : accessible) { String propertyPath = PathUtils.concat(path, JcrConstants.JCR_PRIMARYTYPE); PropertyState property = testRoot.getTree(path).getProperty(JcrConstants.JCR_PRIMARYTYPE); assertNotNull(propertyPath, property); } - List propPaths = ImmutableList.of("/a/aProp", "/a/b/bProp", "/a/bb/bbProp", "/a/b/c/cProp"); + List propPaths = List.of("/a/aProp", "/a/b/bProp", "/a/bb/bbProp", "/a/b/c/cProp"); for (String path : propPaths) { PropertyState property = testRoot.getTree(PathUtils.getParentPath(path)).getProperty(PathUtils.getName(path)); assertNotNull(path, property); @@ -155,14 +154,14 @@ public void testGetPropertyLocation2() throws Exception { Root testRoot = getTestRoot(); - List accessible = ImmutableList.of("/", "/a", "/a/b", "/a/bb", "/a/b/c"); + List accessible = List.of("/", "/a", "/a/b", "/a/bb", "/a/b/c"); for (String path : accessible) { String propertyPath = PathUtils.concat(path, JcrConstants.JCR_PRIMARYTYPE); PropertyState property = testRoot.getTree(path).getProperty(JcrConstants.JCR_PRIMARYTYPE); assertNotNull(propertyPath, property); } - List propPaths = ImmutableList.of("/a/aProp", "/a/b/bProp", "/a/bb/bbProp", "/a/b/c/cProp"); + List propPaths = List.of("/a/aProp", "/a/b/bProp", "/a/bb/bbProp", "/a/b/c/cProp"); for (String path : propPaths) { PropertyState property = testRoot.getTree(PathUtils.getParentPath(path)).getProperty(PathUtils.getName(path)); assertNotNull(path, property); @@ -177,13 +176,13 @@ public void testGetPropertyLocation3() throws Exception { Root testRoot = getTestRoot(); - List accessible = ImmutableList.of("/a/aProp", "/a/bb/bbProp", "/a/b/c/cProp"); + List accessible = List.of("/a/aProp", "/a/bb/bbProp", "/a/b/c/cProp"); for (String path : accessible) { PropertyState property = testRoot.getTree(PathUtils.getParentPath(path)).getProperty(PathUtils.getName(path)); assertNotNull(path, property); } - List notAccessible = ImmutableList.of("/jcr:primaryType", "/a/b/bProp"); + List notAccessible = List.of("/jcr:primaryType", "/a/b/bProp"); for (String path : notAccessible) { PropertyState property = testRoot.getTree(PathUtils.getParentPath(path)).getProperty(PathUtils.getName(path)); assertNull(path, property); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java index b7e2b7a03f7..893eef1b536 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/TreeTest.java @@ -25,7 +25,6 @@ import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; @@ -101,7 +100,7 @@ public void testGetChildrenCount() throws Exception { assertEquals(cntA - 1, testRoot.getTree("/a").getChildrenCount(Long.MAX_VALUE)); // for the following nodes the cnt must not differ - List paths = ImmutableList.of("/a/b", "/a/b/c"); + List paths = List.of("/a/b", "/a/b/c"); for (String path : paths) { assertEquals( root.getTree(path).getChildrenCount(Long.MAX_VALUE), diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiffTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiffTest.java index 0db13cbfbb3..c83a1871647 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiffTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ChildOrderDiffTest.java @@ -16,13 +16,14 @@ */ package org.apache.jackrabbit.oak.security.authorization.permission; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; import org.jetbrains.annotations.NotNull; import org.junit.Test; +import java.util.Arrays; + import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -30,7 +31,7 @@ public class ChildOrderDiffTest { @NotNull private static PropertyState createPropertyState(@NotNull String... names) { - return PropertyStates.createProperty("any", ImmutableList.copyOf(names), Type.NAMES); + return PropertyStates.createProperty("any", Arrays.asList(names), Type.NAMES); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidatorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidatorTest.java index ab97d1076d7..77e3316bf9c 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidatorTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidatorTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.permission; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; @@ -47,6 +46,7 @@ import javax.jcr.security.AccessControlManager; import java.security.Principal; +import java.util.List; import java.util.Set; import static org.apache.jackrabbit.JcrConstants.JCR_CREATED; @@ -276,7 +276,7 @@ public void testChangePrimaryTypeToPolicyNode() throws Exception { Root testRoot = testSession.getLatestRoot(); Tree testChild = testRoot.getTree(TEST_CHILD_PATH); - testChild.setProperty(PropertyStates.createProperty(JcrConstants.JCR_MIXINTYPES, ImmutableList.of(AccessControlConstants.MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES)); + testChild.setProperty(PropertyStates.createProperty(JcrConstants.JCR_MIXINTYPES, List.of(AccessControlConstants.MIX_REP_ACCESS_CONTROLLABLE), Type.NAMES)); Tree testPolicy = testChild.getChild(AccessControlConstants.REP_POLICY); testPolicy.setOrderableChildren(true); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/VersionablePathHookTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/VersionablePathHookTest.java index 22ad256a77d..92f68bbfec5 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/VersionablePathHookTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/VersionablePathHookTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.permission; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; @@ -36,6 +35,7 @@ import org.junit.Test; import java.util.Collections; +import java.util.List; import static org.apache.jackrabbit.JcrConstants.JCR_UUID; import static org.apache.jackrabbit.JcrConstants.JCR_VERSIONHISTORY; @@ -76,7 +76,7 @@ public boolean exists() { @Override public @NotNull Iterable getProperties() { - return ImmutableList.of(PropertyStates.createProperty(JCR_VERSIONHISTORY, "someValue")); + return List.of(PropertyStates.createProperty(JCR_VERSIONHISTORY, "someValue")); } @Override diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/CompositeRestrictionProviderTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/CompositeRestrictionProviderTest.java index d685423124b..4d09827ea2c 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/CompositeRestrictionProviderTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/CompositeRestrictionProviderTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.restriction; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Tree; @@ -39,6 +38,7 @@ import javax.jcr.ValueFactory; import javax.jcr.security.AccessControlException; +import java.util.List; import java.util.Map; import java.util.Set; @@ -94,11 +94,11 @@ public void after() throws Exception { public void testReadRestrictions() throws Exception { Tree aceNode = TreeUtil.addChild(root.getTree("/"), "test", NT_REP_GRANT_ACE); aceNode.setProperty("boolean", true); - aceNode.setProperty(PropertyStates.createProperty("longs", ImmutableList.of(vf.createValue(10), vf.createValue(290)))); + aceNode.setProperty(PropertyStates.createProperty("longs", List.of(vf.createValue(10), vf.createValue(290)))); aceNode.setProperty(REP_GLOB, "*"); aceNode.setProperty(REP_NT_NAMES, Set.of(), Type.NAMES); // empty array aceNode.setProperty("invalid", "val"); - aceNode.setProperty("invalid2", ImmutableList.of("val1", "val2", "val3"), Type.STRINGS); + aceNode.setProperty("invalid2", List.of("val1", "val2", "val3"), Type.STRINGS); Set restrictions = provider.readRestrictions("/test", aceNode); assertEquals(4, restrictions.size()); @@ -138,9 +138,9 @@ public void testValidateRestrictions() throws Exception { Tree aceNode = TreeUtil.addChild(root.getTree("/"), "test", NT_REP_GRANT_ACE); Tree rNode = TreeUtil.addChild(aceNode, REP_RESTRICTIONS, NT_REP_RESTRICTIONS); rNode.setProperty("boolean", true); - rNode.setProperty(PropertyStates.createProperty("longs", ImmutableList.of(vf.createValue(10), vf.createValue(290)))); + rNode.setProperty(PropertyStates.createProperty("longs", List.of(vf.createValue(10), vf.createValue(290)))); rNode.setProperty(REP_GLOB, "*"); - rNode.setProperty(REP_NT_NAMES, ImmutableList.of(), Type.NAMES); // empty array + rNode.setProperty(REP_NT_NAMES, List.of(), Type.NAMES); // empty array provider.validateRestrictions("/test", aceNode); @@ -164,7 +164,7 @@ public void testValidateRestrictions() throws Exception { rNode.setProperty("boolean", true); } - rNode.setProperty(REP_GLOB, ImmutableList.of("*", "/jcr:content"), Type.STRINGS); + rNode.setProperty(REP_GLOB, List.of("*", "/jcr:content"), Type.STRINGS); try { provider.validateRestrictions("/test", aceNode); fail("validation should detect wrong restriction type (multi vs single valued)"); @@ -177,9 +177,9 @@ public void testValidateRestrictions() throws Exception { public void testValidateRestrictionsAtEntryNode() throws Exception { Tree aceNode = TreeUtil.addChild(root.getTree("/"), "test", NT_REP_GRANT_ACE); aceNode.setProperty("boolean", true); - aceNode.setProperty(PropertyStates.createProperty("longs", ImmutableList.of(vf.createValue(10), vf.createValue(290)))); + aceNode.setProperty(PropertyStates.createProperty("longs", List.of(vf.createValue(10), vf.createValue(290)))); aceNode.setProperty(REP_GLOB, "*"); - aceNode.setProperty(REP_NT_NAMES, ImmutableList.of(), Type.NAMES); // empty array + aceNode.setProperty(REP_NT_NAMES, List.of(), Type.NAMES); // empty array provider.validateRestrictions("/test", aceNode); } @@ -190,7 +190,7 @@ public void testValidateInvalidRestrictionDef() throws Exception { Tree aceNode = TreeUtil.addChild(root.getTree("/"), "test", NT_REP_GRANT_ACE); Tree rNode = TreeUtil.addChild(aceNode, REP_RESTRICTIONS, NT_REP_RESTRICTIONS); - rNode.setProperty(PropertyStates.createProperty("longs", ImmutableList.of(vf.createValue(10), vf.createValue(290)))); + rNode.setProperty(PropertyStates.createProperty("longs", List.of(vf.createValue(10), vf.createValue(290)))); try { rp.validateRestrictions("/test", aceNode); @@ -225,7 +225,7 @@ public void testGetRestrictionPattern() throws Exception { assertFalse(provider.getPattern("/test", aceNode) instanceof CompositePattern); rNode.setProperty("boolean", true); - rNode.setProperty(PropertyStates.createProperty("longs", ImmutableList.of(vf.createValue(10), vf.createValue(290)))); + rNode.setProperty(PropertyStates.createProperty("longs", List.of(vf.createValue(10), vf.createValue(290)))); assertTrue(provider.getPattern("/test", rNode) instanceof CompositePattern); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/CurrentPatternTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/CurrentPatternTest.java index 93606f012f6..141885ca658 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/CurrentPatternTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/CurrentPatternTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.restriction; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; @@ -148,7 +147,7 @@ public void testMatchesTreePropertyPropertyNames() { @Test public void testMatchesPath() { - List propNames = ImmutableList.of(new String[0], new String[]{RESIDUAL_NAME}, new String[] {PROP_NAME}); + List propNames = List.of(new String[0], new String[]{RESIDUAL_NAME}, new String[] {PROP_NAME}); for (String[] pn : propNames) { RestrictionPattern rp = createPattern(pn); assertTrue(rp.matches(TEST_PATH)); @@ -172,7 +171,7 @@ public void testMatchesPathPointsToKnownProperty() { } // pattern with * or all propnames will match - List propNames = ImmutableList.of(new String[]{RESIDUAL_NAME}, knownPropertyNames); + List propNames = List.of(new String[]{RESIDUAL_NAME}, knownPropertyNames); for (String[] names : propNames) { rp = createPattern(names); for (String pn : knownPropertyNames) { @@ -205,7 +204,7 @@ public void testMatchesPathPointsToKnownNode() { } // pattern with * or all node-names will NOT match because they point to items that are known to be nodes - List propNames = ImmutableList.of(new String[]{RESIDUAL_NAME}, knownNodeNames); + List propNames = List.of(new String[]{RESIDUAL_NAME}, knownNodeNames); for (String[] names : propNames) { rp = createPattern(names); for (String pn : knownNodeNames) { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/ItemNamePatternTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/ItemNamePatternTest.java index e7211674d94..cc3e4fd0e87 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/ItemNamePatternTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/ItemNamePatternTest.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.commons.PathUtils; @@ -53,7 +52,7 @@ private static Tree addTree(@NotNull Tree parent, @NotNull String relPath) throw public void testMatchesItem() throws Exception { Tree rootTree = root.getTree("/"); - List matching = ImmutableList.of("a", "b", "c", "d/e/a", "a/b/c/d/b", "test/c"); + List matching = List.of("a", "b", "c", "d/e/a", "a/b/c/d/b", "test/c"); for (String relPath : matching) { Tree testTree = addTree(rootTree, relPath); @@ -64,7 +63,7 @@ public void testMatchesItem() throws Exception { testTree.remove(); } - List notMatching = ImmutableList.of("d", "b/d", "d/e/f", "c/b/abc"); + List notMatching = List.of("d", "b/d", "d/e/f", "c/b/abc"); for (String relPath : notMatching) { Tree testTree = addTree(rootTree, relPath); @@ -78,12 +77,12 @@ public void testMatchesItem() throws Exception { @Test public void testMatchesPath() { - List matching = ImmutableList.of("/a", "/b", "/c", "/d/e/a", "/a/b/c/d/b", "/test/c"); + List matching = List.of("/a", "/b", "/c", "/d/e/a", "/a/b/c/d/b", "/test/c"); for (String p : matching) { assertTrue(pattern.matches(p)); } - List notMatching = ImmutableList.of("/", "/d", "/b/d", "/d/e/f", "/c/b/abc"); + List notMatching = List.of("/", "/d", "/b/d", "/d/e/f", "/c/b/abc"); for (String p : notMatching) { assertFalse(pattern.matches(p)); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/ItemNameRestrictionTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/ItemNameRestrictionTest.java index 95478f462c8..5837faa6723 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/ItemNameRestrictionTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/ItemNameRestrictionTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.restriction; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.user.Group; @@ -71,12 +70,12 @@ boolean addEntry(@NotNull JackrabbitAccessControlList acl) throws RepositoryExce public void testRead() { Root testRoot = testSession.getLatestRoot(); - List visible = ImmutableList.of("/a", "/a/d/b", "/a/d/b/e/c"); + List visible = List.of("/a", "/a/d/b", "/a/d/b/e/c"); for (String p : visible) { assertTrue(testRoot.getTree(p).exists()); } - List invisible = ImmutableList.of("/", "/a/d", "/a/d/b/e", "/a/d/b/e/c/f"); + List invisible = List.of("/", "/a/d", "/a/d/b/e", "/a/d/b/e/c/f"); for (String p : invisible) { assertFalse(testRoot.getTree(p).exists()); } @@ -91,7 +90,7 @@ public void testRead() { public void testAddProperty() throws Exception { Root testRoot = testSession.getLatestRoot(); - List paths = ImmutableList.of("/a", "/a/d/b", "/a/d/b/e/c"); + List paths = List.of("/a", "/a/d/b", "/a/d/b/e/c"); for (String p : paths) { Tree t = testRoot.getTree(p); t.setProperty("b", "anyvalue"); @@ -132,7 +131,7 @@ public void testModifyProperty() throws Exception { public void testAddChild() throws Exception { Root testRoot = testSession.getLatestRoot(); - List paths = ImmutableList.of("/a", "/a/d/b", "/a/d/b/e/c"); + List paths = List.of("/a", "/a/d/b", "/a/d/b/e/c"); for (String p : paths) { Tree t = testRoot.getTree(p); TreeUtil.addChild(t, "c", NodeTypeConstants.NT_OAK_UNSTRUCTURED); @@ -143,7 +142,7 @@ public void testAddChild() throws Exception { @Test public void testRemoveTree() { Root testRoot = testSession.getLatestRoot(); - List paths = ImmutableList.of("/a/d/b/e/c", "/a/d/b", "/a"); + List paths = List.of("/a/d/b/e/c", "/a/d/b", "/a"); for (String p : paths) { try { testRoot.getTree(p).remove(); @@ -169,7 +168,7 @@ public void testRemoveTree2() throws Exception { root.commit(); Root testRoot = testSession.getLatestRoot(); - List paths = ImmutableList.of("/a/d/b/e/c", "/a/d/b"); + List paths = List.of("/a/d/b/e/c", "/a/d/b"); for (String p : paths) { testRoot.getTree(p).remove(); testRoot.commit(); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/NodeTypePatternTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/NodeTypePatternTest.java index 5d2ef62d1d8..5144efa7f04 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/NodeTypePatternTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/NodeTypePatternTest.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Tree; @@ -58,7 +57,7 @@ public void testMatchesItem() throws Exception { public void testNotMatchesItem() throws Exception { Tree rootTree = root.getTree("/"); - List notMatching = ImmutableList.of(NodeTypeConstants.NT_OAK_RESOURCE, NodeTypeConstants.NT_OAK_UNSTRUCTURED, JcrConstants.NT_VERSION); + List notMatching = List.of(NodeTypeConstants.NT_OAK_RESOURCE, NodeTypeConstants.NT_OAK_UNSTRUCTURED, JcrConstants.NT_VERSION); for (String ntName : notMatching) { Tree testTree = TreeUtil.addChild(rootTree, "name", ntName); @@ -72,7 +71,7 @@ public void testNotMatchesItem() throws Exception { @Test public void testMatchesPath() { - List notMatching = ImmutableList.of("/", "/a", "/b", "/c", "/d/e/a", "/a/b/c/d/b", "/test/c", "/d", "/b/d", "/d/e/f", "/c/b/abc"); + List notMatching = List.of("/", "/a", "/b", "/c", "/d/e/a", "/a/b/c/d/b", "/test/c", "/d", "/b/d", "/d/e/f", "/c/b/abc"); for (String p : notMatching) { assertFalse(pattern.matches(p)); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/PrefixPatternTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/PrefixPatternTest.java index 06f5074dc4b..a1c38d0e9a4 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/PrefixPatternTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/PrefixPatternTest.java @@ -20,7 +20,6 @@ import java.util.Set; import javax.jcr.NamespaceRegistry; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Tree; @@ -55,7 +54,7 @@ public void testMatchesItem() throws Exception { testTree.remove(); } - List notMatching = ImmutableList.of(NamespaceRegistry.PREFIX_EMPTY, NamespaceRegistry.PREFIX_MIX, "any"); + List notMatching = List.of(NamespaceRegistry.PREFIX_EMPTY, NamespaceRegistry.PREFIX_MIX, "any"); for (String prefix : notMatching) { String name = (prefix.isEmpty()) ? "name" : prefix + ":name"; Tree testTree = TreeUtil.addChild(rootTree, name, NodeTypeConstants.NT_OAK_UNSTRUCTURED); @@ -71,7 +70,7 @@ public void testMatchesItem() throws Exception { @Test public void testMatchesPath() { - List notMatching = ImmutableList.of("/", "/a", "/d/jcr:e/a"); + List notMatching = List.of("/", "/a", "/d/jcr:e/a"); for (String p : notMatching) { assertFalse(p, pattern.matches(p)); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/RestrictionProviderImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/RestrictionProviderImplTest.java index 021bc46d969..4221ac4b921 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/RestrictionProviderImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/restriction/RestrictionProviderImplTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.authorization.restriction; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; @@ -132,7 +131,7 @@ public void testGetSupportedDefinitions() { public void testGetRestrictionPattern() throws Exception { Map map = new HashMap<>(); map.put(PropertyStates.createProperty(REP_GLOB, "/*/jcr:content"), GlobPattern.create("/testPath", "/*/jcr:content")); - List ntNames = ImmutableList.of(JcrConstants.NT_FOLDER, JcrConstants.NT_LINKEDFILE); + List ntNames = List.of(JcrConstants.NT_FOLDER, JcrConstants.NT_LINKEDFILE); map.put(PropertyStates.createProperty(REP_NT_NAMES, ntNames, Type.NAMES), new NodeTypePattern(ntNames)); Tree tree = TreeUtil.getOrAddChild(root.getTree("/"), "testPath", JcrConstants.NT_UNSTRUCTURED); @@ -161,17 +160,17 @@ public void testGetPatternForAllSupported() throws Exception { Map map = new HashMap<>(); String globRestriction = "/*/jcr:content"; map.put(PropertyStates.createProperty(REP_GLOB, globRestriction), GlobPattern.create("/testPath", globRestriction)); - List ntNames = ImmutableList.of(JcrConstants.NT_FOLDER, JcrConstants.NT_LINKEDFILE); + List ntNames = List.of(JcrConstants.NT_FOLDER, JcrConstants.NT_LINKEDFILE); map.put(PropertyStates.createProperty(REP_NT_NAMES, ntNames, Type.NAMES), new NodeTypePattern(ntNames)); - List prefixes = ImmutableList.of("rep", "jcr"); + List prefixes = List.of("rep", "jcr"); map.put(PropertyStates.createProperty(REP_PREFIXES, prefixes, Type.STRINGS), new PrefixPattern(prefixes)); - List itemNames = ImmutableList.of("abc", "jcr:primaryType"); + List itemNames = List.of("abc", "jcr:primaryType"); map.put(PropertyStates.createProperty(REP_ITEM_NAMES, prefixes, Type.NAMES), new ItemNamePattern(itemNames)); - List propNames = ImmutableList.of("jcr:mixinTypes", "jcr:primaryType"); + List propNames = List.of("jcr:mixinTypes", "jcr:primaryType"); map.put(PropertyStates.createProperty(REP_CURRENT, propNames, Type.STRINGS), new CurrentPattern("/testPath", propNames)); List globs = Collections.singletonList(globRestriction); map.put(PropertyStates.createProperty(REP_GLOBS, globs, Type.STRINGS), new GlobsPattern("/testPath", globs)); - List subtrees = ImmutableList.of("/sub/tree", "/a/b/c/"); + List subtrees = List.of("/sub/tree", "/a/b/c/"); map.put(PropertyStates.createProperty(REP_SUBTREES, subtrees, Type.STRINGS), new SubtreePattern("/testPath", subtrees)); Tree tree = TreeUtil.getOrAddChild(root.getTree("/"), "testPath", JcrConstants.NT_UNSTRUCTURED); @@ -191,22 +190,22 @@ public void testGetPatternFromRestrictions() throws Exception { Map map = new HashMap<>(); map.put(PropertyStates.createProperty(REP_GLOB, globRestriction), GlobPattern.create("/testPath", globRestriction)); - List ntNames = ImmutableList.of(JcrConstants.NT_FOLDER, JcrConstants.NT_LINKEDFILE); + List ntNames = List.of(JcrConstants.NT_FOLDER, JcrConstants.NT_LINKEDFILE); map.put(PropertyStates.createProperty(REP_NT_NAMES, ntNames, Type.NAMES), new NodeTypePattern(ntNames)); - List prefixes = ImmutableList.of("rep", "jcr"); + List prefixes = List.of("rep", "jcr"); map.put(PropertyStates.createProperty(REP_PREFIXES, prefixes, Type.STRINGS), new PrefixPattern(prefixes)); - List itemNames = ImmutableList.of("abc", "jcr:primaryType"); + List itemNames = List.of("abc", "jcr:primaryType"); map.put(PropertyStates.createProperty(REP_ITEM_NAMES, itemNames, Type.NAMES), new ItemNamePattern(itemNames)); - List propNames = ImmutableList.of("*"); + List propNames = List.of("*"); map.put(PropertyStates.createProperty(REP_CURRENT, propNames, Type.STRINGS), new CurrentPattern("/testPath", propNames)); List globs = Collections.singletonList(globRestriction); map.put(PropertyStates.createProperty(REP_GLOBS, globs, Type.STRINGS), new GlobsPattern("/testPath", globs)); - List subtrees = ImmutableList.of("/sub/tree", "/a/b/c/"); + List subtrees = List.of("/sub/tree", "/a/b/c/"); map.put(PropertyStates.createProperty(REP_SUBTREES, subtrees, Type.STRINGS), new SubtreePattern("/testPath", subtrees)); Tree tree = TreeUtil.getOrAddChild(root.getTree("/"), "testPath", JcrConstants.NT_UNSTRUCTURED); @@ -259,7 +258,7 @@ public void testValidateGlobRestriction() throws Exception { AccessControlManager acMgr = getAccessControlManager(root); - List globs = ImmutableList.of( + List globs = List.of( "/1*/2*/3*/4*/5*/6*/7*/8*/9*/10*/11*/12*/13*/14*/15*/16*/17*/18*/19*/20*/21*", "*********************"); for (String glob : globs) { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/internal/SecurityProviderRegistrationTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/internal/SecurityProviderRegistrationTest.java index 723c552a005..0d3b5b2282f 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/internal/SecurityProviderRegistrationTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/internal/SecurityProviderRegistrationTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.internal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager; import org.apache.jackrabbit.oak.AbstractSecurityTest; @@ -887,7 +886,7 @@ private void testMultipleServiceWithRanking(@NotNull String fieldName, @NotNull SortedMap m = (SortedMap) f.get(registration); assertEquals(3, m.size()); Collection c = m.values(); - assertTrue(Iterables.elementsEqual(ImmutableList.of(service2, service3, service1), c)); + assertTrue(Iterables.elementsEqual(List.of(service2, service3, service1), c)); } @Test @@ -1105,7 +1104,7 @@ public void testRegisterWithMonitors() { assertNull(context.getService(SecurityProvider.class)); AuthorizationConfiguration mockConfiguration = mockConfiguration(AuthorizationConfiguration.class); - when(mockConfiguration.getMonitors(any(StatisticsProvider.class))).thenReturn(ImmutableList.of(new TestMonitor())); + when(mockConfiguration.getMonitors(any(StatisticsProvider.class))).thenReturn(List.of(new TestMonitor())); registration.bindAuthorizationConfiguration(mockConfiguration, Collections.singletonMap(SERVICE_PID, "customAuthorizationConfig")); SecurityProvider service = context.getService(SecurityProvider.class); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/principal/PrincipalConfigurationImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/principal/PrincipalConfigurationImplTest.java index f983f8cacc9..5115a6b24c1 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/principal/PrincipalConfigurationImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/principal/PrincipalConfigurationImplTest.java @@ -16,7 +16,8 @@ */ package org.apache.jackrabbit.oak.security.principal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import java.util.List; + import org.apache.jackrabbit.api.security.principal.PrincipalManager; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Root; @@ -128,7 +129,7 @@ public ConfigurationParameters getParameters(@Nullable String name) { @NotNull @Override public Iterable getConfigurations() { - return ImmutableList.of(); + return List.of(); } @NotNull diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHookTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHookTest.java index 42dd60c8f54..21170954a85 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHookTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/JcrAllCommitHookTest.java @@ -16,10 +16,10 @@ */ package org.apache.jackrabbit.oak.security.privilege; +import java.util.List; import java.util.Set; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Root; @@ -107,7 +107,7 @@ public void testJcrAllNodeAlreadyContainsNewName() { Root r = adminSession.getLatestRoot(); Tree t = r.getTree(PRIVILEGES_PATH); Tree jcrAll = t.getChild(JCR_ALL); - jcrAll.setProperty(REP_AGGREGATES, ImmutableList.of("newPriv"), Type.NAMES); + jcrAll.setProperty(REP_AGGREGATES, List.of("newPriv"), Type.NAMES); t.addChild("newPriv"); NodeState after = getTreeProvider().asNodeState(r.getTree(PathUtils.ROOT_PATH)); hook.processCommit(before, after, null); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeContextTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeContextTest.java index 746b3f9c21e..1fbeb1bcc8a 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeContextTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeContextTest.java @@ -17,7 +17,7 @@ package org.apache.jackrabbit.oak.security.privilege; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; + import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; @@ -123,7 +123,7 @@ public void testNotDefinesTree() { @Test public void testDefinesLocation() { - List paths = ImmutableList.of( + List paths = List.of( PrivilegeConstants.PRIVILEGES_PATH, PrivilegeConstants.PRIVILEGES_PATH + "/child", PrivilegeConstants.PRIVILEGES_PATH + "/another/child" @@ -139,7 +139,7 @@ public void testDefinesLocation() { @Test public void testNotDefinesLocation() { - List paths = ImmutableList.of( + List paths = List.of( PathUtils.ROOT_PATH, PrivilegeConstants.PRIVILEGES_PATH + "sibling", "/some/other/path", diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeImplTest.java index ddae8eba7b9..4d171217758 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeImplTest.java @@ -16,10 +16,10 @@ */ package org.apache.jackrabbit.oak.security.privilege; +import java.util.List; import java.util.Set; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; @@ -164,7 +164,7 @@ public void testToString() { public void testInvalidDeclaredAggregate() throws Exception { Tree privilegeDefs = root.getTree(PRIVILEGES_PATH); Tree privDef = TreeUtil.addChild(privilegeDefs, "test", NT_REP_PRIVILEGE); - privDef.setProperty(REP_AGGREGATES, ImmutableList.of(JCR_READ, "invalid"), Type.NAMES); + privDef.setProperty(REP_AGGREGATES, List.of(JCR_READ, "invalid"), Type.NAMES); Privilege p = getPrivilegeManager(root).getPrivilege("test"); assertAggregation(p.getDeclaredAggregatePrivileges(), JCR_READ); @@ -174,7 +174,7 @@ public void testInvalidDeclaredAggregate() throws Exception { public void testCyclicDeclaredAggregate() throws Exception { Tree privilegeDefs = root.getTree(PRIVILEGES_PATH); Tree privDef = TreeUtil.addChild(privilegeDefs, "test", NT_REP_PRIVILEGE); - privDef.setProperty(REP_AGGREGATES, ImmutableList.of(JCR_READ, "test"), Type.NAMES); + privDef.setProperty(REP_AGGREGATES, List.of(JCR_READ, "test"), Type.NAMES); Privilege p = getPrivilegeManager(root).getPrivilege("test"); assertAggregation(p.getDeclaredAggregatePrivileges(), JCR_READ); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidatorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidatorTest.java index d3b4a621724..73ab423ce8c 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidatorTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidatorTest.java @@ -17,7 +17,8 @@ package org.apache.jackrabbit.oak.security.privilege; import java.util.Collections; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import java.util.List; + import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.CommitFailedException; @@ -128,7 +129,7 @@ public void testBitsConflictWithAggregation() throws Exception { try { Tree privTree = createPrivilegeTree("test"); privTree.setProperty(PropertyStates.createProperty(REP_AGGREGATES, - ImmutableList.of(JCR_READ, JCR_MODIFY_PROPERTIES), Type.NAMES)); + List.of(JCR_READ, JCR_MODIFY_PROPERTIES), Type.NAMES)); setPrivilegeBits(privTree, REP_BITS, 340); root.commit(); @@ -210,7 +211,7 @@ public void testChildNodeChangedWithoutChanges() throws CommitFailedException { public void testAggregatesIncludesJcrAll() throws Exception { try { Tree privTree = createPrivilegeTree("test"); - privTree.setProperty(PropertyStates.createProperty(REP_AGGREGATES, ImmutableList.of(JCR_ALL, JCR_READ, JCR_WRITE), Type.NAMES)); + privTree.setProperty(PropertyStates.createProperty(REP_AGGREGATES, List.of(JCR_ALL, JCR_READ, JCR_WRITE), Type.NAMES)); PrivilegeBits.getInstance(bitsProvider.getBits(JCR_ALL, JCR_READ, JCR_WRITE)).writeTo(privTree); root.commit(); @@ -223,7 +224,7 @@ public void testAggregatesIncludesJcrAll() throws Exception { public void testAggregatesMatchesExisting() throws Exception { try { Tree privTree = createPrivilegeTree("test"); - privTree.setProperty(PropertyStates.createProperty(REP_AGGREGATES, ImmutableList.of(REP_READ_NODES, REP_READ_PROPERTIES), Type.NAMES)); + privTree.setProperty(PropertyStates.createProperty(REP_AGGREGATES, List.of(REP_READ_NODES, REP_READ_PROPERTIES), Type.NAMES)); PrivilegeBits.getInstance(bitsProvider.getBits(REP_READ_NODES, REP_READ_PROPERTIES)).writeTo(privTree); root.commit(); @@ -235,8 +236,8 @@ public void testAggregatesMatchesExisting() throws Exception { @Test(expected = CommitFailedException.class) public void testPropertyChanged() throws Exception { try { - PropertyState before = PropertyStates.createProperty(REP_AGGREGATES, ImmutableList.of(REP_READ_NODES, REP_READ_PROPERTIES), Type.NAMES); - PropertyState after = PropertyStates.createProperty(REP_AGGREGATES, ImmutableList.of(REP_READ_NODES), Type.NAMES); + PropertyState before = PropertyStates.createProperty(REP_AGGREGATES, List.of(REP_READ_NODES, REP_READ_PROPERTIES), Type.NAMES); + PropertyState after = PropertyStates.createProperty(REP_AGGREGATES, List.of(REP_READ_NODES), Type.NAMES); PrivilegeValidator validator = new PrivilegeValidator(root, root, getTreeProvider()); validator.propertyChanged(before, after); @@ -248,7 +249,7 @@ public void testPropertyChanged() throws Exception { @Test(expected = CommitFailedException.class) public void testPropertyDeleted() throws Exception { try { - PropertyState before = PropertyStates.createProperty(REP_AGGREGATES, ImmutableList.of(REP_READ_NODES, REP_READ_PROPERTIES), Type.NAMES); + PropertyState before = PropertyStates.createProperty(REP_AGGREGATES, List.of(REP_READ_NODES, REP_READ_PROPERTIES), Type.NAMES); PrivilegeValidator validator = new PrivilegeValidator(root, root, getTreeProvider()); validator.propertyDeleted(before); @@ -287,7 +288,7 @@ public void testUnknownAggregate() throws Exception { NodeState newDef = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE) .setProperty(JCR_PRIMARYTYPE, NT_REP_PRIVILEGE) .setProperty(REP_BITS, 8) - .setProperty(REP_AGGREGATES, ImmutableList.of("unknown", JCR_READ), Type.NAMES) + .setProperty(REP_AGGREGATES, List.of("unknown", JCR_READ), Type.NAMES) .getNodeState(); PrivilegeValidator validator = createPrivilegeValidator(); @@ -305,7 +306,7 @@ public void testCircularAggregate() throws Exception { NodeState newDef = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE) .setProperty(JCR_PRIMARYTYPE, NT_REP_PRIVILEGE) .setProperty(REP_BITS, 8) - .setProperty(REP_AGGREGATES, ImmutableList.of("test", JCR_READ), Type.NAMES) + .setProperty(REP_AGGREGATES, List.of("test", JCR_READ), Type.NAMES) .getNodeState(); PrivilegeValidator validator = createPrivilegeValidator(); @@ -324,7 +325,7 @@ public void testCircularAggregate2() throws Exception { NodeState newDef = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE) .setProperty(JCR_PRIMARYTYPE, NT_REP_PRIVILEGE) .setProperty(REP_BITS, 8) - .setProperty(REP_AGGREGATES, ImmutableList.of("test2", JCR_READ), Type.NAMES) + .setProperty(REP_AGGREGATES, List.of("test2", JCR_READ), Type.NAMES) .getNodeState(); PrivilegeValidator validator = createPrivilegeValidator(); @@ -343,7 +344,7 @@ public void testInvalidAggregation() throws Exception { Tree privDefs = root.getTree(PRIVILEGES_PATH); Tree newPriv = TreeUtil.addChild(privDefs, "newPriv", NT_REP_PRIVILEGE); PrivilegeBits.getInstance(PrivilegeBits.BUILT_IN.get(JCR_READ), PrivilegeBits.BUILT_IN.get(JCR_ADD_CHILD_NODES)).writeTo(newPriv); - newPriv.setProperty(REP_AGGREGATES, ImmutableList.of(JCR_READ, JCR_ADD_CHILD_NODES), Type.NAMES); + newPriv.setProperty(REP_AGGREGATES, List.of(JCR_READ, JCR_ADD_CHILD_NODES), Type.NAMES); TreeProvider tp = mock(TreeProvider.class); when(tp.createReadOnlyTree(any(Tree.class), anyString(), any(NodeState.class))).thenReturn(newPriv); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AbstractGroupPrincipalTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AbstractGroupPrincipalTest.java index fa6b8123f33..b07ed1eee0c 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AbstractGroupPrincipalTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AbstractGroupPrincipalTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; @@ -87,7 +86,7 @@ public void testIsMemberOf() throws Exception { @Test public void testIsMemberMissingAuthorizable() { - List principals = ImmutableList.of( + List principals = List.of( new PrincipalImpl("name"), () -> "name" ); @@ -108,7 +107,7 @@ public void testIsMemberOfEveryone() throws Exception { @Test public void testIsMemberOfEveryoneMissingAuthorizable() { - List principals = ImmutableList.of( + List principals = List.of( new PrincipalImpl("name"), () -> "name" ); @@ -188,7 +187,7 @@ boolean isMember(@NotNull Authorizable authorizable) throws RepositoryException @NotNull @Override Iterator getMembers() throws RepositoryException { - return ImmutableList.of(member).iterator(); + return List.of(member).iterator(); } } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AddMembersByIdBestEffortTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AddMembersByIdBestEffortTest.java index c4c16a85137..df8b6b14bcd 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AddMembersByIdBestEffortTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AddMembersByIdBestEffortTest.java @@ -17,11 +17,11 @@ package org.apache.jackrabbit.oak.security.user; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.user.Authorizable; @@ -110,7 +110,7 @@ public void testNonExistingMember() throws Exception { assertTrue(failed.isEmpty()); Iterable memberIds = getMemberIds(testGroup); - Iterables.elementsEqual(ImmutableList.copyOf(NON_EXISTING_IDS), memberIds); + Iterables.elementsEqual(Arrays.asList(NON_EXISTING_IDS), memberIds); Iterator members = testGroup.getDeclaredMembers(); assertFalse(members.hasNext()); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AuthorizableIteratorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AuthorizableIteratorTest.java index 0484a939a4d..ac965482b11 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AuthorizableIteratorTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AuthorizableIteratorTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.User; @@ -100,7 +99,7 @@ public void testInvalidPath() { @Test public void testFilterDuplicates() throws Exception { - List l = ImmutableList.of(getTestUser()); + List l = List.of(getTestUser()); assertEquals(1, Iterators.size(AuthorizableIterator.create(true, l.iterator(), l.iterator()))); assertEquals(2, Iterators.size(AuthorizableIterator.create(false, l.iterator(), l.iterator()))); @@ -119,7 +118,7 @@ public void testFilterDuplicatesHandlesNull() throws Exception { public void testFilterDuplicatesGetIdFails() throws Exception { Authorizable a = when(mock(Authorizable.class).getID()).thenThrow(new RepositoryException()).getMock(); - List l = ImmutableList.of(getTestUser(), a); + List l = List.of(getTestUser(), a); assertEquals(1, Iterators.size(AuthorizableIterator.create(true, l.iterator(), Collections.emptyIterator()))); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/GroupImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/GroupImplTest.java index daa120d8fe7..e88bc84bc4f 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/GroupImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/GroupImplTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; @@ -31,6 +30,7 @@ import javax.jcr.nodetype.ConstraintViolationException; import java.security.Principal; import java.util.Iterator; +import java.util.List; import java.util.UUID; import static org.apache.jackrabbit.oak.spi.security.user.UserConstants.REP_MEMBERS; @@ -165,7 +165,7 @@ public void testGroupPrincipalMembers() throws Exception { @Test public void testImpactOfOak8054AddingMembers() throws Exception { Tree groupTree = root.getTree(group.getPath()); - groupTree.setProperty(REP_MEMBERS, ImmutableList.of(new UserProvider(root, ConfigurationParameters.EMPTY).getContentID(getTestUser().getID())), Type.STRINGS); + groupTree.setProperty(REP_MEMBERS, List.of(new UserProvider(root, ConfigurationParameters.EMPTY).getContentID(getTestUser().getID())), Type.STRINGS); root.commit(); group.addMember(uMgr.createUser("userid", null)); @@ -182,7 +182,7 @@ public void testImpactOfOak8054RemovingMembers() throws Exception { User user = uMgr.createUser("userid", null); UserProvider up = new UserProvider(root, ConfigurationParameters.EMPTY); Tree groupTree = root.getTree(group.getPath()); - groupTree.setProperty(REP_MEMBERS, ImmutableList.of(up.getContentID(getTestUser().getID()), up.getContentID(user.getID())), Type.STRINGS); + groupTree.setProperty(REP_MEMBERS, List.of(up.getContentID(getTestUser().getID()), up.getContentID(user.getID())), Type.STRINGS); root.commit(); group.removeMembers(user.getID()); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/ImpersonationImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/ImpersonationImplTest.java index 2e69715c552..8cc770d5d86 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/ImpersonationImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/ImpersonationImplTest.java @@ -18,13 +18,13 @@ import java.security.Principal; import java.util.Enumeration; +import java.util.List; import java.util.Set; import java.util.UUID; import javax.jcr.RepositoryException; import javax.security.auth.Subject; import org.apache.jackrabbit.api.security.principal.GroupPrincipal; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.api.security.principal.PrincipalIterator; @@ -93,7 +93,7 @@ public void testContentRepresentation() throws Exception { PropertyState property = tree.getProperty(UserConstants.REP_IMPERSONATORS); assertNotNull(property); - assertEquals(ImmutableList.of(impersonator.getPrincipal().getName()), property.getValue(Type.STRINGS)); + assertEquals(List.of(impersonator.getPrincipal().getName()), property.getValue(Type.STRINGS)); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/IntermediatePathTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/IntermediatePathTest.java index e6685bc4b2a..69fb4b94fa3 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/IntermediatePathTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/IntermediatePathTest.java @@ -22,7 +22,6 @@ import javax.jcr.RepositoryException; import javax.jcr.nodetype.ConstraintViolationException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.CommitFailedException; @@ -139,7 +138,7 @@ public void testGroupWrongRoot() throws Exception { @Test public void testInvalidAbsolutePaths() throws Exception { TreeUtil.addChild(root.getTree(PathUtils.ROOT_PATH), "testNode", NodeTypeConstants.NT_OAK_UNSTRUCTURED); - List invalidPaths = ImmutableList.of( + List invalidPaths = List.of( "/", PathUtils.getAncestorPath(UserConstants.DEFAULT_GROUP_PATH, 1), PathUtils.getAncestorPath(UserConstants.DEFAULT_GROUP_PATH, 2), @@ -183,7 +182,7 @@ public void testAbsolutePathsWithInvalidParentElements() throws Exception { @Test public void testRelativePaths() throws Exception { TreeUtil.addChild(root.getTree(PathUtils.ROOT_PATH), "testNode", NodeTypeConstants.NT_OAK_UNSTRUCTURED); - List invalidPaths = ImmutableList.of("..", "../..", "../../..", "../../../testNode","a/b/../../../c"); + List invalidPaths = List.of("..", "../..", "../../..", "../../../testNode","a/b/../../../c"); for (String relPath : invalidPaths) { try { createAuthorizable(false, relPath); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordExpiryHistoryTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordExpiryHistoryTest.java index f7698b6835c..2001c249145 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordExpiryHistoryTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordExpiryHistoryTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; @@ -36,6 +35,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; +import java.util.List; import java.util.Map; /** @@ -57,7 +57,7 @@ protected ConfigurationParameters getSecurityConfigParameters() { pwAction.init(null, ConfigurationParameters.of( PasswordValidationAction.CONSTRAINT, "^.*(?=.{4,}).*" )); - final AuthorizableActionProvider actionProvider = securityProvider -> ImmutableList.of(pwAction); + final AuthorizableActionProvider actionProvider = securityProvider -> List.of(pwAction); ConfigurationParameters userConfig = ConfigurationParameters.of( Map.of( diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordHistoryTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordHistoryTest.java index d2c31065a10..08139e751bf 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordHistoryTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/PasswordHistoryTest.java @@ -24,11 +24,11 @@ import javax.jcr.RepositoryException; import javax.jcr.nodetype.ConstraintViolationException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Tree; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration; import org.apache.jackrabbit.oak.spi.security.user.UserConstants; @@ -62,7 +62,9 @@ protected ConfigurationParameters getSecurityConfigParameters() { @NotNull private List getHistory(@NotNull User user) throws RepositoryException { Iterable history = TreeUtil.getStrings(root.getTree(user.getPath()).getChild(REP_PWD), REP_PWD_HISTORY); - return (history == null) ? Collections.emptyList() : ImmutableList.copyOf(history).reverse(); + List result = history == null ? Collections.emptyList() : CollectionUtils.toList(history); + Collections.reverse(result); + return result; } /** @@ -217,7 +219,7 @@ public void testDisabledPasswordHistory() throws Exception { User user = getTestUser(); Tree userTree = root.getTree(user.getPath()); - List configs = ImmutableList.of( + List configs = List.of( ConfigurationParameters.EMPTY, ConfigurationParameters.of(PARAM_PASSWORD_HISTORY_SIZE, PASSWORD_HISTORY_DISABLED_SIZE), ConfigurationParameters.of(PARAM_PASSWORD_HISTORY_SIZE, -1), diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/SystemUserImplTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/SystemUserImplTest.java index dc7aea0c5f1..b268e6bc350 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/SystemUserImplTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/SystemUserImplTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.api.security.user.UserManager; @@ -49,6 +48,7 @@ import javax.jcr.nodetype.ConstraintViolationException; import javax.security.auth.login.LoginException; import java.util.Iterator; +import java.util.List; import java.util.UUID; import static org.junit.Assert.assertEquals; @@ -95,7 +95,7 @@ protected ConfigurationParameters getSecurityConfigParameters() { ConfigurationParameters.of(UserConstants.PARAM_AUTHORIZABLE_ACTION_PROVIDER, (AuthorizableActionProvider) securityProvider -> { AuthorizableAction action = new AccessControlAction(); action.init(securityProvider, ConfigurationParameters.of(AccessControlAction.USER_PRIVILEGE_NAMES, new String[]{PrivilegeConstants.JCR_ALL})); - return ImmutableList.of(action); + return List.of(action); })); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserContextTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserContextTest.java index 1b9aa5da037..4afdd01266b 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserContextTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserContextTest.java @@ -21,7 +21,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; @@ -225,7 +224,7 @@ public void testPropertyDefinesLocation() { NT_REP_GROUP, GROUP_PROPERTY_NAMES, NT_REP_USER, USER_PROPERTY_NAMES, NT_REP_PASSWORD, PWD_PROPERTY_NAMES, - NT_REP_MEMBER_REFERENCES, ImmutableList.of(REP_MEMBERS) + NT_REP_MEMBER_REFERENCES, List.of(REP_MEMBERS) ); m.forEach((key, value) -> { @@ -302,7 +301,7 @@ public void testNoTreeDefinesLocationIntermediate() { @Test public void testNotDefinesLocation() { - List paths = ImmutableList.of( + List paths = List.of( PathUtils.ROOT_PATH, NodeTypeConstants.NODE_TYPES_PATH, "/content", diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterBaseTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterBaseTest.java index 15a22c7c20c..b91b5a75b92 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterBaseTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterBaseTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.user.User; @@ -65,7 +64,7 @@ public abstract class UserImporterBaseTest extends AbstractSecurityTest implemen @NotNull @Override public List getAuthorizableActions(@NotNull SecurityProvider securityProvider) { - return (testAction == null) ? ImmutableList.of() : ImmutableList.of(testAction); + return (testAction == null) ? List.of() : List.of(testAction); } }; @@ -206,6 +205,6 @@ PropertyDefinition mockPropertyDefinition(@NotNull String declaringNt, boolean m @NotNull NodeInfo createNodeInfo(@NotNull String name, @NotNull String primaryTypeName) { - return new NodeInfo(name, primaryTypeName, ImmutableList.of(), null); + return new NodeInfo(name, primaryTypeName, List.of(), null); } } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterImpersonationIgnoreTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterImpersonationIgnoreTest.java index f8bdae4c430..20e16325f86 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterImpersonationIgnoreTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterImpersonationIgnoreTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.user.User; @@ -34,6 +33,7 @@ import javax.jcr.RepositoryException; import java.security.Principal; +import java.util.List; import java.util.Set; import static org.junit.Assert.assertEquals; @@ -73,7 +73,7 @@ public void testKnownImpersonators() throws Exception { PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); - assertEquals(ImmutableList.of(testUser.getPrincipal().getName()), impersonators.getValue(Type.STRINGS)); + assertEquals(List.of(testUser.getPrincipal().getName()), impersonators.getValue(Type.STRINGS)); } @Test @@ -83,7 +83,7 @@ public void testMixedImpersonators() throws Exception { PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); - assertEquals(ImmutableList.of(testUser.getPrincipal().getName()), impersonators.getValue(Type.STRINGS)); + assertEquals(List.of(testUser.getPrincipal().getName()), impersonators.getValue(Type.STRINGS)); } @Test(expected = RepositoryException.class) @@ -102,19 +102,19 @@ public void testUserConvertedGroupBeforeProcessing() throws Exception { @Test public void testReplaceExistingProperty() throws Exception { - userTree.setProperty(REP_IMPERSONATORS, ImmutableList.of("impersonator1"), Type.STRINGS); + userTree.setProperty(REP_IMPERSONATORS, List.of("impersonator1"), Type.STRINGS); assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS, testUser.getPrincipal().getName()), mockPropertyDefinition(NT_REP_USER, true))); importer.processReferences(); PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); - assertEquals(ImmutableList.of(testUser.getPrincipal().getName()), impersonators.getValue(Type.STRINGS)); + assertEquals(List.of(testUser.getPrincipal().getName()), impersonators.getValue(Type.STRINGS)); } @Test public void testReplaceExistingProperty2() throws Exception { - userTree.setProperty(REP_IMPERSONATORS, ImmutableList.of("impersonator1"), Type.STRINGS); + userTree.setProperty(REP_IMPERSONATORS, List.of("impersonator1"), Type.STRINGS); assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS, "impersonator1", testUser.getPrincipal().getName()), mockPropertyDefinition(NT_REP_USER, true))); importer.processReferences(); @@ -138,7 +138,7 @@ public void testNewImpersonator() throws Exception { PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); - assertEquals(ImmutableList.of("impersonator1"), impersonators.getValue(Type.STRINGS)); + assertEquals(List.of("impersonator1"), impersonators.getValue(Type.STRINGS)); } @Test @@ -156,7 +156,7 @@ public void testNewImpersonator2() throws Exception { PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); - assertEquals(ImmutableList.of("impersonator1"), impersonators.getValue(Type.STRINGS)); + assertEquals(List.of("impersonator1"), impersonators.getValue(Type.STRINGS)); } @Test @@ -176,7 +176,7 @@ public void testRevokeImpersonationAlreadyRemoved() throws Exception { return null; }).when(ua).onRevokeImpersonation(any(User.class), any(Principal.class), any(Root.class), any(NamePathMapper.class)); - userTree.setProperty(REP_IMPERSONATORS, ImmutableList.of("impersonator1"), Type.STRINGS); + userTree.setProperty(REP_IMPERSONATORS, List.of("impersonator1"), Type.STRINGS); assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS), mockPropertyDefinition(NT_REP_USER, true))); importer.processReferences(); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipAbortTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipAbortTest.java index 8d8d22faec5..c4e44304fb8 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipAbortTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipAbortTest.java @@ -18,7 +18,6 @@ import javax.jcr.nodetype.ConstraintViolationException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal; @@ -26,6 +25,8 @@ import org.jetbrains.annotations.NotNull; import org.junit.Test; +import java.util.List; + import static org.junit.Assert.assertTrue; public class UserImporterMembershipAbortTest extends UserImporterMembershipIgnoreTest { @@ -38,13 +39,13 @@ String getImportBehavior() { @Test(expected = ConstraintViolationException.class) public void testUnknownMember() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, unknownContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, unknownContentId))); importer.processReferences(); } @Test(expected = ConstraintViolationException.class) public void testMixedMembers() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, unknownContentId, knownMemberContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, unknownContentId, knownMemberContentId))); importer.processReferences(); } @@ -59,7 +60,7 @@ public void testAddSameAsMember() throws Exception { @Test(expected = ConstraintViolationException.class) public void testNewMembersToEveryone() throws Exception { - groupTree.setProperty(REP_MEMBERS, ImmutableList.of(knownMemberContentId), Type.STRINGS); + groupTree.setProperty(REP_MEMBERS, List.of(knownMemberContentId), Type.STRINGS); groupTree.setProperty(REP_PRINCIPAL_NAME, EveryonePrincipal.NAME); Tree userTree = createUserTree(); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipBesteffortTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipBesteffortTest.java index 324f1f0fa8b..5d7ec9d2795 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipBesteffortTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipBesteffortTest.java @@ -16,11 +16,12 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.xml.ImportBehavior; import org.jetbrains.annotations.NotNull; import org.junit.Test; +import java.util.List; + import static org.junit.Assert.assertTrue; public class UserImporterMembershipBesteffortTest extends UserImporterMembershipIgnoreTest { @@ -33,7 +34,7 @@ String getImportBehavior() { @Test public void testUnknownMember() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, unknownContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, unknownContentId))); importer.processReferences(); assertTrue(groupTree.hasProperty(REP_MEMBERS)); @@ -41,7 +42,7 @@ public void testUnknownMember() throws Exception { @Test public void testMixedMembers() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, unknownContentId, knownMemberContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, unknownContentId, knownMemberContentId))); importer.processReferences(); assertTrue(groupTree.hasProperty(REP_MEMBERS)); diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipIgnoreTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipIgnoreTest.java index d154b00c271..2d062572c1e 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipIgnoreTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterMembershipIgnoreTest.java @@ -21,13 +21,13 @@ import java.util.Set; import javax.jcr.RepositoryException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal; import org.junit.Test; @@ -68,13 +68,13 @@ public void before() throws Exception { @Test(expected = IllegalArgumentException.class) public void testInvalidMemberContentId() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, "memberId"))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, "memberId"))); importer.processReferences(); } @Test public void testUnknownMember() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, unknownContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, unknownContentId))); importer.processReferences(); // default importbehavior == IGNORE @@ -83,7 +83,7 @@ public void testUnknownMember() throws Exception { @Test public void testKnownMemberThresholdNotReached() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); importer.processReferences(); assertTrue(groupTree.hasProperty(REP_MEMBERS)); @@ -97,7 +97,7 @@ public void testKnownMemberThresholdReached() throws Exception { } groupTree.setProperty(REP_MEMBERS, memberIds, Type.STRINGS); - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); importer.processReferences(); assertEquals(1, memberRefList.getChildrenCount(100)); @@ -106,7 +106,7 @@ public void testKnownMemberThresholdReached() throws Exception { @Test public void testMixedMembers() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, unknownContentId, knownMemberContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, unknownContentId, knownMemberContentId))); importer.processReferences(); assertFalse(memberRefList.hasChild("memberRef")); @@ -114,7 +114,7 @@ public void testMixedMembers() throws Exception { @Test(expected = RepositoryException.class) public void testGroupRemovedBeforeProcessing() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); groupTree.remove(); importer.processReferences(); @@ -122,14 +122,14 @@ public void testGroupRemovedBeforeProcessing() throws Exception { @Test(expected = RepositoryException.class) public void testUserConvertedGroupBeforeProcessing() throws Exception { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); groupTree.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_USER); importer.processReferences(); } @Test public void testAddMemberToNonExistingMember() throws Exception { - groupTree.setProperty(REP_MEMBERS, ImmutableList.of(unknownContentId), Type.STRINGS); + groupTree.setProperty(REP_MEMBERS, List.of(unknownContentId), Type.STRINGS); assertTrue(importer.handlePropInfo(groupTree, createPropInfo(REP_MEMBERS, knownMemberContentId), mockPropertyDefinition(NT_REP_GROUP, true))); importer.processReferences(); @@ -145,7 +145,7 @@ public void testAddReplacesExistingMember() throws Exception { String contentId = userProvider.getContentID(userTree); assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_AUTHORIZABLE_ID, TEST_USER_ID), mockPropertyDefinition(NT_REP_AUTHORIZABLE, false))); - groupTree.setProperty(REP_MEMBERS, ImmutableList.of(knownMemberContentId), Type.STRINGS); + groupTree.setProperty(REP_MEMBERS, List.of(knownMemberContentId), Type.STRINGS); assertTrue(importer.handlePropInfo(groupTree, createPropInfo(REP_MEMBERS, contentId), mockPropertyDefinition(NT_REP_GROUP, true))); importer.processReferences(); @@ -165,7 +165,7 @@ public void testNewMembers() throws Exception { PropertyState members = groupTree.getProperty(REP_MEMBERS); assertNotNull(members); - assertEquals(ImmutableList.of(contentId), ImmutableList.copyOf(members.getValue(Type.STRINGS))); + assertEquals(List.of(contentId), CollectionUtils.toList(members.getValue(Type.STRINGS))); } @Test @@ -180,7 +180,7 @@ public void testNewMembers2() throws Exception { PropertyState members = groupTree.getProperty(REP_MEMBERS); assertNotNull(members); - assertEquals(ImmutableList.of(contentId), ImmutableList.copyOf(members.getValue(Type.STRINGS))); + assertEquals(List.of(contentId), CollectionUtils.toList((members.getValue(Type.STRINGS)))); } @Test @@ -197,7 +197,7 @@ public void testAddSameAsMember() throws Exception { @Test public void testNewMembersToEveryone() throws Exception { - groupTree.setProperty(REP_MEMBERS, ImmutableList.of(knownMemberContentId), Type.STRINGS); + groupTree.setProperty(REP_MEMBERS, List.of(knownMemberContentId), Type.STRINGS); groupTree.setProperty(REP_PRINCIPAL_NAME, EveryonePrincipal.NAME); Tree userTree = createUserTree(); @@ -209,7 +209,7 @@ public void testNewMembersToEveryone() throws Exception { PropertyState members = groupTree.getProperty(REP_MEMBERS); assertNotNull(members); - assertEquals(ImmutableList.of(knownMemberContentId), ImmutableList.copyOf(members.getValue(Type.STRINGS))); + assertEquals(List.of(knownMemberContentId), CollectionUtils.toList((members.getValue(Type.STRINGS)))); } @Test @@ -227,6 +227,6 @@ public void testAddExistingMembers() throws Exception { PropertyState members = groupTree.getProperty(REP_MEMBERS); assertNotNull(members); - assertEquals(ImmutableList.of(contentId), ImmutableList.copyOf(members.getValue(Type.STRINGS))); + assertEquals(List.of(contentId), CollectionUtils.toList((members.getValue(Type.STRINGS)))); } } \ No newline at end of file diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterTest.java index abe4b03f790..a8782755da7 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserImporterTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.JackrabbitSession; @@ -52,6 +51,7 @@ import javax.jcr.nodetype.PropertyDefinition; import java.lang.reflect.Field; import java.util.Collections; +import java.util.List; import java.util.Map; import static org.apache.jackrabbit.oak.spi.nodetype.NodeTypeConstants.NT_OAK_UNSTRUCTURED; @@ -625,7 +625,7 @@ public void testStartNonExistingTree() throws Exception { @Test(expected = IllegalStateException.class) public void testStartChildInfoIllegalState() { - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, "member1"))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, "member1"))); } @Test(expected = IllegalStateException.class) @@ -635,7 +635,7 @@ public void testStartChildInfoWithoutValidStart() throws Exception { memberRefList.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_MEMBER_REFERENCES_LIST); importer.start(memberRefList); - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, "member1"))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, "member1"))); } @Test @@ -646,7 +646,7 @@ public void testStartChildInfoWithoutRepMembersProperty() throws Exception { memberRefList.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_MEMBER_REFERENCES_LIST); assertTrue(importer.start(memberRefList)); - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of()); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of()); } @Test @@ -657,7 +657,7 @@ public void testStartChildInfoWithRepMembersProperty() throws Exception { memberRefList.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_MEMBER_REFERENCES_LIST); assertTrue(importer.start(memberRefList)); - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, "member1"))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo(REP_MEMBERS, "member1"))); } @Test @@ -668,7 +668,7 @@ public void testStartChildInfoWithOtherProperty() throws Exception { memberRefList.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_MEMBER_REFERENCES_LIST); importer.start(memberRefList); - importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo("otherName", "member1"))); + importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), List.of(createPropInfo("otherName", "member1"))); importer.processReferences(); // no members should have been added to the group node @@ -684,7 +684,7 @@ public void testStartRepMembersChildInfo() throws Exception { Tree repMembers = groupTree.addChild("memberTree"); repMembers.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_MEMBERS); assertTrue(importer.start(repMembers)); - importer.startChildInfo(createNodeInfo("memberTree", NT_REP_MEMBERS), ImmutableList.of(createPropInfo("anyProp", "memberValue"))); + importer.startChildInfo(createNodeInfo("memberTree", NT_REP_MEMBERS), List.of(createPropInfo("anyProp", "memberValue"))); } @Test @@ -695,7 +695,7 @@ public void testStartOtherChildInfo() throws Exception { memberRefList.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_MEMBER_REFERENCES_LIST); assertTrue(importer.start(memberRefList)); - importer.startChildInfo(createNodeInfo("memberRef", NT_OAK_UNSTRUCTURED), ImmutableList.of(createPropInfo(REP_MEMBERS, "member1"))); + importer.startChildInfo(createNodeInfo("memberRef", NT_OAK_UNSTRUCTURED), List.of(createPropInfo(REP_MEMBERS, "member1"))); } //-------------------------------------------------------< endChildInfo >--- diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/GroupActionTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/GroupActionTest.java index d4c8cd6fd44..302926740e0 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/GroupActionTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/GroupActionTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user.action; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.api.security.user.User; @@ -33,6 +32,7 @@ import org.junit.Test; import java.util.Collections; +import java.util.List; import java.util.Set; import static org.mockito.Mockito.mock; @@ -45,7 +45,7 @@ public class GroupActionTest extends AbstractSecurityTest { private static final String TEST_USER_PREFIX = "testUser"; final GroupAction groupAction = mock(GroupAction.class); - private final AuthorizableActionProvider actionProvider = securityProvider -> ImmutableList.of(groupAction); + private final AuthorizableActionProvider actionProvider = securityProvider -> List.of(groupAction); private User testUser01; private User testUser02; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/PasswordValidationActionTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/PasswordValidationActionTest.java index 0b910ad496b..abba077269e 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/PasswordValidationActionTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/PasswordValidationActionTest.java @@ -16,7 +16,8 @@ */ package org.apache.jackrabbit.oak.security.user.action; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import java.util.List; + import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Type; @@ -44,7 +45,7 @@ public class PasswordValidationActionTest extends AbstractSecurityTest { private final PasswordValidationAction pwAction = new PasswordValidationAction(); private final AuthorizableAction testAction = mock(AuthorizableAction.class); - private final AuthorizableActionProvider actionProvider = securityProvider -> ImmutableList.of(pwAction, testAction); + private final AuthorizableActionProvider actionProvider = securityProvider -> List.of(pwAction, testAction); @Before public void before() throws Exception { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/UserActionTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/UserActionTest.java index bbff8dda1e0..db0b8e61339 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/UserActionTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/action/UserActionTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user.action; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.oak.AbstractSecurityTest; import org.apache.jackrabbit.oak.api.Root; @@ -35,6 +34,7 @@ import javax.jcr.RepositoryException; import javax.jcr.ValueFactory; import java.security.Principal; +import java.util.List; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -50,7 +50,7 @@ public class UserActionTest extends AbstractSecurityTest { private UserAction userAction = mock(UserAction.class); private ClearProfileAction clearProfileAction = new ClearProfileAction(); - private final AuthorizableActionProvider actionProvider = securityProvider -> ImmutableList.of(userAction, clearProfileAction); + private final AuthorizableActionProvider actionProvider = securityProvider -> List.of(userAction, clearProfileAction); @Override protected ConfigurationParameters getSecurityConfigParameters() { diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/QueryUtilTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/QueryUtilTest.java index f95c8d01890..00b7ed2b0f6 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/QueryUtilTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/QueryUtilTest.java @@ -24,7 +24,6 @@ import javax.jcr.RepositoryException; import javax.jcr.Value; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.QueryBuilder; @@ -159,7 +158,7 @@ public void testNodeTypeName() { @Test public void testEscapeNodeName() { - List names = ImmutableList.of("name", JcrConstants.JCR_CREATED, "%name", "a%name", "name%"); + List names = List.of("name", JcrConstants.JCR_CREATED, "%name", "a%name", "name%"); for (String name : names) { assertEquals(QueryUtils.escapeNodeName(name), QueryUtil.escapeNodeName(name)); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/ResultIteratorTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/ResultIteratorTest.java index 6f6c3b4dfdc..0b4b916decc 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/ResultIteratorTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/ResultIteratorTest.java @@ -18,9 +18,9 @@ import java.util.Collections; import java.util.Iterator; +import java.util.List; import java.util.NoSuchElementException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.junit.Test; @@ -37,7 +37,7 @@ public void createWithNegativeOffset() { @Test public void testCreateWithoutLimitation() { - Iterator it = ImmutableList.of("str").iterator(); + Iterator it = List.of("str").iterator(); assertSame(it, ResultIterator.create(ResultIterator.OFFSET_NONE, ResultIterator.MAX_ALL, it)); } @@ -58,22 +58,22 @@ public void testCreateOffsetGtSize() { @Test public void testCreateOffsetLtSize() { - assertEquals(1, Iterators.size(ResultIterator.create(1, ResultIterator.MAX_ALL, ImmutableList.of("str", "str").iterator()))); + assertEquals(1, Iterators.size(ResultIterator.create(1, ResultIterator.MAX_ALL, List.of("str", "str").iterator()))); } @Test public void testCreateOffsetEqualsMax() { - assertEquals(1, Iterators.size(ResultIterator.create(1, 1, ImmutableList.of("str", "str").iterator()))); + assertEquals(1, Iterators.size(ResultIterator.create(1, 1, List.of("str", "str").iterator()))); } @Test public void testCreateOffsetGtMax() { - assertEquals(1, Iterators.size(ResultIterator.create(2, 1, ImmutableList.of("str", "str", "str").iterator()))); + assertEquals(1, Iterators.size(ResultIterator.create(2, 1, List.of("str", "str", "str").iterator()))); } @Test public void testCreateOffsetLtMax() { - Iterator resultIt = ResultIterator.create(1, 3, ImmutableList.of("str", "str", "str", "str").iterator()); + Iterator resultIt = ResultIterator.create(1, 3, List.of("str", "str", "str", "str").iterator()); assertEquals(3, Iterators.size(resultIt)); } @@ -85,7 +85,7 @@ public void testNextNoElements() { @Test public void testNextWithOffset() { - Iterator it = ResultIterator.create(1, ResultIterator.MAX_ALL, ImmutableList.of("str", "str2").iterator()); + Iterator it = ResultIterator.create(1, ResultIterator.MAX_ALL, List.of("str", "str2").iterator()); assertEquals("str2", it.next()); } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManagerTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManagerTest.java index 4af97d30882..1c350b76039 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManagerTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManagerTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.security.user.query; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.user.Authorizable; @@ -28,6 +27,7 @@ import org.apache.jackrabbit.oak.api.ContentSession; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.query.QueryEngineSettings; import org.apache.jackrabbit.oak.security.internal.SecurityProviderBuilder; import org.apache.jackrabbit.oak.security.user.AbstractUserTest; @@ -495,7 +495,7 @@ public void build(@NotNull QueryBuilder builder) { }; Iterator result = queryMgr.findAuthorizables(q); - assertEquals(ImmutableList.of(user, g2, g), ImmutableList.copyOf(result)); + assertEquals(List.of(user, g2, g), CollectionUtils.toList(result)); } @Test @@ -516,7 +516,7 @@ public void build(@NotNull QueryBuilder builder) { }; Iterator result = queryMgr.findAuthorizables(q); - assertEquals(ImmutableList.of(user, g, g2), ImmutableList.copyOf(result)); + assertEquals(List.of(user, g, g2), CollectionUtils.toList(result)); } @Test diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/whiteboard/WhiteboardAuthorizableActionProviderTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/whiteboard/WhiteboardAuthorizableActionProviderTest.java index e46fb2bd27c..e7be81e0e5b 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/whiteboard/WhiteboardAuthorizableActionProviderTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/whiteboard/WhiteboardAuthorizableActionProviderTest.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Map; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.security.SecurityProvider; import org.apache.jackrabbit.oak.spi.security.user.action.AbstractAuthorizableAction; import org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableAction; @@ -64,7 +63,7 @@ public void testStarted() { public void testRegisteredImplementation() { actionProvider.start(whiteboard); - AuthorizableActionProvider registered = securityProvider -> ImmutableList.of(new TestAction()); + AuthorizableActionProvider registered = securityProvider -> List.of(new TestAction()); whiteboard.register(AuthorizableActionProvider.class, registered, Map.of()); List actions = actionProvider.getAuthorizableActions(Mockito.mock(SecurityProvider.class)); diff --git a/oak-doc/src/site/markdown/query/property-index.md b/oak-doc/src/site/markdown/query/property-index.md index 940f7c93458..ebd6b3113fd 100644 --- a/oak-doc/src/site/markdown/query/property-index.md +++ b/oak-doc/src/site/markdown/query/property-index.md @@ -115,7 +115,7 @@ or to simplify you can use one of the existing `IndexUtils#createIndexDefinition { NodeBuilder index = IndexUtils.getOrCreateOakIndex(root); - IndexUtils.createIndexDefinition(index, "myProp", true, false, ImmutableList.of("myProp"), null); + IndexUtils.createIndexDefinition(index, "myProp", true, false, List.of("myProp"), null); } #### Reindexing diff --git a/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/readonly/ReadOnlyAuthorizationConfiguration.java b/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/readonly/ReadOnlyAuthorizationConfiguration.java index e7a5b1510c1..c85c10b41d3 100644 --- a/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/readonly/ReadOnlyAuthorizationConfiguration.java +++ b/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/readonly/ReadOnlyAuthorizationConfiguration.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.exercise.security.authorization.models.readonly; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy; import org.apache.jackrabbit.commons.iterator.AccessControlPolicyIteratorAdapter; import org.apache.jackrabbit.oak.api.PropertyState; @@ -344,25 +343,25 @@ public RepositoryInitializer getRepositoryInitializer() { @NotNull @Override public List getCommitHooks(@NotNull String workspaceName) { - return ImmutableList.of(); + return List.of(); } @NotNull @Override public List getValidators(@NotNull String workspaceName, @NotNull Set principals, @NotNull MoveTracker moveTracker) { - return ImmutableList.of(); + return List.of(); } @NotNull @Override public List getConflictHandlers() { - return ImmutableList.of(); + return List.of(); } @NotNull @Override public List getProtectedItemImporters() { - return ImmutableList.of(); + return List.of(); } @NotNull diff --git a/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/simplifiedroles/ThreeRolesAccessControlManager.java b/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/simplifiedroles/ThreeRolesAccessControlManager.java index 5303484ef61..2a1216c89e6 100644 --- a/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/simplifiedroles/ThreeRolesAccessControlManager.java +++ b/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/simplifiedroles/ThreeRolesAccessControlManager.java @@ -16,6 +16,8 @@ */ package org.apache.jackrabbit.oak.exercise.security.authorization.models.simplifiedroles; +import java.util.List; + import javax.jcr.AccessDeniedException; import javax.jcr.PathNotFoundException; import javax.jcr.RepositoryException; @@ -27,7 +29,6 @@ import javax.jcr.security.Privilege; import javax.jcr.version.VersionException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.commons.iterator.AccessControlPolicyIteratorAdapter; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.spi.security.SecurityProvider; @@ -86,7 +87,7 @@ public AccessControlPolicy[] getEffectivePolicies(String absPath) throws PathNot @Override public AccessControlPolicyIterator getApplicablePolicies(String absPath) throws PathNotFoundException, AccessDeniedException, RepositoryException { // EXERCISE - return new AccessControlPolicyIteratorAdapter(ImmutableList.of()); + return new AccessControlPolicyIteratorAdapter(List.of()); } @Override diff --git a/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/simplifiedroles/ThreeRolesAuthorizationConfiguration.java b/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/simplifiedroles/ThreeRolesAuthorizationConfiguration.java index 0188b15129d..f6be9c8748a 100644 --- a/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/simplifiedroles/ThreeRolesAuthorizationConfiguration.java +++ b/oak-exercise/src/main/java/org/apache/jackrabbit/oak/exercise/security/authorization/models/simplifiedroles/ThreeRolesAuthorizationConfiguration.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.exercise.security.authorization.models.simplifiedroles; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; @@ -168,7 +167,7 @@ public RepositoryInitializer getRepositoryInitializer() { @NotNull @Override public List getValidators(@NotNull String workspaceName, @NotNull Set principals, @NotNull MoveTracker moveTracker) { - return ImmutableList.of(new ValidatorProvider() { + return List.of(new ValidatorProvider() { @Override protected Validator getRootValidator(NodeState before, NodeState after, CommitInfo info) { // EXERCISE: write a validator that meets the following requirements: @@ -188,7 +187,7 @@ protected Validator getRootValidator(NodeState before, NodeState after, CommitIn @Override public List getProtectedItemImporters() { // EXERCISE - return ImmutableList.of(); + return List.of(); } @NotNull diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L4_EffectivePoliciesTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L4_EffectivePoliciesTest.java index d443f0d9247..9583db37a3b 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L4_EffectivePoliciesTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L4_EffectivePoliciesTest.java @@ -27,7 +27,6 @@ import javax.jcr.security.AccessControlPolicy; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager; @@ -270,7 +269,7 @@ public void testSessionGetEffectivePoliciesWithoutPrivilege() throws Exception { testSession = getTestSession(); AccessControlManager testAcMgr = testSession.getAccessControlManager(); - List paths = ImmutableList.of(testRoot, NodeTypeConstants.NODE_TYPES_PATH); + List paths = List.of(testRoot, NodeTypeConstants.NODE_TYPES_PATH); for (String path : paths) { // EXERCISE : complete or fix the test case AccessControlPolicy[] effectivePolicies = testAcMgr.getEffectivePolicies(path); diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L5_AccessControlListImplTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L5_AccessControlListImplTest.java index d4d274e9836..46fc6ed6260 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L5_AccessControlListImplTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/accesscontrol/L5_AccessControlListImplTest.java @@ -17,6 +17,7 @@ package org.apache.jackrabbit.oak.exercise.security.authorization.accesscontrol; import java.security.Principal; +import java.util.Arrays; import java.util.Collections; import java.util.List; import javax.jcr.RepositoryException; @@ -27,7 +28,6 @@ import javax.jcr.security.AccessControlManager; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.JackrabbitWorkspace; import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry; @@ -186,15 +186,16 @@ public void testUpdateAndComplementary() throws Exception { public void testAddEntryWithInvalidPrincipals() throws Exception { // EXERCISE: explain for each principal in the list why using it for an ACE fails - List invalidPrincipals = ImmutableList.of( + List invalidPrincipals = Arrays.asList( new InvalidTestPrincipal("unknown"), null, - new PrincipalImpl(""), new Principal() { - @Override - public String getName() { - return "unknown"; - } - }); + new PrincipalImpl(""), + new Principal() { + @Override + public String getName() { + return "unknown"; + } + }); for (Principal principal : invalidPrincipals) { try { @@ -227,7 +228,7 @@ public void testAddEntryWithInvalidPrivilege() throws Exception { Privilege customPriv = ((JackrabbitWorkspace) superuser.getWorkspace()).getPrivilegeManager().registerPrivilege(privilegeName, true, new String[0]); // EXERCISE : walks through this test and explain why adding those ACEs fails. - List invalidPrivileges = ImmutableList.of( + List invalidPrivileges = Arrays.asList( new Privilege[0], null, new Privilege[] {customPriv} diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/advanced/L5_CustomPermissionEvaluationTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/advanced/L5_CustomPermissionEvaluationTest.java index 35c9d8076ac..314cb402c9e 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/advanced/L5_CustomPermissionEvaluationTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/advanced/L5_CustomPermissionEvaluationTest.java @@ -23,7 +23,6 @@ import javax.jcr.Session; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.JackrabbitSession; @@ -203,8 +202,7 @@ public void before() throws Exception { root.commit(); - trees = ImmutableList.builder().add(root.getTree("/")).add(testTree).add(aTree).add(aaTree).add(bTree).add(bbTree).add(cTree).add(ccTree).build(); - + trees = List.of(root.getTree("/"), testTree, aTree, aaTree, bTree, bbTree, cTree, ccTree); } private PermissionProvider getPermissionProvider(@NotNull Set principals) { @@ -269,7 +267,7 @@ public void testGuestAccess() throws Exception { @Test public void testWriteAccess() throws Exception { - List> editors = ImmutableList.>of( + List> editors = List.of( ImmutableSet.of(new Editor("ida")), ImmutableSet.of(EveryonePrincipal.getInstance(), new Editor("amanda")), ImmutableSet.of(getTestUser().getPrincipal(),new Editor("susi")), @@ -309,7 +307,7 @@ public void testWriteAccess() throws Exception { @Test public void testReadAccess() throws Exception { - List> readers = ImmutableList.>of( + List> readers = List.of( ImmutableSet.of(new Reader("ida")), ImmutableSet.of(EveryonePrincipal.getInstance(), new Reader("fairuz")), ImmutableSet.of(getTestUser().getPrincipal(),new Editor("juni")), diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L3_BuiltInPrivilegesTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L3_BuiltInPrivilegesTest.java index 8e68990fe6f..b0c980ea456 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L3_BuiltInPrivilegesTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L3_BuiltInPrivilegesTest.java @@ -16,6 +16,7 @@ */ package org.apache.jackrabbit.oak.exercise.security.privilege; +import java.util.Arrays; import java.util.Map; import java.util.Set; import javax.jcr.RepositoryException; @@ -23,8 +24,6 @@ import javax.jcr.security.AccessControlPolicy; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; @@ -135,7 +134,7 @@ public void testAggregation() throws RepositoryException { ); Iterable aggregated = Iterables.filter( - ImmutableList.copyOf(privilegeManager.getRegisteredPrivileges()), + Arrays.asList(privilegeManager.getRegisteredPrivileges()), input -> input != null && input.isAggregate()); for (Privilege aggrPrivilege : aggregated) { diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L6_AuthorizableContentTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L6_AuthorizableContentTest.java index 5366a5315de..7724b2f1ecd 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L6_AuthorizableContentTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L6_AuthorizableContentTest.java @@ -20,7 +20,6 @@ import javax.jcr.Node; import javax.jcr.RepositoryException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; @@ -149,7 +148,7 @@ public void testUserNodeType() throws RepositoryException { String expectedNodeTypeName = null; // EXERCISE assertEquals(expectedNodeTypeName, node.getPrimaryNodeType().getName()); - List mixinTypes = ImmutableList.of(); // EXERCISE : fill the list + List mixinTypes = List.of(); // EXERCISE : fill the list for (String mixin : mixinTypes) { assertTrue(node.isNodeType(mixin)); } @@ -174,7 +173,7 @@ public void testGroupNodeType() throws RepositoryException { String expectedNodeTypeName = null; // EXERCISE assertEquals(expectedNodeTypeName, node.getPrimaryNodeType().getName()); - List mixinTypes = ImmutableList.of(); // EXERCISE : fill the list + List mixinTypes = List.of(); // EXERCISE : fill the list for (String mixin : mixinTypes) { assertTrue(node.isNodeType(mixin)); } diff --git a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L7_AuthorizablePropertiesTest.java b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L7_AuthorizablePropertiesTest.java index 1b8ea63c0f5..c1e9f2d2137 100644 --- a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L7_AuthorizablePropertiesTest.java +++ b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L7_AuthorizablePropertiesTest.java @@ -22,7 +22,6 @@ import javax.jcr.RepositoryException; import javax.jcr.Value; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.security.user.Authorizable; @@ -125,7 +124,7 @@ public void testArbitraryProperties() throws RepositoryException { Node node = getAuthorizableNode(testUser); // EXERCISE: build the list of existing user properties rel paths - List userPropertiesPath = ImmutableList.of(); + List userPropertiesPath = List.of(); for (String relPath : userPropertiesPath) { assertTrue(testUser.hasProperty(relPath)); } @@ -139,13 +138,13 @@ public void testArbitraryProperties() throws RepositoryException { assertArrayEquals(petsExpected, node.getProperty(expectedRelPath).getValues()); // EXERCISE: build a list of protected JCR properties that cannot be accessed using the Authorizable interface - List protectedJcrPropertyNames = ImmutableList.of(); + List protectedJcrPropertyNames = List.of(); for (String relPath : protectedJcrPropertyNames) { assertFalse(testUser.hasProperty(relPath)); } // EXERCISE: build a list of protected properties defined by the authorizable or user node type definitions that cannot be accessed using the Authorizable interface - List protectedAuthorizablePropertyNames = ImmutableList.of(); + List protectedAuthorizablePropertyNames = List.of(); for (String relPath : protectedAuthorizablePropertyNames) { assertFalse(testUser.hasProperty(relPath)); } diff --git a/oak-it/src/test/java/org/apache/jackrabbit/oak/api/TreeTest.java b/oak-it/src/test/java/org/apache/jackrabbit/oak/api/TreeTest.java index c4e44bd8585..e4a63f1f9f4 100644 --- a/oak-it/src/test/java/org/apache/jackrabbit/oak/api/TreeTest.java +++ b/oak-it/src/test/java/org/apache/jackrabbit/oak/api/TreeTest.java @@ -28,8 +28,6 @@ import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.OakBaseTest; import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; @@ -60,7 +58,7 @@ public TreeTest(NodeStoreFixture fixture) { public void setUp() { repository = new Oak(store) .with(new OpenSecurityProvider()) - .with(new CompositeConflictHandler(ImmutableList.of( + .with(new CompositeConflictHandler(List.of( ConflictHandlers.wrap(new ChildOrderConflictHandler() { /** * Allow deleting changed node. diff --git a/oak-it/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateClusterTestIT.java b/oak-it/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateClusterTestIT.java index 285dca71927..69908e95b12 100644 --- a/oak-it/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateClusterTestIT.java +++ b/oak-it/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateClusterTestIT.java @@ -53,7 +53,6 @@ import org.junit.Before; import org.junit.Test; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.io.Closer; public class AsyncIndexUpdateClusterTestIT { @@ -65,8 +64,7 @@ public class AsyncIndexUpdateClusterTestIT { private MemoryBlobStore bs; private Random random = new Random(); - private final List values = ImmutableList.of("a", "b", "c", "d", - "e"); + private final List values = List.of("a", "b", "c", "d", "e"); private Closer closer = Closer.create(); private final AtomicBoolean illegalReindex = new AtomicBoolean(false); diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/IndexCostEvaluationTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/IndexCostEvaluationTest.java index c0f43e5b50e..f09e2eb21ba 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/IndexCostEvaluationTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/IndexCostEvaluationTest.java @@ -17,7 +17,6 @@ package org.apache.jackrabbit.oak; import ch.qos.logback.classic.Level; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitRepository; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.oak.commons.junit.LogCustomizer; @@ -113,7 +112,7 @@ private class TestIndexProvider implements QueryIndexProvider { @Override public @NotNull List getQueryIndexes(NodeState nodeState) { - return ImmutableList.of(index); + return List.of(index); } } diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NamePathTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NamePathTest.java index 6224f87d432..38f6fd39d37 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NamePathTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NamePathTest.java @@ -32,8 +32,6 @@ import javax.jcr.RepositoryException; import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver; import org.junit.After; @@ -62,7 +60,7 @@ public void teardown() throws RepositoryException { @Test public void testSlashInPath() throws RepositoryException { - List paths = ImmutableList.of( + List paths = List.of( "//jcr:content", "//content" ); @@ -71,7 +69,7 @@ public void testSlashInPath() throws RepositoryException { @Test public void testSlashInName() throws RepositoryException { - List names = ImmutableList.of( + List names = List.of( "/jcr:content", "/content", "jcr:con/ent", @@ -83,7 +81,7 @@ public void testSlashInName() throws RepositoryException { @Test public void testColonInPath() throws RepositoryException { - List paths = ImmutableList.of( + List paths = List.of( "/jcr:con:ent" ); testPaths(paths); @@ -91,7 +89,7 @@ public void testColonInPath() throws RepositoryException { @Test public void testColonInName() throws RepositoryException { - List names = ImmutableList.of( + List names = List.of( "jcr:con:ent" ); testNames(names); @@ -99,7 +97,7 @@ public void testColonInName() throws RepositoryException { @Test public void testSquareBracketsInPath() throws RepositoryException { - List paths = ImmutableList.of( + List paths = List.of( "//jcr:content", "/jcr:con]ent", "/con]ent" @@ -109,7 +107,7 @@ public void testSquareBracketsInPath() throws RepositoryException { @Test public void testSquareBracketsInName() throws RepositoryException { - List names = ImmutableList.of( + List names = List.of( "jcr:content[1]", "content[1]", "jcr:conten[t]", @@ -135,7 +133,7 @@ public void testSquareBracketsInName() throws RepositoryException { @Test public void testAsteriskInPath() throws RepositoryException { - List paths = ImmutableList.of( + List paths = List.of( "/jcr:con*ent", "/jcr:*ontent", "/jcr:conten*", @@ -148,7 +146,7 @@ public void testAsteriskInPath() throws RepositoryException { @Test public void testAsteriskInName() throws RepositoryException { - List names = ImmutableList.of( + List names = List.of( "jcr:con*ent", "jcr:*ontent", "jcr:conten*", @@ -161,7 +159,7 @@ public void testAsteriskInName() throws RepositoryException { @Test public void testVerticalLineInPath() throws Exception { - List paths = ImmutableList.of( + List paths = List.of( "/jcr:con|ent", "/jcr:|ontent", "/jcr:conten|", @@ -174,7 +172,7 @@ public void testVerticalLineInPath() throws Exception { @Test public void testVerticalLineInName() throws Exception { - List names = ImmutableList.of( + List names = List.of( "jcr:con|ent", "jcr:|ontent", "jcr:conten|", @@ -187,7 +185,7 @@ public void testVerticalLineInName() throws Exception { @Test public void testWhitespaceInPath() throws Exception { - List paths = ImmutableList.of( + List paths = List.of( "/content ", "/ content", "/content\t", @@ -201,7 +199,7 @@ public void testWhitespaceInPath() throws Exception { @Test public void testWhitespaceInName() throws Exception { - List names = ImmutableList.of( + List names = List.of( "jcr:content ", "content ", " content", diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/HasPermissionTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/HasPermissionTest.java index a8dad6686b9..8fa0aff6761 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/HasPermissionTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/HasPermissionTest.java @@ -22,7 +22,6 @@ import javax.jcr.Session; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.oak.spi.security.authorization.permission.Permissions; @@ -32,7 +31,7 @@ public class HasPermissionTest extends AbstractEvaluationTest { public void testEmpty() throws Exception { - List paths = ImmutableList.of( + List paths = List.of( "/", path, childPPath, path + "/rep:policy", "/nonExisting", path + "/nonExisting"); @@ -82,7 +81,7 @@ public void testDuplicate() throws Exception { } public void testMultiple() throws Exception { - List paths = ImmutableList.of( + List paths = List.of( "/", path, childPPath, path + "/rep:policy", "/nonExisting", path + "/nonExisting"); diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/RemappingTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/RemappingTest.java index 2cd275ae809..22586f1ad03 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/RemappingTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/RemappingTest.java @@ -24,7 +24,6 @@ import javax.jcr.Session; import javax.jcr.Value; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Query; import org.apache.jackrabbit.api.security.user.QueryBuilder; @@ -43,8 +42,8 @@ public class RemappingTest extends AbstractUserTest { private Session session; private Authorizable authorizable; - private List unmappedPaths = ImmutableList.of("uTest:property", "uTest:node/uTest:property2"); - private List mappedPaths = ImmutableList.of("my:property", "my:node/my:property2"); + private List unmappedPaths = List.of("uTest:property", "uTest:node/uTest:property2"); + private List mappedPaths = List.of("my:property", "my:node/my:property2"); private Value nameValue; @Override diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserQueryTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserQueryTest.java index f2c697cfd10..7cf06c8f02b 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserQueryTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserQueryTest.java @@ -27,9 +27,7 @@ import javax.jcr.RepositoryException; import javax.jcr.Value; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; import org.apache.jackrabbit.api.security.user.Query; @@ -755,7 +753,7 @@ public void build(@NotNull QueryBuilder builder) { } }); - Iterator continents = ImmutableList.of("africa", "america", "australia").iterator(); + Iterator continents = List.of("africa", "america", "australia").iterator(); String expected = continents.next(); while (result.hasNext()) { Authorizable a = result.next(); @@ -779,7 +777,7 @@ public void build(@NotNull QueryBuilder builder) { } }); - Iterator continents = ImmutableList.of("Africa", "America", "africa", "australia").iterator(); + Iterator continents = List.of("Africa", "America", "africa", "australia").iterator(); String expected = continents.next(); while (result.hasNext()) { Authorizable a = result.next(); diff --git a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactory.java b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactory.java index 5ae384fb64b..86f76fda221 100644 --- a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactory.java +++ b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexAugmentorFactory.java @@ -23,7 +23,6 @@ import java.util.Map; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.LinkedListMultimap; import org.apache.jackrabbit.guava.common.collect.ListMultimap; import org.osgi.service.component.annotations.Component; @@ -185,7 +184,7 @@ class CompositeIndexFieldProvider implements IndexFieldProvider { CompositeIndexFieldProvider(String nodeType, List providers) { this.nodeType = nodeType; - this.providers = ImmutableList.copyOf(providers); + this.providers = List.copyOf(providers); } @NotNull @@ -219,7 +218,7 @@ class CompositeFulltextQueryTermsProvider implements FulltextQueryTermsProvider CompositeFulltextQueryTermsProvider(String nodeType, List providers) { this.nodeType = nodeType; - this.providers = ImmutableList.copyOf(providers); + this.providers = List.copyOf(providers); } @Override diff --git a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProvider.java b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProvider.java index bc152ad21d5..f9c3a09ff7f 100644 --- a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProvider.java +++ b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProvider.java @@ -19,7 +19,6 @@ import java.io.Closeable; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.plugins.index.aggregate.AggregateIndex; import org.apache.jackrabbit.oak.spi.commit.CommitInfo; import org.apache.jackrabbit.oak.spi.commit.Observer; @@ -73,7 +72,7 @@ public void contentChanged(@NotNull NodeState root, @NotNull CommitInfo info) { @Override @NotNull public List getQueryIndexes(NodeState nodeState) { - return ImmutableList.of(new AggregateIndex(newLuceneIndex()), newLucenePropertyIndex()); + return List.of(new AggregateIndex(newLuceneIndex()), newLucenePropertyIndex()); } protected LuceneIndex newLuceneIndex() { diff --git a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java index 66b16756a79..093852c4f66 100644 --- a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java +++ b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; @@ -38,7 +39,6 @@ import org.apache.jackrabbit.guava.common.collect.AbstractIterator; import org.apache.jackrabbit.guava.common.collect.FluentIterable; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.oak.api.PropertyValue; @@ -1688,7 +1688,7 @@ private List getFacetsUncached(int numberOfFacets, String columnName) thr Facets facets = FacetHelper.getFacets(searcher, query, plan, config); if (facets != null) { try { - ImmutableList.Builder res = new ImmutableList.Builder<>(); + List res = new ArrayList<>(); FacetResult topChildren = facets.getTopChildren(numberOfFacets, facetFieldName); if (topChildren != null) { for (LabelAndValue lav : topChildren.labelValues) { @@ -1696,7 +1696,7 @@ private List getFacetsUncached(int numberOfFacets, String columnName) thr lav.label, lav.value.intValue() )); } - return res.build(); + return Collections.unmodifiableList(res); } } catch (IllegalArgumentException iae) { LOG.debug(iae.getMessage(), iae); @@ -1712,7 +1712,7 @@ private List getFacetsUncached(int numberOfFacets, String columnName) thr private List getFacetsUncached(Facets facets, int numberOfFacets, String columnName) throws IOException { String facetFieldName = FulltextIndex.parseFacetField(columnName); try { - ImmutableList.Builder res = new ImmutableList.Builder<>(); + List res = new ArrayList<>(); FacetResult topChildren = facets.getTopChildren(numberOfFacets, facetFieldName); if (topChildren == null) { return null; @@ -1722,7 +1722,7 @@ private List getFacetsUncached(Facets facets, int numberOfFacets, String lav.label, lav.value.intValue() )); } - return res.build(); + return Collections.unmodifiableList(res); } catch (IllegalArgumentException iae) { LOG.debug(iae.getMessage(), iae); LOG.warn("facets for {} not yet indexed: {}", facetFieldName, iae); @@ -1746,7 +1746,7 @@ public List getFacets(int numberOfFacets, String columnName) throws IOExc if (facets != null) { try { - ImmutableList.Builder res = new ImmutableList.Builder<>(); + List res = new ArrayList<>(); FacetResult topChildren = facets.getTopChildren(numberOfFacets, facetFieldName); if (topChildren != null) { for (LabelAndValue lav : topChildren.labelValues) { @@ -1754,7 +1754,7 @@ public List getFacets(int numberOfFacets, String columnName) throws IOExc lav.label, lav.value.intValue() )); } - return res.build(); + return Collections.unmodifiableList(res); } } catch (IllegalArgumentException iae) { LOG.debug(iae.getMessage(), iae); diff --git a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/NRTIndex.java b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/NRTIndex.java index 0791004a36b..c70755d4b67 100644 --- a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/NRTIndex.java +++ b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/NRTIndex.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene.hybrid; import java.io.Closeable; @@ -29,7 +28,6 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.commons.io.FileUtils; import org.apache.jackrabbit.oak.commons.conditions.Validate; import org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier; @@ -173,7 +171,7 @@ public synchronized List getReaders() { decrementReaderUseCount(readers); dirReader = latestReader; - readers = ImmutableList.copyOf(newReaders); + readers = List.copyOf(newReaders); return readers; } diff --git a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/reader/DefaultIndexReaderFactory.java b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/reader/DefaultIndexReaderFactory.java index 9154e6f9f7f..30710a904fc 100644 --- a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/reader/DefaultIndexReaderFactory.java +++ b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/reader/DefaultIndexReaderFactory.java @@ -16,15 +16,14 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene.reader; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier; import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition; import org.apache.jackrabbit.oak.plugins.index.lucene.directory.OakDirectory; @@ -55,7 +54,7 @@ public List createReaders(LuceneIndexDefinition definition, N if (!mountInfoProvider.hasNonDefaultMounts()) { LuceneIndexReader reader = createReader(definition, defnState, indexPath, FulltextIndexConstants.INDEX_DATA_CHILD_NAME, SUGGEST_DATA_CHILD_NAME); - return reader != null ? ImmutableList.of(reader) : Collections.emptyList(); + return reader != null ? List.of(reader) : Collections.emptyList(); } else { return createMountedReaders(definition, defnState, indexPath); } @@ -63,7 +62,7 @@ public List createReaders(LuceneIndexDefinition definition, N private List createMountedReaders(LuceneIndexDefinition definition, NodeState defnState, String indexPath) throws IOException { - ImmutableList.Builder readers = ImmutableList.builder(); + List readers = new ArrayList<>(); LuceneIndexReader reader = createReader(mountInfoProvider.getDefaultMount(), definition, defnState, indexPath); //Default mount is the first entry. This ensures that suggester, spellcheck can work on that untill they //support multiple readers @@ -77,7 +76,7 @@ private List createMountedReaders(LuceneIndexDefinition defin readers.add(reader); } } - return readers.build(); + return Collections.unmodifiableList(readers); } @Nullable diff --git a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/IndexDefinitionBuilder.java b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/IndexDefinitionBuilder.java index ea26e212a9d..427762dd02b 100644 --- a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/IndexDefinitionBuilder.java +++ b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/IndexDefinitionBuilder.java @@ -47,7 +47,6 @@ import static java.util.Arrays.asList; import static java.util.Objects.requireNonNull; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED; import static org.apache.jackrabbit.oak.api.Type.NAME; @@ -616,7 +615,7 @@ private static Tree getOrCreateChild(Tree tree, String name){ static class SelectiveEqualsDiff extends EqualsDiff { // Properties for which changes shouldn't auto set the reindex flag - static final List ignorablePropertiesList = of( + static final List ignorablePropertiesList = List.of( FulltextIndexConstants.PROP_WEIGHT, FIELD_BOOST, IndexConstants.USE_IF_EXISTS, @@ -626,7 +625,7 @@ static class SelectiveEqualsDiff extends EqualsDiff { FulltextIndexConstants.BLOB_SIZE, FulltextIndexConstants.COST_PER_ENTRY, FulltextIndexConstants.COST_PER_EXECUTION); - static final List ignorableFacetConfigProps = of( + static final List ignorableFacetConfigProps = List.of( FulltextIndexConstants.PROP_SECURE_FACETS, FulltextIndexConstants.PROP_STATISTICAL_FACET_SAMPLE_SIZE, FulltextIndexConstants.PROP_FACETS_TOP_CHILDREN); diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/jcr/AtomicCounterIT.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/jcr/AtomicCounterIT.java index ec590a5e8a4..bfe6c5ed8ff 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/jcr/AtomicCounterIT.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/jcr/AtomicCounterIT.java @@ -18,6 +18,7 @@ */ package org.apache.jackrabbit.oak.jcr; +import java.util.List; import java.util.Set; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -47,7 +48,6 @@ import org.junit.Rule; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES; import static org.apache.jackrabbit.oak.api.Type.BOOLEAN; import static org.apache.jackrabbit.oak.api.Type.LONG; @@ -74,7 +74,7 @@ public void setup() throws Exception { NodeBuilder builder = ns.getRoot().builder(); NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME); NodeBuilder lucene = newLuceneIndexDefinition(index, "lucene", Set.of("String"), null, "async"); - lucene.setProperty("async", of("async", "nrt"), STRINGS); + lucene.setProperty("async", List.of("async", "nrt"), STRINGS); IndexDefinition.updateDefinition(index.child("lucene")); ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); @@ -111,7 +111,7 @@ public void consolidate() throws Exception { Root root = session.getLatestRoot(); Tree t = root.getTree("/"); Tree counter = t.addChild("counter"); - counter.setProperty(JCR_MIXINTYPES, of(MIX_ATOMIC_COUNTER), NAMES); + counter.setProperty(JCR_MIXINTYPES, List.of(MIX_ATOMIC_COUNTER), NAMES); root.commit(); root = session.getLatestRoot(); diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexNodeManagerTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexNodeManagerTest.java index 5e6d3ae44bd..937b78af2e4 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexNodeManagerTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexNodeManagerTest.java @@ -16,14 +16,13 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene; import java.io.File; import java.io.IOException; import java.util.Collections; +import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.plugins.index.lucene.directory.OakDirectory; import org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndex; import org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory; @@ -140,7 +139,7 @@ public void lockAndRefreshPolicy() throws Exception { @Test public void indexOpenedBeforeFistCycle() throws Exception { NodeState nrtIndex = createNRTIndex(); - NodeState asyncIndex = nrtIndex.builder().setProperty("async", ImmutableList.of("async"), STRINGS).getNodeState(); + NodeState asyncIndex = nrtIndex.builder().setProperty("async", List.of("async"), STRINGS).getNodeState(); NodeState nonAsyncIndex; { NodeBuilder builder = nrtIndex.builder(); @@ -193,7 +192,7 @@ public void indexWithIndexedDataOpenedBeforeFistCycle() throws Exception { directory.close(); nrtIndex = indexBuilder.getNodeState(); } - NodeState asyncIndex = nrtIndex.builder().setProperty("async", ImmutableList.of("async"), STRINGS).getNodeState(); + NodeState asyncIndex = nrtIndex.builder().setProperty("async", List.of("async"), STRINGS).getNodeState(); NodeState nonAsyncIndex; { NodeBuilder builder = nrtIndex.builder(); @@ -218,7 +217,7 @@ public void indexWithIndexedDataOpenedBeforeFistCycle() throws Exception { @Test public void hasIndexingRun() { NodeState nrtIndex = createNRTIndex(); - NodeState asyncIndex = nrtIndex.builder().setProperty("async", ImmutableList.of("async"), STRINGS).getNodeState(); + NodeState asyncIndex = nrtIndex.builder().setProperty("async", List.of("async"), STRINGS).getNodeState(); NodeState nonAsyncIndex; { NodeBuilder builder = nrtIndex.builder(); diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlannerTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlannerTest.java index bea73fc3c51..45efad61685 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlannerTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexPlannerTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene; import static java.util.Objects.requireNonNull; @@ -103,8 +102,6 @@ import org.junit.After; import org.junit.Test; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - public class IndexPlannerTest { private NodeState root = INITIAL_CONTENT; @@ -121,7 +118,7 @@ public void planForSortField() throws Exception{ defn.setProperty(createProperty(ORDERED_PROP_NAMES, Set.of("foo"), STRINGS)); LuceneIndexNode node = createIndexNode(new LuceneIndexDefinition(root, defn.getNodeState(), "/foo")); FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/foo", createFilter("nt:base"), - ImmutableList.of(new OrderEntry("foo", Type.LONG, OrderEntry.Order.ASCENDING))); + List.of(new OrderEntry("foo", Type.LONG, OrderEntry.Order.ASCENDING))); assertNotNull(planner.getPlan()); assertTrue(pr(planner.getPlan()).isUniquePathsRequired()); } @@ -131,7 +128,7 @@ public void noPlanForSortOnlyByScore() throws Exception{ NodeBuilder defn = newLucenePropertyIndexDefinition(builder, "test", Set.of("foo"), "async"); LuceneIndexNode node = createIndexNode(new LuceneIndexDefinition(root, defn.getNodeState(), "/foo")); FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/foo", createFilter("nt:file"), - ImmutableList.of(new OrderEntry("jcr:score", Type.LONG, OrderEntry.Order.ASCENDING))); + List.of(new OrderEntry("jcr:score", Type.LONG, OrderEntry.Order.ASCENDING))); assertNull(planner.getPlan()); } @@ -1127,7 +1124,7 @@ public void syncIndex_NotUsedWithSort() throws Exception{ filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar")); FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/foo", filter, - ImmutableList.of(new OrderEntry("bar", Type.LONG, OrderEntry.Order.ASCENDING))); + List.of(new OrderEntry("bar", Type.LONG, OrderEntry.Order.ASCENDING))); QueryIndex.IndexPlan plan = planner.getPlan(); assertNotNull(plan); @@ -1151,7 +1148,7 @@ public void syncIndex_NotUsedWithFulltext() throws Exception{ filter.setFullTextConstraint(FullTextParser.parse("bar", "mountain")); FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/foo", filter, - ImmutableList.of(new OrderEntry("bar", Type.LONG, OrderEntry.Order.ASCENDING))); + List.of(new OrderEntry("bar", Type.LONG, OrderEntry.Order.ASCENDING))); QueryIndex.IndexPlan plan = planner.getPlan(); assertNotNull(plan); @@ -1297,7 +1294,7 @@ public void noRestrictionWithSingleSortableField() throws Exception{ LuceneIndexDefinition definition = new LuceneIndexDefinition(root, defn.getNodeState(), "/test"); LuceneIndexNode node = createIndexNode(definition); FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/test", createFilter("nt:base"), - ImmutableList.of(new OrderEntry("foo", Type.LONG, OrderEntry.Order.ASCENDING), + List.of(new OrderEntry("foo", Type.LONG, OrderEntry.Order.ASCENDING), new OrderEntry("bar", Type.LONG, OrderEntry.Order.ASCENDING))); assertNotNull(planner.getPlan()); @@ -1312,7 +1309,7 @@ public void noRestrictionWithTwoSortableFields() throws Exception{ LuceneIndexDefinition definition = new LuceneIndexDefinition(root, defn.getNodeState(), "/test"); LuceneIndexNode node = createIndexNode(definition); FulltextIndexPlanner planner = new FulltextIndexPlanner(node, "/test", createFilter("nt:base"), - ImmutableList.of(new OrderEntry("foo", Type.LONG, OrderEntry.Order.ASCENDING), + List.of(new OrderEntry("foo", Type.LONG, OrderEntry.Order.ASCENDING), new OrderEntry("bar", Type.LONG, OrderEntry.Order.ASCENDING))); assertNotNull(planner.getPlan()); diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexlaneRepositoryTraversalTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexlaneRepositoryTraversalTest.java index 14c1e55fc23..870c3ef503e 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexlaneRepositoryTraversalTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexlaneRepositoryTraversalTest.java @@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.plugins.index.lucene; import ch.qos.logback.classic.Level; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.InitialContent; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.api.CommitFailedException; @@ -131,8 +130,8 @@ public void repositoryTraversalIfLaneIsPresent() throws Exception { Tree test1 = root.getTree("/").addChild(INDEX_DEFINITIONS_NAME).addChild("mynodetype"); test1.setProperty("jcr:primaryType", "oak:QueryIndexDefinition", Type.NAME); test1.setProperty("type", "property"); - test1.setProperty("propertyNames", ImmutableList.of("jcr:primaryType", "jcr:mixinTypes"), Type.NAMES); - test1.setProperty("declaringNodeTypes", ImmutableList.of("oak:QueryIndexDefinition"), Type.NAMES); + test1.setProperty("propertyNames", List.of("jcr:primaryType", "jcr:mixinTypes"), Type.NAMES); + test1.setProperty("declaringNodeTypes", List.of("oak:QueryIndexDefinition"), Type.NAMES); test1.setProperty("nodeTypeListDefined", true); test1.setProperty("reindex", true); root.commit(); diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDefinitionTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDefinitionTest.java index 0d9766b3880..a4abb51327a 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDefinitionTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexDefinitionTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene; import java.util.Collections; @@ -25,7 +24,6 @@ import javax.jcr.PropertyType; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.index.IndexConstants; @@ -312,7 +310,7 @@ public void indexRuleInheritanceDisabled() throws Exception{ @Test public void indexRuleInheritanceOrdering() throws Exception{ NodeBuilder rules = builder.child(INDEX_RULES); - rules.setProperty(OAK_CHILD_ORDER, ImmutableList.of("nt:hierarchyNode", "nt:base"),NAMES); + rules.setProperty(OAK_CHILD_ORDER, List.of("nt:hierarchyNode", "nt:base"),NAMES); rules.child("nt:hierarchyNode").setProperty(FulltextIndexConstants.FIELD_BOOST, 2.0); rules.child("nt:base").setProperty(FulltextIndexConstants.FIELD_BOOST, 3.0); @@ -325,7 +323,7 @@ public void indexRuleInheritanceOrdering() throws Exception{ @Test public void indexRuleInheritanceOrdering2() throws Exception{ NodeBuilder rules = builder.child(INDEX_RULES); - rules.setProperty(OAK_CHILD_ORDER, ImmutableList.of("nt:base", "nt:hierarchyNode"),NAMES); + rules.setProperty(OAK_CHILD_ORDER, List.of("nt:base", "nt:hierarchyNode"),NAMES); rules.child("nt:hierarchyNode").setProperty(FulltextIndexConstants.FIELD_BOOST, 2.0); rules.child("nt:base").setProperty(FulltextIndexConstants.FIELD_BOOST, 3.0); @@ -400,7 +398,7 @@ public void indexRuleWithPropertyOrdering() throws Exception{ .setProperty(FulltextIndexConstants.PROP_IS_REGEX, true) .setProperty(FulltextIndexConstants.FIELD_BOOST, 4.0); - rules.child("nt:folder").child(PROP_NODE).setProperty(OAK_CHILD_ORDER, ImmutableList.of("prop2", "prop1"), NAMES); + rules.child("nt:folder").child(PROP_NODE).setProperty(OAK_CHILD_ORDER, List.of("prop2", "prop1"), NAMES); LuceneIndexDefinition defn = new LuceneIndexDefinition(root, builder.getNodeState(), "/foo"); @@ -416,7 +414,7 @@ public void indexRuleWithPropertyOrdering() throws Exception{ assertEquals(4.0f, rule1.getConfig("fooProp").boost, 0); //Order it correctly to get expected result - rules.child("nt:folder").child(PROP_NODE).setProperty(OAK_CHILD_ORDER, ImmutableList.of("prop1", "prop2"), NAMES); + rules.child("nt:folder").child(PROP_NODE).setProperty(OAK_CHILD_ORDER, List.of("prop1", "prop2"), NAMES); defn = new LuceneIndexDefinition(root, builder.getNodeState(), "/foo"); rule1 = defn.getApplicableIndexingRule(asState(newNode("nt:folder"))); assertEquals(3.0f, rule1.getConfig("fooProp").boost, 0); diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorTest.java index a54da2e9620..92ef77eff93 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexEditorTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene; import java.io.File; @@ -29,7 +28,6 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.commons.CIHelper; import org.apache.jackrabbit.oak.plugins.blob.datastore.CachingFileDataStore; @@ -118,7 +116,7 @@ public class LuceneIndexEditorTest { @Parameterized.Parameters(name = "{index}: useBlobStore ({0})") public static List fixtures() { - return ImmutableList.of(new Boolean[] {true}, new Boolean[] {false}); + return List.of(new Boolean[] {true}, new Boolean[] {false}); } @Before diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java index 69c093c81c5..1b998419cb7 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.plugins.index.lucene; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static org.apache.jackrabbit.guava.common.collect.Iterators.transform; import static org.apache.jackrabbit.guava.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static java.util.Arrays.asList; @@ -69,6 +68,7 @@ import org.apache.jackrabbit.oak.api.Blob; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.commons.junit.LogCustomizer; import org.apache.jackrabbit.oak.plugins.index.IndexConstants; import org.apache.jackrabbit.oak.plugins.index.IndexUpdate; @@ -116,8 +116,6 @@ import org.junit.Assert; import org.junit.Test; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - @SuppressWarnings("ConstantConditions") public class LuceneIndexTest { @@ -218,7 +216,7 @@ public void testLuceneLazyCursor() throws Exception { List plans = queryIndex.getPlans(filter, null, indexed); Cursor cursor = queryIndex.query(plans.get(0), indexed); - List paths = copyOf(transform(cursor, IndexRow::getPath)); + List paths = CollectionUtils.toList(transform(cursor, IndexRow::getPath)); assertFalse(paths.isEmpty()); assertEquals(LuceneIndex.LUCENE_QUERY_BATCH_SIZE + 1, paths.size()); } @@ -400,7 +398,7 @@ public void testPropertyNonExistence() throws Exception { FilterImpl filter = createFilter(NT_TEST); filter.restrictProperty("foo", Operator.EQUAL, null); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/c")); + assertFilter(filter, queryIndex, indexed, List.of("/c")); } @Test @@ -431,7 +429,7 @@ public void testPropertyExistence() throws Exception { FilterImpl filter = createFilter(NT_TEST); filter.restrictProperty("foo", Operator.NOT_EQUAL, null); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/a","/b")); + assertFilter(filter, queryIndex, indexed, List.of("/a","/b")); } @@ -467,7 +465,7 @@ public void testRelativePropertyNonExistence() throws Exception { FilterImpl filter = createFilter(NT_TEST); filter.restrictProperty("jcr:content/bar", Operator.EQUAL, null); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/b1")); + assertFilter(filter, queryIndex, indexed, List.of("/b1")); builder.child("b1").child("jcr:content").setProperty("bar", "foo"); after = builder.getNodeState(); @@ -502,19 +500,19 @@ public void testPathRestrictions() throws Exception { FilterImpl filter = createTestFilter(); filter.restrictPath("/", Filter.PathRestriction.EXACT); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/")); + assertFilter(filter, queryIndex, indexed, List.of("/")); filter = createTestFilter(); filter.restrictPath("/", Filter.PathRestriction.DIRECT_CHILDREN); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/a", "/a1")); + assertFilter(filter, queryIndex, indexed, List.of("/a", "/a1")); filter = createTestFilter(); filter.restrictPath("/a", Filter.PathRestriction.DIRECT_CHILDREN); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/a/b")); + assertFilter(filter, queryIndex, indexed, List.of("/a/b")); filter = createTestFilter(); filter.restrictPath("/a", Filter.PathRestriction.ALL_CHILDREN); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/a/b", "/a/b/c")); + assertFilter(filter, queryIndex, indexed, List.of("/a/b", "/a/b/c")); } @Test @@ -538,15 +536,15 @@ public void nodeNameIndex() throws Exception{ FilterImpl filter = createFilter(NT_FILE); filter.restrictProperty(QueryConstants.RESTRICTION_LOCAL_NAME, Operator.EQUAL, PropertyValues.newString("foo")); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/foo")); + assertFilter(filter, queryIndex, indexed, List.of("/foo")); filter = createFilter(NT_FILE); filter.restrictProperty(QueryConstants.RESTRICTION_LOCAL_NAME, Operator.LIKE, PropertyValues.newString("camelCase")); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/camelCase")); + assertFilter(filter, queryIndex, indexed, List.of("/camelCase")); filter = createFilter(NT_FILE); filter.restrictProperty(QueryConstants.RESTRICTION_LOCAL_NAME, Operator.LIKE, PropertyValues.newString("camel%")); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/camelCase")); + assertFilter(filter, queryIndex, indexed, List.of("/camelCase")); } private FilterImpl createTestFilter(){ @@ -573,7 +571,7 @@ public void analyzerWithStopWords() throws Exception{ FilterImpl filter = createFilter("nt:base"); filter.setFullTextConstraint(new FullTextTerm(null, "fox jumping", false, false, null)); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/")); + assertFilter(filter, queryIndex, indexed, List.of("/")); //No stop word configured so default analyzer would also check for 'was' filter.setFullTextConstraint(new FullTextTerm(null, "fox was jumping", false, false, null)); @@ -594,36 +592,36 @@ public void analyzerWithStopWords() throws Exception{ queryIndex = new LucenePropertyIndex(tracker); filter.setFullTextConstraint(new FullTextTerm(null, "fox jumping", false, false, null)); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/")); + assertFilter(filter, queryIndex, indexed, List.of("/")); //Now this should get passed as the analyzer would ignore 'was' filter.setFullTextConstraint(new FullTextTerm(null, "fox was jumping", false, false, null)); - assertFilter(filter, queryIndex, indexed, ImmutableList.of("/")); + assertFilter(filter, queryIndex, indexed, List.of("/")); } @Test public void testTokens() { Analyzer analyzer = LuceneIndexConstants.ANALYZER; - assertEquals(ImmutableList.of("parent", "child"), + assertEquals(List.of("parent", "child"), LuceneIndex.tokenize("/parent/child", analyzer)); - assertEquals(ImmutableList.of("p1234", "p5678"), + assertEquals(List.of("p1234", "p5678"), LuceneIndex.tokenize("/p1234/p5678", analyzer)); - assertEquals(ImmutableList.of("first", "second"), + assertEquals(List.of("first", "second"), LuceneIndex.tokenize("first_second", analyzer)); - assertEquals(ImmutableList.of("first1", "second2"), + assertEquals(List.of("first1", "second2"), LuceneIndex.tokenize("first1_second2", analyzer)); - assertEquals(ImmutableList.of("first", "second"), + assertEquals(List.of("first", "second"), LuceneIndex.tokenize("first. second", analyzer)); - assertEquals(ImmutableList.of("first", "second"), + assertEquals(List.of("first", "second"), LuceneIndex.tokenize("first.second", analyzer)); - assertEquals(ImmutableList.of("hello", "world"), + assertEquals(List.of("hello", "world"), LuceneIndex.tokenize("hello-world", analyzer)); - assertEquals(ImmutableList.of("hello", "wor*"), + assertEquals(List.of("hello", "wor*"), LuceneIndex.tokenize("hello-wor*", analyzer)); - assertEquals(ImmutableList.of("*llo", "world"), + assertEquals(List.of("*llo", "world"), LuceneIndex.tokenize("*llo-world", analyzer)); - assertEquals(ImmutableList.of("*llo", "wor*"), + assertEquals(List.of("*llo", "wor*"), LuceneIndex.tokenize("*llo-wor*", analyzer)); } @@ -843,7 +841,7 @@ public void testConfigErrorInIndexDefintion() throws Exception { newLucenePropertyIndexDefinition(index, "luceneTest", Set.of("foo"), null); newLucenePropertyIndexDefinition(index, "luceneTest2", Set.of("foo2"), null); - builder.child(INDEX_DEFINITIONS_NAME).child("luceneTest").setProperty(IndexConstants.ENTRY_COUNT_PROPERTY_NAME, ImmutableList.of(2L), Type.LONGS); + builder.child(INDEX_DEFINITIONS_NAME).child("luceneTest").setProperty(IndexConstants.ENTRY_COUNT_PROPERTY_NAME, List.of(2L), Type.LONGS); NodeState before = builder.getNodeState(); // Add some content that qualifies to be indexed by both of the above indexes (separately) diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/MultiplexingLucenePropertyIndexTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/MultiplexingLucenePropertyIndexTest.java index 2864cff8ee8..d4a70dd1ef1 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/MultiplexingLucenePropertyIndexTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/MultiplexingLucenePropertyIndexTest.java @@ -16,10 +16,8 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.oak.api.QueryEngine.NO_BINDINGS; import static org.apache.jackrabbit.oak.api.Type.STRINGS; import static org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndexTest.createIndex; @@ -44,7 +42,6 @@ import javax.jcr.PropertyType; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.commons.io.FileUtils; import org.apache.jackrabbit.oak.InitialContent; import org.apache.jackrabbit.oak.Oak; @@ -213,13 +210,13 @@ public void propertyIndex() throws Exception{ assertEquals(2, getIndexDirNames(idxName).size()); String barQuery = "select [jcr:path] from [nt:base] where [foo] = 'bar'"; - assertQuery(barQuery, of("/libs/a", "/content/a")); + assertQuery(barQuery, List.of("/libs/a", "/content/a")); Result result = executeQuery(barQuery, SQL2, NO_BINDINGS); assertTrue(result.getRows().iterator().hasNext()); assertEquals(2, result.getSize(Result.SizePrecision.FAST_APPROXIMATION, 100)); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar2'", of("/libs/b")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar2'", List.of("/libs/b")); } @Test diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactoryTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactoryTest.java index c4ead1c3b16..e9a4f1365c9 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactoryTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactoryTest.java @@ -16,16 +16,15 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene; import java.io.ByteArrayOutputStream; import java.io.PrintWriter; import java.io.Reader; import java.lang.reflect.Field; +import java.util.List; import java.util.Map; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.commons.io.IOUtils; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.plugins.index.lucene.NodeStateAnalyzerFactory.NodeStateResourceLoader; @@ -109,7 +108,7 @@ public void analyzerByComposition_TokenFilter() throws Exception{ nb.child(ANL_TOKENIZER).setProperty(ANL_NAME, "whitespace"); NodeBuilder filters = nb.child(ANL_FILTERS); - filters.setProperty(OAK_CHILD_ORDER, ImmutableList.of("stop", "LowerCase"),NAMES); + filters.setProperty(OAK_CHILD_ORDER, List.of("stop", "LowerCase"),NAMES); filters.child("LowerCase").setProperty(ANL_NAME, "LowerCase"); filters.child("LowerCase").setProperty(JCR_PRIMARYTYPE, "nt:unstructured"); //name is optional. Derived from nodeName @@ -131,7 +130,7 @@ public void analyzerByComposition_CharFilter() throws Exception{ nb.child(ANL_TOKENIZER).setProperty(ANL_NAME, "whitespace"); NodeBuilder filters = nb.child(ANL_CHAR_FILTERS); - filters.setProperty(OAK_CHILD_ORDER, ImmutableList.of("htmlStrip", "mapping"),NAMES); + filters.setProperty(OAK_CHILD_ORDER, List.of("htmlStrip", "mapping"),NAMES); filters.child("mapping").setProperty(ANL_NAME, "mapping"); filters.child("htmlStrip"); //name is optional. Derived from nodeName diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/HybridIndexTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/HybridIndexTest.java index 05c4f129183..d588ad353f0 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/HybridIndexTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/HybridIndexTest.java @@ -38,7 +38,6 @@ import javax.management.ObjectName; import ch.qos.logback.classic.Level; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.commons.exec.CommandLine; import org.apache.commons.exec.DefaultExecutor; @@ -99,7 +98,6 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.guava.common.util.concurrent.MoreExecutors.newDirectExecutorService; import static org.apache.jackrabbit.oak.api.QueryEngine.NO_BINDINGS; import static org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider; @@ -194,25 +192,25 @@ public void hybridIndex() throws Exception{ runAsyncIndex(); setTraversalEnabled(false); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a")); //Add new node. This would not be reflected in result as local index would not be updated createPath("/b").setProperty("foo", "bar"); root.commit(); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a")); //Now let some time elapse such that readers can be refreshed clock.waitUntil(clock.getTime() + refreshDelta + 1); //Now recently added stuff should be visible without async indexing run - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a", "/b")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a", "/b")); createPath("/c").setProperty("foo", "bar"); root.commit(); //Post async index it should still be upto date runAsyncIndex(); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a", "/b", "/c")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a", "/b", "/c")); } @Test @@ -262,7 +260,7 @@ public void noTextExtractionForSyncCommit() throws Exception{ runAsyncIndex(); assertEquals(1, testBlob.accessCount); - assertQuery("select * from [nt:base] where CONTAINS(*, 'sky')", of("/test/msg/jcr:content")); + assertQuery("select * from [nt:base] where CONTAINS(*, 'sky')", List.of("/test/msg/jcr:content")); } @@ -281,12 +279,12 @@ public void hybridIndexSync() throws Exception{ runAsyncIndex(); setTraversalEnabled(false); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a")); //Add new node. This should get immediately reelected as its a sync index createPath("/b").setProperty("foo", "bar"); root.commit(); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a", "/b")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a", "/b")); } @Test @@ -299,19 +297,19 @@ public void usageBeforeFirstIndex() throws Exception{ createPath("/a").setProperty("foo", "bar"); root.commit(); setTraversalEnabled(false); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a")); //Add new node. This should get immediately reelected as its a sync index createPath("/b").setProperty("foo", "bar"); root.commit(); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a", "/b")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a", "/b")); runAsyncIndex(); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a", "/b")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a", "/b")); createPath("/c").setProperty("foo", "bar"); root.commit(); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a", "/b", "/c")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a", "/b", "/c")); } @Test @@ -325,7 +323,7 @@ public void newNodeTypesFoundLater() throws Exception{ createPath("/a").setProperty("foo", "bar"); root.commit(); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a")); optionalEditorProvider.delegate = new TypeEditorProvider(false); NodeTypeRegistry.register(root, IOUtils.toInputStream(TestUtil.TEST_NODE_TYPE), "test nodeType"); @@ -335,7 +333,7 @@ public void newNodeTypesFoundLater() throws Exception{ b.setProperty(JcrConstants.JCR_PRIMARYTYPE, "oak:TestNode", Type.NAME); b.setProperty("bar", "foo"); root.commit(); - assertQuery("select [jcr:path] from [nt:base] where [bar] = 'foo'", of("/b")); + assertQuery("select [jcr:path] from [nt:base] where [bar] = 'foo'", List.of("/b")); } @Test @@ -354,7 +352,7 @@ public void newNodeTypesFoundLater2() throws Exception{ //such that it does not indexes test nodetype Tree nodeType = root.getTree("/oak:index/nodetype"); if (!nodeType.hasProperty(IndexConstants.DECLARING_NODE_TYPES)){ - nodeType.setProperty(IndexConstants.DECLARING_NODE_TYPES, ImmutableList.of("nt:file"), Type.NAMES); + nodeType.setProperty(IndexConstants.DECLARING_NODE_TYPES, List.of("nt:file"), Type.NAMES); nodeType.setProperty(IndexConstants.REINDEX_PROPERTY_NAME, true); } @@ -364,7 +362,7 @@ public void newNodeTypesFoundLater2() throws Exception{ createPath("/a").setProperty("foo", "bar"); root.commit(); - assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", of("/a")); + assertQuery("select [jcr:path] from [nt:base] where [foo] = 'bar'", List.of("/a")); optionalEditorProvider.delegate = new TypeEditorProvider(false); NodeTypeRegistry.register(root, IOUtils.toInputStream(TestUtil.TEST_NODE_TYPE), "test nodeType"); @@ -380,7 +378,7 @@ public void newNodeTypesFoundLater2() throws Exception{ String query = "select [jcr:path] from [oak:TestNode] "; assertThat(explain(query), containsString("/oak:index/hybridtest")); - assertQuery(query, of("/b", "/c")); + assertQuery(query, List.of("/b", "/c")); } @Test diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/BucketSwitcherTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/BucketSwitcherTest.java index 3ddf24a5e3a..d44271dba2c 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/BucketSwitcherTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/BucketSwitcherTest.java @@ -16,15 +16,14 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene.property; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.state.EqualsDiff; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexUtil.PROP_HEAD_BUCKET; import static org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexUtil.PROP_PREVIOUS_BUCKET; import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; @@ -43,7 +42,7 @@ public class BucketSwitcherTest { @Test public void basic() throws Exception { bs.switchBucket(100); - assertThat(copyOf(bs.getOldBuckets()), empty()); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), empty()); } @Test @@ -52,7 +51,7 @@ public void singleUnusedBucket() throws Exception { builder.setProperty(PROP_HEAD_BUCKET, "1"); bs.switchBucket(100); - assertThat(copyOf(bs.getOldBuckets()), empty()); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), empty()); } @Test @@ -65,7 +64,7 @@ public void twoBucket_HeadUnused() throws Exception { bs.switchBucket(100); assertFalse(builder.hasProperty(PROP_PREVIOUS_BUCKET)); assertEquals("2", builder.getString(PROP_HEAD_BUCKET)); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1")); } @Test @@ -81,7 +80,7 @@ public void twoBuckets_BothUsed() throws Exception { assertEquals("3", builder.getString(PROP_HEAD_BUCKET)); assertTrue(builder.hasChildNode("3")); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1")); } @Test @@ -96,7 +95,7 @@ public void twoBuckets_2Switches() throws Exception{ bs.switchBucket(150); assertFalse(builder.hasProperty(PROP_PREVIOUS_BUCKET)); assertEquals("3", builder.getString(PROP_HEAD_BUCKET)); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1", "2")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1", "2")); } /** @@ -117,7 +116,7 @@ public void twoBuckets_NoChange() throws Exception{ assertEquals("3", builder.getString(PROP_HEAD_BUCKET)); assertEquals("2", builder.getString(PROP_PREVIOUS_BUCKET)); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1")); NodeState state1 = builder.getNodeState(); assertFalse(bs.switchBucket(100)); @@ -126,7 +125,7 @@ public void twoBuckets_NoChange() throws Exception{ //as previous assertEquals("3", builder.getString(PROP_HEAD_BUCKET)); assertEquals("2", builder.getString(PROP_PREVIOUS_BUCKET)); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1")); NodeState state2 = builder.getNodeState(); assertFalse(bs.switchBucket(100)); @@ -134,7 +133,7 @@ public void twoBuckets_NoChange() throws Exception{ //Async indexer time still not changed. So head bucket remains same assertEquals("3", builder.getString(PROP_HEAD_BUCKET)); assertEquals("2", builder.getString(PROP_PREVIOUS_BUCKET)); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1")); NodeState state3 = builder.getNodeState(); @@ -159,7 +158,7 @@ public void twoBucket_IndexedToTimeChange() throws Exception{ assertEquals("3", builder.getString(PROP_HEAD_BUCKET)); assertEquals("2", builder.getString(PROP_PREVIOUS_BUCKET)); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1")); NodeState state1 = builder.getNodeState(); assertTrue(bs.switchBucket(150)); @@ -167,14 +166,14 @@ public void twoBucket_IndexedToTimeChange() throws Exception{ //This time previous bucket should be discarded assertEquals("3", builder.getString(PROP_HEAD_BUCKET)); assertNull(builder.getString(PROP_PREVIOUS_BUCKET)); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1", "2")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1", "2")); NodeState state2 = builder.getNodeState(); assertTrue(bs.switchBucket(200)); assertEquals("3", builder.getString(PROP_HEAD_BUCKET)); assertNull(builder.getString(PROP_PREVIOUS_BUCKET)); - assertThat(copyOf(bs.getOldBuckets()), containsInAnyOrder("1", "2")); + assertThat(CollectionUtils.toList(bs.getOldBuckets()), containsInAnyOrder("1", "2")); //assert no change done after previous is removed //not even change of asyncIndexedTo diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexLookupTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexLookupTest.java index 1ee37ff43fd..99f4f8adab9 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexLookupTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexLookupTest.java @@ -16,13 +16,12 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene.property; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; import org.apache.jackrabbit.oak.plugins.index.search.PropertyDefinition; @@ -108,7 +107,7 @@ public void pathResultAbsolutePath() throws Exception{ Iterable paths = lookup.query(filter, propertyName, filter.getPropertyRestriction(propertyName)); - assertThat(ImmutableList.copyOf(paths), containsInAnyOrder("/a")); + assertThat(CollectionUtils.toList(paths), containsInAnyOrder("/a")); } @Test @@ -128,14 +127,14 @@ public void nonRootIndex() throws Exception{ Iterable paths = lookup.query(filter, propertyName, filter.getPropertyRestriction(propertyName)); - assertThat(ImmutableList.copyOf(paths), containsInAnyOrder("/a")); + assertThat(CollectionUtils.toList(paths), containsInAnyOrder("/a")); lookup = new HybridPropertyIndexLookup(indexPath, builder.getNodeState(), "/content", true); paths = lookup.query(filter, propertyName, filter.getPropertyRestriction(propertyName)); - assertThat(ImmutableList.copyOf(paths), containsInAnyOrder("/content/a")); + assertThat(CollectionUtils.toList(paths), containsInAnyOrder("/content/a")); } private void propertyUpdated(String nodePath, String propertyRelativeName, String value){ @@ -157,7 +156,7 @@ private List query(Filter filter, String propertyName, String propertyRe HybridPropertyIndexLookup lookup = new HybridPropertyIndexLookup(indexPath, builder.getNodeState()); Iterable paths = lookup.query(filter, propertyName, filter.getPropertyRestriction(propertyRestrictionName)); - return ImmutableList.copyOf(paths); + return CollectionUtils.toList(paths); } private PropertyDefinition pd(String propName){ diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexStorageTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexStorageTest.java index e292ac1aa28..dc6640ea048 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexStorageTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexStorageTest.java @@ -16,13 +16,12 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene.property; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyValue; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; import org.apache.jackrabbit.oak.plugins.index.search.PropertyDefinition; @@ -205,7 +204,7 @@ private List query(String propertyName, PropertyValue value) { HybridPropertyIndexLookup lookup = new HybridPropertyIndexLookup(indexPath, builder.getNodeState()); FilterImpl filter = createFilter(root, "nt:base"); Iterable paths = lookup.query(filter, propertyName, value); - return ImmutableList.copyOf(paths); + return CollectionUtils.toList(paths); } private PropertyIndexUpdateCallback newCallback(){ diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexCleanerTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexCleanerTest.java index b8b89933bbd..4ebc69def36 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexCleanerTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexCleanerTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene.property; import java.util.HashMap; @@ -24,9 +23,9 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.InitialContent; import org.apache.jackrabbit.oak.api.CommitFailedException; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfo; import org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService; import org.apache.jackrabbit.oak.plugins.index.lucene.property.PropertyIndexCleaner.CleanupStats; @@ -332,7 +331,7 @@ private List query(String indexPath, String propertyName, String value) HybridPropertyIndexLookup lookup = new HybridPropertyIndexLookup(indexPath, getNode(root, indexPath)); FilterImpl filter = FilterImpl.newTestInstance(); Iterable paths = lookup.query(filter, propertyName, PropertyValues.newString(value)); - return ImmutableList.copyOf(paths); + return CollectionUtils.toList(paths); } private static class SimpleAsyncInfoService implements AsyncIndexInfoService { diff --git a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniqueIndexCleanerTest.java b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniqueIndexCleanerTest.java index 9b33ff2e4fd..fce3c814201 100644 --- a/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniqueIndexCleanerTest.java +++ b/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniqueIndexCleanerTest.java @@ -16,14 +16,12 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.lucene.property; - +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexUtil.PROP_CREATED; import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; @@ -42,7 +40,7 @@ public void nothingCleaned() throws Exception{ UniqueIndexCleaner cleaner = new UniqueIndexCleaner(MILLISECONDS, 1); cleaner.clean(builder, 10); - assertThat(copyOf(builder.getChildNodeNames()), containsInAnyOrder("a", "b")); + assertThat(CollectionUtils.toList(builder.getChildNodeNames()), containsInAnyOrder("a", "b")); } @Test @@ -53,7 +51,7 @@ public void cleanWithMargin() throws Exception{ refresh(); UniqueIndexCleaner cleaner = new UniqueIndexCleaner(MILLISECONDS, 100); cleaner.clean(builder, 200); - assertThat(copyOf(builder.getChildNodeNames()), containsInAnyOrder("b")); + assertThat(CollectionUtils.toList(builder.getChildNodeNames()), containsInAnyOrder("b")); } private void refresh(){ diff --git a/oak-query-spi/src/main/java/org/apache/jackrabbit/oak/spi/query/CompositeQueryIndexProvider.java b/oak-query-spi/src/main/java/org/apache/jackrabbit/oak/spi/query/CompositeQueryIndexProvider.java index 57e70fe08a1..430bb9e3f29 100644 --- a/oak-query-spi/src/main/java/org/apache/jackrabbit/oak/spi/query/CompositeQueryIndexProvider.java +++ b/oak-query-spi/src/main/java/org/apache/jackrabbit/oak/spi/query/CompositeQueryIndexProvider.java @@ -24,8 +24,6 @@ import org.apache.jackrabbit.oak.spi.state.NodeState; import org.jetbrains.annotations.NotNull; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - /** * This {@code QueryIndexProvider} aggregates a list of query index providers * into a single query index provider. @@ -49,14 +47,14 @@ public static QueryIndexProvider compose( return new QueryIndexProvider() { @Override public List getQueryIndexes(NodeState nodeState) { - return ImmutableList.of(); + return List.of(); } }; } else if (providers.size() == 1) { return providers.iterator().next(); } else { return new CompositeQueryIndexProvider( - ImmutableList.copyOf(providers)); + List.copyOf(providers)); } } diff --git a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/SimpleFlatFileUtil.java b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/SimpleFlatFileUtil.java index 5c54bc6548f..643eeb1fd6c 100644 --- a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/SimpleFlatFileUtil.java +++ b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/SimpleFlatFileUtil.java @@ -18,7 +18,6 @@ */ package org.apache.jackrabbit.oak.index.indexer.document.flatfile; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static org.apache.jackrabbit.oak.commons.PathUtils.elements; import java.io.BufferedWriter; @@ -29,6 +28,7 @@ import java.util.Comparator; import java.util.stream.StreamSupport; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry; import org.apache.jackrabbit.oak.plugins.document.DocumentNodeState; import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry; @@ -93,7 +93,7 @@ private void addEntry(NodeState ns) throws IOException { return; } String jsonText = entryWriter.asSortedJson(e.getNodeState()); - String line = entryWriter.toString(copyOf(elements(path)), jsonText); + String line = entryWriter.toString(CollectionUtils.toList(elements(path)), jsonText); writer.append(line); writer.append(LINE_SEPARATOR); totalLines++; diff --git a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/SimpleNodeStateHolder.java b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/SimpleNodeStateHolder.java index dd0a365c5f7..c3bac1cb8e8 100644 --- a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/SimpleNodeStateHolder.java +++ b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/SimpleNodeStateHolder.java @@ -16,14 +16,14 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.index.indexer.document.flatfile; +import java.util.Collections; import java.util.List; import org.apache.jackrabbit.oak.commons.StringUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static org.apache.jackrabbit.oak.commons.PathUtils.elements; import static org.apache.jackrabbit.oak.index.indexer.document.flatfile.NodeStateEntryWriter.getPath; @@ -32,7 +32,7 @@ public class SimpleNodeStateHolder implements NodeStateHolder{ private final List pathElements; public SimpleNodeStateHolder(String line) { - this.pathElements = copyOf(elements(getPath(line))); + this.pathElements = Collections.unmodifiableList(CollectionUtils.toList(elements(getPath(line)))); this.line = line; } diff --git a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/StateInBytesHolder.java b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/StateInBytesHolder.java index 3b46e85ba81..31694ce551a 100644 --- a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/StateInBytesHolder.java +++ b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/StateInBytesHolder.java @@ -16,15 +16,15 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.index.indexer.document.flatfile; import java.nio.charset.StandardCharsets; +import java.util.Collections; import java.util.List; import org.apache.jackrabbit.oak.commons.StringUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static org.apache.jackrabbit.oak.commons.PathUtils.elements; class StateInBytesHolder implements NodeStateHolder { @@ -32,7 +32,7 @@ class StateInBytesHolder implements NodeStateHolder { private final byte[] content; public StateInBytesHolder(String path, String line) { - this.pathElements = copyOf(elements(path)); + this.pathElements = Collections.unmodifiableList(CollectionUtils.toList(elements(path))); this.content = line.getBytes(StandardCharsets.UTF_8); } diff --git a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/indexversion/PurgeOldIndexVersion.java b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/indexversion/PurgeOldIndexVersion.java index 73255e35a5e..3556f052a65 100644 --- a/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/indexversion/PurgeOldIndexVersion.java +++ b/oak-run-commons/src/main/java/org/apache/jackrabbit/oak/indexversion/PurgeOldIndexVersion.java @@ -27,7 +27,6 @@ import java.util.Map; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.io.Closer; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.Type; @@ -228,7 +227,7 @@ private void purgeOldIndexVersion(NodeStore store, List t NodeBuilder nodeBuilder = PurgeOldVersionUtils.getNode(rootBuilder, nodeName); if (nodeBuilder.exists()) { String type = nodeBuilder.getProperty(TYPE_PROPERTY_NAME).getValue(Type.STRING); - List indexEditorProviders = ImmutableList.of( + List indexEditorProviders = List.of( new ReferenceEditorProvider(), new PropertyIndexEditorProvider(), new NodeCounterEditorProvider()); EditorHook hook = new EditorHook(new IndexUpdateProvider(CompositeIndexEditorProvider.compose(indexEditorProviders))); if (toDeleteIndexNameObject.getOperation() == IndexVersionOperation.Operation.DELETE_HIDDEN_AND_DISABLE) { diff --git a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/ChildNodeStateProviderTest.java b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/ChildNodeStateProviderTest.java index 59f829c4a54..d558622065d 100644 --- a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/ChildNodeStateProviderTest.java +++ b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/ChildNodeStateProviderTest.java @@ -26,11 +26,11 @@ import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; @@ -60,17 +60,17 @@ public void children() { CountingIterable citr = createList(preferred, asList("/a", "/a/jcr:content", "/a/c", "/a/d", "/e", "/e/f", "/g", "/h")); ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred); - assertEquals(asList("jcr:content", "c", "d"), copyOf(childNames(p.children()))); + assertEquals(asList("jcr:content", "c", "d"), CollectionUtils.toList(childNames(p.children()))); assertEquals(5, citr.getCount()); citr.reset(); p = new ChildNodeStateProvider(citr, "/e", preferred); - assertEquals(singletonList("f"), copyOf(childNames(p.children()))); + assertEquals(singletonList("f"), CollectionUtils.toList(childNames(p.children()))); assertEquals(7, citr.getCount()); p = new ChildNodeStateProvider(citr, "/g", preferred); - assertEquals(emptyList(), copyOf(childNames(p.children()))); + assertEquals(emptyList(), CollectionUtils.toList(childNames(p.children()))); } @Test @@ -79,22 +79,22 @@ public void children2() { CountingIterable citr = createList(preferred, asList("/a", "/a/b", "/a/b/c", "/a/b/c/d", "/e", "/e/f", "/g", "/h")); ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred); - assertEquals(singletonList("b"), copyOf(childNames(p.children()))); + assertEquals(singletonList("b"), CollectionUtils.toList(childNames(p.children()))); assertEquals(5, citr.getCount()); citr.reset(); p = new ChildNodeStateProvider(citr, "/a/b", preferred); - assertEquals(singletonList("c"), copyOf(childNames(p.children()))); + assertEquals(singletonList("c"), CollectionUtils.toList(childNames(p.children()))); assertEquals(5, citr.getCount()); p = new ChildNodeStateProvider(citr, "/a/b/c", preferred); - assertEquals(singletonList("d"), copyOf(childNames(p.children()))); + assertEquals(singletonList("d"), CollectionUtils.toList(childNames(p.children()))); p = new ChildNodeStateProvider(citr, "/a/b/c/d", preferred); - assertEquals(emptyList(), copyOf(childNames(p.children()))); + assertEquals(emptyList(), CollectionUtils.toList(childNames(p.children()))); p = new ChildNodeStateProvider(citr, "/h", preferred); - assertEquals(emptyList(), copyOf(childNames(p.children()))); + assertEquals(emptyList(), CollectionUtils.toList(childNames(p.children()))); } @Test @@ -152,7 +152,7 @@ public void childNames() { CountingIterable citr = createList(preferred, asList("/a", "/a/jcr:content", "/a/c", "/a/d", "/e", "/e/f")); ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred); - assertEquals(asList("jcr:content", "c", "d"), copyOf(childNames(p.children()))); + assertEquals(asList("jcr:content", "c", "d"), CollectionUtils.toList(childNames(p.children()))); assertEquals(5, citr.getCount()); } @@ -163,7 +163,7 @@ public void childNames2() { "/a/c", "/a/c/status","/a/d", "/e", "/e/f")); ChildNodeStateProvider p = new ChildNodeStateProvider(citr, "/a", preferred); - assertEquals(asList("jcr:content", "c", "d"), copyOf(childNames(p.children()))); + assertEquals(asList("jcr:content", "c", "d"), CollectionUtils.toList(childNames(p.children()))); assertEquals(7, citr.getCount()); } diff --git a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/NodeStateEntryWriterTest.java b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/NodeStateEntryWriterTest.java index ddfc6b1f1d2..6b7c4e8fc37 100644 --- a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/NodeStateEntryWriterTest.java +++ b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/NodeStateEntryWriterTest.java @@ -16,13 +16,13 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.index.indexer.document.flatfile; import java.util.Arrays; import java.util.List; import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry; import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry.NodeStateEntryBuilder; import org.apache.jackrabbit.oak.spi.blob.BlobStore; @@ -32,7 +32,6 @@ import org.apache.jackrabbit.oak.spi.state.NodeState; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static org.apache.jackrabbit.oak.commons.PathUtils.elements; import static org.apache.jackrabbit.oak.index.indexer.document.flatfile.NodeStateEntryWriter.getPath; import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; @@ -112,7 +111,7 @@ public void pathElements(){ NodeStateEntry e1 = new NodeStateEntryBuilder(b1.getNodeState(), "/a/b/c/d").build(); String json = nw.asJson(e1.getNodeState()); - List pathElements = copyOf(elements(e1.getPath())); + List pathElements = CollectionUtils.toList(elements(e1.getPath())); String line = nw.toString(pathElements, json); @@ -132,7 +131,7 @@ public void pathElements_root(){ NodeStateEntry e1 = new NodeStateEntryBuilder(b1.getNodeState(), "/").build(); String json = nw.asJson(e1.getNodeState()); - List pathElements = copyOf(elements(e1.getPath())); + List pathElements = CollectionUtils.toList(elements(e1.getPath())); String line = nw.toString(pathElements, json); @@ -154,9 +153,9 @@ public void memUsage() { b.setProperty("foo1", "bar1"); String json2 = nw.asJson(b.getNodeState()); - String line1 = nw.toString(copyOf(elements("/")), json1); - String line2 = nw.toString(copyOf(elements("/sub-node")), json1); - String line3 = nw.toString(copyOf(elements("/sub-node")), json2); + String line1 = nw.toString(CollectionUtils.toList(elements("/")), json1); + String line2 = nw.toString(CollectionUtils.toList(elements("/sub-node")), json1); + String line3 = nw.toString(CollectionUtils.toList(elements("/sub-node")), json2); NodeStateEntryReader nr = new NodeStateEntryReader(blobStore); diff --git a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/TestUtils.java b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/TestUtils.java index e9d5b483b5e..66d831e8c63 100644 --- a/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/TestUtils.java +++ b/oak-run-commons/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/TestUtils.java @@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.index.indexer.document.flatfile; import org.apache.jackrabbit.guava.common.collect.Iterables; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry; import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry.NodeStateEntryBuilder; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; @@ -29,7 +30,6 @@ import java.util.Set; import java.util.function.Predicate; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static java.util.Collections.emptySet; import static java.util.stream.Collectors.toList; import static org.apache.jackrabbit.oak.commons.PathUtils.elements; @@ -51,7 +51,7 @@ static List extractPredicatePaths(List paths, Predicate static List sortPaths(List paths, Comparator> comparator) { List> copy = paths.stream() - .map(p -> copyOf(elements(p))) + .map(p -> CollectionUtils.toList(elements(p))) .sorted(comparator) .collect(toList()); return copy.stream().map(e -> "/" + String.join("/", e)).collect(toList()); diff --git a/oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionsCommandTest.java b/oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionsCommandTest.java index 3f2aad0865b..30dd2c07500 100644 --- a/oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionsCommandTest.java +++ b/oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionsCommandTest.java @@ -20,10 +20,12 @@ import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import java.util.concurrent.TimeUnit; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.oak.plugins.document.util.MongoConnection; import org.apache.jackrabbit.oak.run.RevisionsCommand; import org.junit.Before; @@ -409,11 +411,13 @@ private DocumentNodeStore createDocumentNodeStore(boolean fullGCEnabled) { private static class RevisionsCmd implements Runnable { - private final ImmutableList args; + private final List args; public RevisionsCmd(String... args) { - this.args = ImmutableList.builder().add(MongoUtils.URL) - .add(args).build(); + List builder = new ArrayList<>(); + builder.add(MongoUtils.URL); + builder.addAll(Arrays.asList(args)); + this.args = Collections.unmodifiableList(builder); } @Override diff --git a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCheckTest.java b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCheckTest.java index 3512ff16eca..6871a440215 100644 --- a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCheckTest.java +++ b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCheckTest.java @@ -40,7 +40,6 @@ import java.util.Random; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.guava.common.collect.Maps; @@ -203,7 +202,7 @@ public void testConsistency() throws Exception { Random rand = new Random(); String deletedBlobId = Iterables.get(blobsAdded, rand.nextInt(blobsAdded.size())); blobsAdded.remove(deletedBlobId); - long count = setupDataStore.countDeleteChunks(ImmutableList.of(deletedBlobId), 0); + long count = setupDataStore.countDeleteChunks(List.of(deletedBlobId), 0); assertEquals(1, count); setupDataStore.close(); @@ -224,7 +223,7 @@ public void testConsistencyVerbose() throws Exception { blobsAdded.remove(deletedBlobId); long count = setupDataStore - .countDeleteChunks(ImmutableList.of(deletedBlobId), + .countDeleteChunks(List.of(deletedBlobId), 0); assertEquals(1, count); setupDataStore.close(); @@ -250,11 +249,11 @@ public void testConsistencyWithDeleteTracker() throws Exception { Random rand = new Random(); String deletedBlobId = Iterables.get(blobsAdded, rand.nextInt(blobsAdded.size())); blobsAdded.remove(deletedBlobId); - long count = setupDataStore.countDeleteChunks(ImmutableList.of(deletedBlobId), 0); + long count = setupDataStore.countDeleteChunks(List.of(deletedBlobId), 0); String activeDeletedBlobId = Iterables.get(blobsAdded, rand.nextInt(blobsAdded.size())); blobsAdded.remove(activeDeletedBlobId); - count += setupDataStore.countDeleteChunks(ImmutableList.of(activeDeletedBlobId), 0); + count += setupDataStore.countDeleteChunks(List.of(activeDeletedBlobId), 0); assertEquals(2, count); // artificially put the deleted id in the tracked .del file @@ -281,11 +280,11 @@ public void testConsistencyVerboseWithDeleteTracker() throws Exception { Random rand = new Random(); String deletedBlobId = Iterables.get(blobsAdded, rand.nextInt(blobsAdded.size())); blobsAdded.remove(deletedBlobId); - long count = setupDataStore.countDeleteChunks(ImmutableList.of(deletedBlobId), 0); + long count = setupDataStore.countDeleteChunks(List.of(deletedBlobId), 0); String activeDeletedBlobId = Iterables.get(blobsAdded, rand.nextInt(blobsAdded.size())); blobsAdded.remove(activeDeletedBlobId); - count += setupDataStore.countDeleteChunks(ImmutableList.of(activeDeletedBlobId), 0); + count += setupDataStore.countDeleteChunks(List.of(activeDeletedBlobId), 0); assertEquals(2, count); // artificially put the deleted id in the tracked .del file diff --git a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCommandTest.java b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCommandTest.java index f0cc1d8d1fd..f2d0fdda85b 100644 --- a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCommandTest.java +++ b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DataStoreCommandTest.java @@ -42,7 +42,6 @@ import ch.qos.logback.classic.Level; import org.apache.jackrabbit.guava.common.base.Splitter; import org.apache.jackrabbit.guava.common.base.Strings; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.guava.common.collect.Maps; @@ -258,7 +257,7 @@ private static Data prepareData(StoreFixture storeFixture, DataStoreFixture blob } for (String id : data.missingDataStore) { - long count = blobStore.countDeleteChunks(ImmutableList.of(id), 0); + long count = blobStore.countDeleteChunks(List.of(id), 0); assertEquals(1, count); } @@ -1341,11 +1340,11 @@ class FileDataStoreFixture implements DataStoreFixture { static class FixtureHelper { static List getStoreFixtures() { - return ImmutableList.of(StoreFixture.MONGO, StoreFixture.SEGMENT, StoreFixture.SEGMENT_AZURE); + return List.of(StoreFixture.MONGO, StoreFixture.SEGMENT, StoreFixture.SEGMENT_AZURE); } static List getDataStoreFixtures() { - return ImmutableList.of(DataStoreFixture.S3, DataStoreFixture.AZURE, DataStoreFixture.FDS); + return List.of(DataStoreFixture.S3, DataStoreFixture.AZURE, DataStoreFixture.FDS); } static List get() { diff --git a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DocumentStoreCheckCommandTest.java b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DocumentStoreCheckCommandTest.java index 5083b29be6b..c2963ec7517 100644 --- a/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DocumentStoreCheckCommandTest.java +++ b/oak-run/src/test/java/org/apache/jackrabbit/oak/run/DocumentStoreCheckCommandTest.java @@ -21,8 +21,6 @@ import java.util.List; import java.util.UUID; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.document.DocumentMKBuilderProvider; @@ -237,7 +235,7 @@ private void merge(NodeBuilder builder, boolean withIndexUpdate) CommitHook hook = EmptyHook.INSTANCE; if (withIndexUpdate) { NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder); - IndexUtils.createIndexDefinition(index, "uuid", true, true, ImmutableList.of("jcr:uuid"), null); + IndexUtils.createIndexDefinition(index, "uuid", true, true, List.of("jcr:uuid"), null); hook = new EditorHook(new IndexUpdateProvider(new PropertyIndexEditorProvider())); } ns.merge(builder, hook, CommitInfo.EMPTY); diff --git a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/Aggregate.java b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/Aggregate.java index 09b72ebc3d3..69ce99079fd 100644 --- a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/Aggregate.java +++ b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/Aggregate.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.search; import java.util.ArrayList; @@ -28,9 +27,9 @@ import java.util.Map; import java.util.regex.Pattern; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.index.search.util.ConfigUtil; import org.apache.jackrabbit.oak.plugins.memory.MemoryChildNodeEntry; import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry; @@ -343,7 +342,7 @@ public String toString() { } public boolean matches(String nodePath) { - List pathElements = ImmutableList.copyOf(PathUtils.elements(nodePath)); + List pathElements = CollectionUtils.toList(PathUtils.elements(nodePath)); if (pathElements.size() != elements.length){ return false; } diff --git a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/PropertyDefinition.java b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/PropertyDefinition.java index 9310058a135..04eb55dd3c7 100644 --- a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/PropertyDefinition.java +++ b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/PropertyDefinition.java @@ -18,7 +18,6 @@ */ package org.apache.jackrabbit.oak.plugins.index.search; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static org.apache.jackrabbit.guava.common.collect.Iterables.toArray; import static org.apache.jackrabbit.oak.commons.PathUtils.elements; import static org.apache.jackrabbit.oak.commons.PathUtils.isAbsolute; @@ -32,6 +31,7 @@ import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.index.property.ValuePattern; import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition.IndexingRule; import org.apache.jackrabbit.oak.plugins.index.search.util.FunctionIndexProcessor; @@ -306,7 +306,7 @@ private static String[] computeAncestors(String path) { if (FulltextIndexConstants.REGEX_ALL_PROPS.equals(path)) { return EMPTY_ANCESTORS; } else { - return toArray(copyOf(elements(PathUtils.getParentPath(path))), String.class); + return toArray(CollectionUtils.toList(elements(PathUtils.getParentPath(path))), String.class); } } diff --git a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/util/IndexDefinitionBuilder.java b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/util/IndexDefinitionBuilder.java index c3bde0ea367..a55c0fcf30e 100644 --- a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/util/IndexDefinitionBuilder.java +++ b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/util/IndexDefinitionBuilder.java @@ -45,7 +45,6 @@ import static java.util.Arrays.asList; import static java.util.Objects.requireNonNull; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED; import static org.apache.jackrabbit.oak.api.Type.NAME; @@ -643,7 +642,7 @@ private static Tree getOrCreateChild(Tree tree, String name) { static class SelectiveEqualsDiff extends EqualsDiff { // Properties for which changes shouldn't auto set the reindex flag - static final List ignorablePropertiesList = of( + static final List ignorablePropertiesList = List.of( FulltextIndexConstants.PROP_WEIGHT, FIELD_BOOST, IndexConstants.USE_IF_EXISTS, @@ -653,7 +652,7 @@ static class SelectiveEqualsDiff extends EqualsDiff { FulltextIndexConstants.BLOB_SIZE, FulltextIndexConstants.COST_PER_ENTRY, FulltextIndexConstants.COST_PER_EXECUTION); - static final List ignorableFacetConfigProps = of( + static final List ignorableFacetConfigProps = List.of( FulltextIndexConstants.PROP_SECURE_FACETS, FulltextIndexConstants.PROP_STATISTICAL_FACET_SAMPLE_SIZE, FulltextIndexConstants.PROP_FACETS_TOP_CHILDREN); diff --git a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexAndTraversalQueriesSimilarResultsCommonTest.java b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexAndTraversalQueriesSimilarResultsCommonTest.java index 0b86a878cf4..c3f871ba078 100644 --- a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexAndTraversalQueriesSimilarResultsCommonTest.java +++ b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexAndTraversalQueriesSimilarResultsCommonTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.plugins.index; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.plugins.index.search.util.IndexDefinitionBuilder; import org.apache.jackrabbit.oak.query.AbstractQueryTest; @@ -78,14 +77,14 @@ protected Tree setIndex(IndexDefinitionBuilder builder, String idxName) { * - The queries that have different results between traversal and the indexes, for the most part also produce * different results between Elastic and Lucene. */ - protected List queriesWithSameResults = ImmutableList.of( + protected List queriesWithSameResults = List.of( // Full-text queries "/jcr:root//*[jcr:contains(@propa, '*')]", "/jcr:root//*[jcr:contains(@propa, '123*')]", "/jcr:root//*[jcr:contains(@propa, 'fal*')]" ); - protected List queriesWithDifferentResults = ImmutableList.of( + protected List queriesWithDifferentResults = List.of( "/jcr:root//*[@propa]", "/jcr:root//*[@propa > 0]", "/jcr:root//*[@propa > '0']", diff --git a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexExclusionQueryCommonTest.java b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexExclusionQueryCommonTest.java index a813ebe4c94..82c40abcd19 100644 --- a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexExclusionQueryCommonTest.java +++ b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexExclusionQueryCommonTest.java @@ -22,7 +22,6 @@ import java.util.List; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static javax.jcr.PropertyType.TYPENAME_BINARY; import static javax.jcr.PropertyType.TYPENAME_STRING; import static org.apache.jackrabbit.JcrConstants.JCR_LASTMODIFIED; @@ -47,8 +46,8 @@ public abstract class IndexExclusionQueryCommonTest extends AbstractQueryTest { protected void createTestIndexNode() throws Exception { Tree index = createTestIndexNode(root.getTree("/"), indexOptions.getIndexType()); index.setProperty(INCLUDE_PROPERTY_TYPES, - of(TYPENAME_BINARY, TYPENAME_STRING), STRINGS); - index.setProperty(EXCLUDE_PROPERTY_NAMES, of(NOT_IN), STRINGS); + List.of(TYPENAME_BINARY, TYPENAME_STRING), STRINGS); + index.setProperty(EXCLUDE_PROPERTY_NAMES, List.of(NOT_IN), STRINGS); TestUtil.useV2(index); root.commit(); } @@ -72,12 +71,12 @@ public void ignoreByType() throws Exception { + " and (@" + JCR_LASTMODIFIED + " > xs:dateTime('2014-04-01T08:58:03.231Z')) ]"; - TestUtil.assertEventually(() -> assertQuery(query, "xpath", of("/content/two")), 3000 * 3); + TestUtil.assertEventually(() -> assertQuery(query, "xpath", List.of("/content/two")), 3000 * 3); } @Test public void ignoreByName() throws Exception { - final List expected = of("/content/two"); + final List expected = List.of("/content/two"); Tree content = root.getTree("/").addChild("content"); Tree one = content.addChild("one"); @@ -117,7 +116,7 @@ public void ignoreByName2() throws Exception { // Should not return /content/two since there, querty value is set for notincluded property which // is part of excluded properties in the index definition - TestUtil.assertEventually(() -> assertQuery(query, "xpath", of("/content/one")), 3000 * 3); + TestUtil.assertEventually(() -> assertQuery(query, "xpath", List.of("/content/one")), 3000 * 3); } @Test @@ -138,7 +137,7 @@ public void ignoreByType2() throws Exception { // Assert /content/two is not returned since it matches 2014 from DATE type property field which is not part of // includePropertyTypes in the index definition String query = "/jcr:root/content//*[jcr:contains(., '2014')]"; - TestUtil.assertEventually(() -> assertQuery(query, "xpath", of("/content/one")), 3000 * 3); + TestUtil.assertEventually(() -> assertQuery(query, "xpath", List.of("/content/one")), 3000 * 3); } } diff --git a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexPlannerCommonTest.java b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexPlannerCommonTest.java index ebba33eca46..e8a557e923c 100644 --- a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexPlannerCommonTest.java +++ b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexPlannerCommonTest.java @@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.plugins.index; import org.apache.commons.lang3.RandomStringUtils; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants; @@ -104,7 +103,7 @@ public void planForSortField() throws Exception { defn.setProperty(createProperty(ORDERED_PROP_NAMES, Set.of("foo"), STRINGS)); IndexNode node = createIndexNode(getIndexDefinition(root, defn.getNodeState(), "/oak:index/" + indexName)); FulltextIndexPlanner planner = getIndexPlanner(node, "/oak:index/" + indexName, createFilter("nt:base"), - ImmutableList.of(new QueryIndex.OrderEntry("foo", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); + List.of(new QueryIndex.OrderEntry("foo", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); assertNotNull(planner.getPlan()); assertTrue(pr(planner.getPlan()).isUniquePathsRequired()); } @@ -114,7 +113,7 @@ public void noPlanForSortOnlyByScore() throws Exception { NodeBuilder defn = getPropertyIndexDefinitionNodeBuilder(builder, indexName, Set.of("foo"), "async"); IndexNode node = createIndexNode(getIndexDefinition(root, defn.getNodeState(), "/oak:index/" + indexName)); FulltextIndexPlanner planner = getIndexPlanner(node, "/oak:index/" + indexName, createFilter("nt:file"), - ImmutableList.of(new QueryIndex.OrderEntry("jcr:score", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); + List.of(new QueryIndex.OrderEntry("jcr:score", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); assertNull(planner.getPlan()); } @@ -1158,7 +1157,7 @@ public void syncIndex_NotUsedWithSort() throws Exception { TestUtil.assertEventually(() -> { FulltextIndexPlanner planner = getIndexPlanner(node, "/oak:index/" + indexName, filter, - ImmutableList.of(new QueryIndex.OrderEntry("bar", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); + List.of(new QueryIndex.OrderEntry("bar", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); QueryIndex.IndexPlan plan = planner.getPlan(); assertNotNull(plan); @@ -1184,7 +1183,7 @@ public void syncIndex_NotUsedWithFulltext() throws Exception { TestUtil.assertEventually(() -> { FulltextIndexPlanner planner = getIndexPlanner(node, "/oak:index/" + indexName, filter, - ImmutableList.of(new QueryIndex.OrderEntry("bar", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); + List.of(new QueryIndex.OrderEntry("bar", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); QueryIndex.IndexPlan plan = planner.getPlan(); assertNotNull(plan); @@ -1338,7 +1337,7 @@ public void noRestrictionWithSingleSortableField() throws Exception { TestUtil.assertEventually(() -> { FulltextIndexPlanner planner = getIndexPlanner(node, "/oak:index/" + indexName, createFilter("nt:base"), - ImmutableList.of(new QueryIndex.OrderEntry("foo", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING), + List.of(new QueryIndex.OrderEntry("foo", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING), new QueryIndex.OrderEntry("bar", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); assertNotNull(planner.getPlan()); assertEquals(1, planner.getPlan().getEstimatedEntryCount()); @@ -1356,7 +1355,7 @@ public void noRestrictionWithTwoSortableFields() throws Exception { TestUtil.assertEventually(() -> { FulltextIndexPlanner planner = getIndexPlanner(node, "/oak:index/" + indexName, createFilter("nt:base"), - ImmutableList.of(new QueryIndex.OrderEntry("foo", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING), + List.of(new QueryIndex.OrderEntry("foo", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING), new QueryIndex.OrderEntry("bar", Type.LONG, QueryIndex.OrderEntry.Order.ASCENDING))); assertNotNull(planner.getPlan()); diff --git a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/search/AggregateTest.java b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/search/AggregateTest.java index 38ac728f152..ab4936ef038 100644 --- a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/search/AggregateTest.java +++ b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/search/AggregateTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.search; import java.util.ArrayList; @@ -42,7 +41,6 @@ import org.apache.jackrabbit.oak.spi.state.NodeState; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.guava.common.collect.Iterables.toArray; import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; @@ -71,7 +69,7 @@ public class AggregateTest { @Test public void oneLevelAll() { - Aggregate ag = new Aggregate("nt:base", of(ni("*"))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("*"))); NodeBuilder nb = newNode("nt:base"); nb.child("a").child("c"); nb.child("b"); @@ -83,7 +81,7 @@ public void oneLevelAll() { @Test public void oneLevelNamed() { - Aggregate ag = new Aggregate("nt:base", of(ni("a"))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("a"))); NodeBuilder nb = newNode("nt:base"); nb.child("a"); nb.child("b"); @@ -95,7 +93,7 @@ public void oneLevelNamed() { @Test public void noOfChildNodeRead() { - Aggregate ag = new Aggregate("nt:base", of(ni("a"))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("a"))); NodeBuilder nb = newNode("nt:base"); nb.child("a"); for (int i = 0; i < 10; i++) { @@ -119,7 +117,7 @@ public void noOfChildNodeRead() { @Test public void oneLevelTyped() { - Aggregate ag = new Aggregate("nt:base", of(ni("nt:resource","*", false))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("nt:resource","*", false))); NodeBuilder nb = newNode("nt:base"); nb.child("a").setProperty(JCR_PRIMARYTYPE,"nt:resource"); nb.child("b"); @@ -131,7 +129,7 @@ public void oneLevelTyped() { @Test public void oneLevelTypedMixin() { - Aggregate ag = new Aggregate("nt:base", of(ni("mix:title","*", false))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("mix:title","*", false))); NodeBuilder nb = newNode("nt:base"); nb.child("a").setProperty(JcrConstants.JCR_MIXINTYPES, Collections.singleton("mix:title"), Type.NAMES); nb.child("b"); @@ -143,7 +141,7 @@ public void oneLevelTypedMixin() { @Test public void multiLevelAll() { - Aggregate ag = new Aggregate("nt:base", of(ni("*"), ni("*/*"))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("*"), ni("*/*"))); NodeBuilder nb = newNode("nt:base"); nb.child("a").child("c"); nb.child("b"); @@ -156,7 +154,7 @@ public void multiLevelAll() { @Test public void multiLevelNamed() { - Aggregate ag = new Aggregate("nt:base", of(ni("a"), ni("d/e"))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("a"), ni("d/e"))); NodeBuilder nb = newNode("nt:base"); nb.child("a").child("c"); nb.child("b"); @@ -169,7 +167,7 @@ public void multiLevelNamed() { @Test public void multiLevelTyped() { - Aggregate ag = new Aggregate("nt:base", of(ni("a"), + Aggregate ag = new Aggregate("nt:base", List.of(ni("a"), ni("nt:resource", "d/*/*", false))); NodeBuilder nb = newNode("nt:base"); nb.child("a").child("c"); @@ -185,7 +183,7 @@ public void multiLevelTyped() { @Test public void multiLevelNamedSubAll() { - Aggregate ag = new Aggregate("nt:base", of(ni("a"), ni("d/*/*"))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("a"), ni("d/*/*"))); NodeBuilder nb = newNode("nt:base"); nb.child("a").child("c"); nb.child("b"); @@ -202,9 +200,9 @@ public void multiLevelNamedSubAll() { @Test public void multiAggregateMapping() { - Aggregate ag = new Aggregate("nt:base", of(ni("*"))); + Aggregate ag = new Aggregate("nt:base", List.of(ni("*"))); - Aggregate agFile = new Aggregate("nt:file", of(ni("*"), ni("*/*"))); + Aggregate agFile = new Aggregate("nt:file", List.of(ni("*"), ni("*/*"))); mapper.add("nt:file", agFile); NodeBuilder nb = newNode("nt:base"); @@ -220,7 +218,7 @@ public void multiAggregateMapping() { @Test public void recursionEnabled() { - Aggregate agFile = new Aggregate("nt:file", of(ni("*")), 5); + Aggregate agFile = new Aggregate("nt:file", List.of(ni("*")), 5); mapper.add("nt:file", agFile); NodeBuilder nb = newNode("nt:file"); @@ -237,7 +235,7 @@ public void recursionEnabled() { @Test public void recursionEnabledWithLimitCheck() { int limit = 5; - Aggregate agFile = new Aggregate("nt:file", of(ni("*")), limit); + Aggregate agFile = new Aggregate("nt:file", List.of(ni("*")), limit); mapper.add("nt:file", agFile); List expectedPaths = new ArrayList<>(); @@ -265,12 +263,12 @@ public void recursionEnabledWithLimitCheck() { @Test public void includeMatches() { - Aggregate ag = new Aggregate("nt:base", of(ni(null, "*", true), ni(null, "*/*", true))); + Aggregate ag = new Aggregate("nt:base", List.of(ni(null, "*", true), ni(null, "*/*", true))); assertTrue(ag.hasRelativeNodeInclude("foo")); assertTrue(ag.hasRelativeNodeInclude("foo/bar")); assertFalse(ag.hasRelativeNodeInclude("foo/bar/baz")); - Aggregate ag2 = new Aggregate("nt:base", of(ni(null, "foo", true), ni(null, "foo/*", true))); + Aggregate ag2 = new Aggregate("nt:base", List.of(ni(null, "foo", true), ni(null, "foo/*", true))); assertTrue(ag2.hasRelativeNodeInclude("foo")); assertFalse(ag2.hasRelativeNodeInclude("bar")); assertTrue(ag2.hasRelativeNodeInclude("foo/bar")); @@ -281,9 +279,9 @@ public void includeMatches() { public void testReaggregate() { //Enable relative include for all child nodes of nt:folder //So indexing would create fulltext field for each relative nodes - Aggregate agFolder = new Aggregate("nt:folder", of(ni("nt:file", "*", true))); + Aggregate agFolder = new Aggregate("nt:folder", List.of(ni("nt:file", "*", true))); - Aggregate agFile = new Aggregate("nt:file", of(ni(null, "jcr:content", true))); + Aggregate agFile = new Aggregate("nt:file", List.of(ni(null, "jcr:content", true))); mapper.add("nt:file", agFile); mapper.add("nt:folder", agFolder); @@ -312,9 +310,9 @@ public void testReaggregateMixin() { //Enable relative include for all child nodes of nt:folder //So indexing would create fulltext field for each relative nodes - Aggregate agFolder = new Aggregate("nt:folder", of(ni("mix:title", "*", true))); + Aggregate agFolder = new Aggregate("nt:folder", List.of(ni("mix:title", "*", true))); - Aggregate agFile = new Aggregate("mix:title", of(ni(null, "jcr:content", true))); + Aggregate agFile = new Aggregate("mix:title", List.of(ni(null, "jcr:content", true))); mapper.add("mix:title", agFile); mapper.add("nt:folder", agFolder); @@ -338,7 +336,7 @@ public void testReaggregateMixin() { public void testRelativeNodeInclude() { //Enable relative include for all child nodes of nt:folder //So indexing would create fulltext field for each relative nodes - Aggregate agContent = new Aggregate("app:Page", of(ni(null, "jcr:content", true))); + Aggregate agContent = new Aggregate("app:Page", List.of(ni(null, "jcr:content", true))); mapper.add("app:Page", agContent); diff --git a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/CompositeConfiguration.java b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/CompositeConfiguration.java index 64a669bb152..e0dd31f5ee0 100644 --- a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/CompositeConfiguration.java +++ b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/CompositeConfiguration.java @@ -18,7 +18,6 @@ */ package org.apache.jackrabbit.oak.spi.security; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.guava.common.collect.ObjectArrays; @@ -45,6 +44,7 @@ import org.osgi.framework.Constants; import java.security.Principal; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; @@ -142,9 +142,9 @@ public void removeConfiguration(@NotNull T configuration) { @NotNull public List getConfigurations() { if (configurations.isEmpty() && defaultConfig != null) { - return ImmutableList.of(defaultConfig); + return List.of(defaultConfig); } else { - return ImmutableList.copyOf(configurations); + return List.copyOf(configurations); } } @@ -221,20 +221,21 @@ public RepositoryInitializer getRepositoryInitializer() { public List getCommitHooks(@NotNull final String workspaceName) { Iterable t = Iterables.concat(Lists.transform(getConfigurations(), securityConfiguration -> securityConfiguration.getCommitHooks(workspaceName))); - return ImmutableList.copyOf(t); + return Collections.unmodifiableList(CollectionUtils.toList(t)); } @NotNull @Override public List getValidators(@NotNull final String workspaceName, @NotNull final Set principals, @NotNull final MoveTracker moveTracker) { Iterable t = Iterables.concat(Lists.transform(getConfigurations(), securityConfiguration -> securityConfiguration.getValidators(workspaceName, principals, moveTracker))); - return ImmutableList.copyOf(t); + return Collections.unmodifiableList(CollectionUtils.toList(t)); } @NotNull @Override public List getConflictHandlers() { - return ImmutableList.copyOf(Iterables.concat(Lists.transform(getConfigurations(), securityConfiguration -> securityConfiguration.getConflictHandlers()))); + return CollectionUtils.toList(Iterables.concat(Lists.transform(getConfigurations(), + securityConfiguration -> securityConfiguration.getConflictHandlers()))); } @NotNull @@ -242,7 +243,7 @@ public List getConflictHandlers() { public List getProtectedItemImporters() { Iterable t = Iterables.concat(Lists.transform(getConfigurations(), securityConfiguration -> securityConfiguration.getProtectedItemImporters())); - return ImmutableList.copyOf(t); + return Collections.unmodifiableList(CollectionUtils.toList(t)); } @NotNull diff --git a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/OpenSecurityProvider.java b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/OpenSecurityProvider.java index 32945766d28..a18656b1c19 100644 --- a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/OpenSecurityProvider.java +++ b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/OpenSecurityProvider.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration; import org.apache.jackrabbit.oak.spi.security.authentication.OpenAuthenticationConfiguration; import org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration; @@ -24,6 +23,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.List; + /** * Rudimentary {@code SecurityProvider} implementation that allow every subject * to authenticate and grants it full access everywhere. Note, that this @@ -44,7 +45,7 @@ public ConfigurationParameters getParameters(@Nullable String name) { @NotNull @Override public Iterable getConfigurations() { - return ImmutableList.of(new OpenAuthenticationConfiguration(), new OpenAuthorizationConfiguration()); + return List.of(new OpenAuthenticationConfiguration(), new OpenAuthorizationConfiguration()); } @NotNull diff --git a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/token/CompositeTokenProvider.java b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/token/CompositeTokenProvider.java index 354799349eb..55b1a7c3c6a 100644 --- a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/token/CompositeTokenProvider.java +++ b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/token/CompositeTokenProvider.java @@ -21,8 +21,6 @@ import java.util.Map; import javax.jcr.Credentials; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -35,7 +33,7 @@ public final class CompositeTokenProvider implements TokenProvider { private final List providers; private CompositeTokenProvider(@NotNull List providers) { - this.providers = ImmutableList.copyOf(providers); + this.providers = List.copyOf(providers); } @NotNull diff --git a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ImmutableACL.java b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ImmutableACL.java index 3c264d2a196..d22aaf57859 100644 --- a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ImmutableACL.java +++ b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ImmutableACL.java @@ -26,7 +26,6 @@ import javax.jcr.security.AccessControlException; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry; import org.apache.jackrabbit.oak.namepath.NamePathMapper; import org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider; @@ -57,7 +56,7 @@ public ImmutableACL(@Nullable String oakPath, @NotNull RestrictionProvider restrictionProvider, @NotNull NamePathMapper namePathMapper) { super(oakPath, namePathMapper); - this.entries = ImmutableList.copyOf(entries); + this.entries = List.copyOf(entries); this.restrictionProvider = restrictionProvider; } diff --git a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/AbstractRestrictionProvider.java b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/AbstractRestrictionProvider.java index b811eb00bf9..7da5e9e5ca4 100644 --- a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/AbstractRestrictionProvider.java +++ b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/AbstractRestrictionProvider.java @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -30,7 +31,6 @@ import javax.jcr.Value; import javax.jcr.security.AccessControlException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; @@ -85,7 +85,7 @@ public Restriction createRestriction(@Nullable String oakPath, @NotNull String o } PropertyState propertyState; if (requiredType.isArray()) { - propertyState = PropertyStates.createProperty(oakName, ImmutableList.of(value), tag); + propertyState = PropertyStates.createProperty(oakName, List.of(value), tag); } else { propertyState = PropertyStates.createProperty(oakName, value); } diff --git a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/xml/PropInfo.java b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/xml/PropInfo.java index 8451aa1a551..36d9ec2de50 100644 --- a/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/xml/PropInfo.java +++ b/oak-security-spi/src/main/java/org/apache/jackrabbit/oak/spi/xml/PropInfo.java @@ -25,7 +25,6 @@ import javax.jcr.Value; import javax.jcr.nodetype.PropertyDefinition; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; import org.jetbrains.annotations.NotNull; @@ -73,7 +72,7 @@ public enum MultipleStatus { UNKNOWN, MULTIPLE } * @param value value of the property being imported */ public PropInfo(@Nullable String name, int type, @NotNull TextValue value) { - this(name, type, ImmutableList.of(value), MultipleStatus.UNKNOWN); + this(name, type, List.of(value), MultipleStatus.UNKNOWN); } /** @@ -100,7 +99,7 @@ public PropInfo(@Nullable String name, int type, @NotNull MultipleStatus multipleStatus) { this.name = name; this.type = type; - this.values = ImmutableList.copyOf(values); + this.values = List.copyOf(values); this.multipleStatus = multipleStatus; } diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/plugins/tree/TreeUtilTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/plugins/tree/TreeUtilTest.java index 79f9ce11c5d..d84e973f252 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/plugins/tree/TreeUtilTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/plugins/tree/TreeUtilTest.java @@ -16,9 +16,7 @@ */ package org.apache.jackrabbit.oak.plugins.tree; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; @@ -310,7 +308,7 @@ public void testAddChildWithOrderableChildren() throws Exception { Tree parent = when(mockTree("/some/tree", true).addChild("name")).thenReturn(t).getMock(); when(ntDef.getProperty(JCR_HASORDERABLECHILDNODES)).thenReturn(PropertyStates.createProperty(JCR_HASORDERABLECHILDNODES, true, Type.BOOLEAN)); - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithoutChildren); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(defWithoutChildren); @@ -328,10 +326,10 @@ public void testAddChildWithDefaultChildType() throws Exception { Tree defWithChild = mock(Tree.class); when(defWithChild.getProperty(JCR_DEFAULTPRIMARYTYPE)).thenReturn(PropertyStates.createProperty(JCR_DEFAULTPRIMARYTYPE, NT_OAK_UNSTRUCTURED, Type.NAME)); when(defWithChild.getChild("name")).thenReturn(defWithChild); - when(defWithChild.getChildren()).thenReturn(ImmutableList.of(defWithChild)); + when(defWithChild.getChildren()).thenReturn(List.of(defWithChild)); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(defWithChild); - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithoutChildren); when(ntDef.getProperty(JCR_IS_ABSTRACT)).thenReturn(PropertyStates.createProperty(JCR_IS_ABSTRACT, true, Type.BOOLEAN)); @@ -418,7 +416,7 @@ public void testAddMixinAlreadyContainedNoPrimary() throws Exception { @Test public void testAddMixinSuPrimary() throws Exception { when(ntDef.getProperty(JCR_ISMIXIN)).thenReturn(PropertyStates.createProperty(JCR_ISMIXIN, true, Type.BOOLEAN)); - when(ntDef.getProperty(REP_PRIMARY_SUBTYPES)).thenReturn(PropertyStates.createProperty(REP_PRIMARY_SUBTYPES, ImmutableList.of(NT_OAK_UNSTRUCTURED), Type.NAMES)); + when(ntDef.getProperty(REP_PRIMARY_SUBTYPES)).thenReturn(PropertyStates.createProperty(REP_PRIMARY_SUBTYPES, List.of(NT_OAK_UNSTRUCTURED), Type.NAMES)); when(typeRoot.getChild("containsSubPrimary")).thenReturn(ntDef); TreeUtil.addMixin(child, "containsSubPrimary", typeRoot, "userId"); @@ -430,7 +428,7 @@ public void testAddMixinSuPrimary() throws Exception { @Test public void testAddMixinSubMixin() throws Exception { when(ntDef.getProperty(JCR_ISMIXIN)).thenReturn(PropertyStates.createProperty(JCR_ISMIXIN, true, Type.BOOLEAN)); - when(ntDef.getProperty(REP_MIXIN_SUBTYPES)).thenReturn(PropertyStates.createProperty(REP_MIXIN_SUBTYPES, ImmutableList.of(MIX_VERSIONABLE), Type.NAMES)); + when(ntDef.getProperty(REP_MIXIN_SUBTYPES)).thenReturn(PropertyStates.createProperty(REP_MIXIN_SUBTYPES, List.of(MIX_VERSIONABLE), Type.NAMES)); when(typeRoot.getChild("containsSubMixin")).thenReturn(ntDef); TreeUtil.addMixin(child, "containsSubMixin", typeRoot, "userId"); @@ -441,7 +439,7 @@ public void testAddMixinSubMixin() throws Exception { @Test public void testAddMixin() throws Exception { - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getProperty(JCR_ISMIXIN)).thenReturn(PropertyStates.createProperty(JCR_ISMIXIN, true, Type.BOOLEAN)); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithoutChildren); @@ -457,8 +455,8 @@ public void testAddMixin() throws Exception { @Test public void testAutoCreateItemsNoAutoCreateDefs() throws Exception { Tree noAutoCreate = when(mockTree("/definitions/definition/notAutoCreate", true).getProperty(JCR_AUTOCREATED)).thenReturn(PropertyStates.createProperty(JCR_AUTOCREATED, false)).getMock(); - Tree defWithChildren = when(mockTree("/definitions/definition", true).getChildren()).thenReturn(ImmutableList.of(noAutoCreate)).getMock(); - Tree definitions = when(mockTree("/definitions", true).getChildren()).thenReturn(ImmutableList.of(defWithChildren)).getMock(); + Tree defWithChildren = when(mockTree("/definitions/definition", true).getChildren()).thenReturn(List.of(noAutoCreate)).getMock(); + Tree definitions = when(mockTree("/definitions", true).getChildren()).thenReturn(List.of(defWithChildren)).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(definitions); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(definitions); @@ -471,13 +469,13 @@ public void testAutoCreateItemsNoAutoCreateDefs() throws Exception { @Test public void testAutoCreateItemsExcludedProperties() throws Exception { - List list = ImmutableList.of( + List list = List.of( mockTree("/some/path/"+ REP_PRIMARY_TYPE, true), mockTree("/some/path/" + REP_MIXIN_TYPES, true)); Tree defWithExcludedProperties = when(mock(Tree.class).getChildren()).thenReturn(list).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithExcludedProperties); - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(defWithoutChildren); TreeUtil.autoCreateItems(child, ntDef, typeRoot, "userId"); @@ -490,11 +488,11 @@ public void testAutoCreateItemsExcludedProperties() throws Exception { public void testAutoCreateItemsExistingUuid() throws Exception { Tree definition = when(mock(Tree.class).getProperty(JCR_AUTOCREATED)).thenReturn(PropertyStates.createProperty(JCR_AUTOCREATED, true)).getMock(); Tree definitions = mockTree("/some/path/"+ REP_UUID, true); - when(definitions.getChildren()).thenReturn(ImmutableList.of(definition)); - Tree defWithExcludedProperties = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(definitions)).getMock(); + when(definitions.getChildren()).thenReturn(List.of(definition)); + Tree defWithExcludedProperties = when(mock(Tree.class).getChildren()).thenReturn(List.of(definitions)).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithExcludedProperties); - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(defWithoutChildren); when(child.hasProperty(JCR_UUID)).thenReturn(true); @@ -509,11 +507,11 @@ public void testAutoCreateItemsExistingUuid() throws Exception { public void testAutoCreateItemsMissingUuid() throws Exception { Tree definition = when(mock(Tree.class).getProperty(JCR_AUTOCREATED)).thenReturn(PropertyStates.createProperty(JCR_AUTOCREATED, true)).getMock(); Tree definitions = mockTree("/some/path/"+ REP_UUID, true); - when(definitions.getChildren()).thenReturn(ImmutableList.of(definition)); - Tree defWithExcludedProperties = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(definitions)).getMock(); + when(definitions.getChildren()).thenReturn(List.of(definition)); + Tree defWithExcludedProperties = when(mock(Tree.class).getChildren()).thenReturn(List.of(definitions)).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithExcludedProperties); - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(defWithoutChildren); when(child.hasProperty(JCR_UUID)).thenReturn(false); @@ -528,11 +526,11 @@ public void testAutoCreateItemsMissingUuid() throws Exception { public void testAutoCreateItemsMissingDefaultValue() throws Exception { Tree definition = when(mock(Tree.class).getProperty(JCR_AUTOCREATED)).thenReturn(PropertyStates.createProperty(JCR_AUTOCREATED, true)).getMock(); Tree definitions = mockTree("/some/path/unknownProperty", true); - when(definitions.getChildren()).thenReturn(ImmutableList.of(definition)); - Tree defWithExcludedProperties = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(definitions)).getMock(); + when(definitions.getChildren()).thenReturn(List.of(definition)); + Tree defWithExcludedProperties = when(mock(Tree.class).getChildren()).thenReturn(List.of(definitions)).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithExcludedProperties); - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(defWithoutChildren); when(child.hasProperty("unknownProperty")).thenReturn(false); @@ -543,12 +541,12 @@ public void testAutoCreateItemsMissingDefaultValue() throws Exception { public void testAutoCreateItemsExistingChild() throws Exception { Tree definition = when(mock(Tree.class).getProperty(JCR_AUTOCREATED)).thenReturn(PropertyStates.createProperty(JCR_AUTOCREATED, true)).getMock(); Tree definitions = mockTree("/some/path/autoChild", true); - when(definitions.getChildren()).thenReturn(ImmutableList.of(definition)); + when(definitions.getChildren()).thenReturn(List.of(definition)); - Tree defWithAutoChild = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(definitions)).getMock(); + Tree defWithAutoChild = when(mock(Tree.class).getChildren()).thenReturn(List.of(definitions)).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(defWithAutoChild); - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithoutChildren); when(child.hasChild("autoChild")).thenReturn(true); @@ -565,12 +563,12 @@ public void testAutoCreateItemsNonExistingChild() throws Exception { when(definition.getProperty(JCR_DEFAULTPRIMARYTYPE)).thenReturn(PropertyStates.createProperty(JCR_DEFAULTPRIMARYTYPE, NT_OAK_UNSTRUCTURED, Type.NAME)); Tree definitions = mockTree("/some/path/autoChild", true); - when(definitions.getChildren()).thenReturn(ImmutableList.of(definition)); + when(definitions.getChildren()).thenReturn(List.of(definition)); - Tree defWithAutoChild = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(definitions)).getMock(); + Tree defWithAutoChild = when(mock(Tree.class).getChildren()).thenReturn(List.of(definitions)).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(defWithAutoChild); - Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree defWithoutChildren = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); when(ntDef.getChild(REP_NAMED_PROPERTY_DEFINITIONS)).thenReturn(defWithoutChildren); Tree newChild = mock(Tree.class); @@ -606,7 +604,7 @@ public void testAutoCreatePropertyBuiltIn() { @Test public void testAutoCreatePropertyFromDefaultValues() { - PropertyState defaultSingleValue = PropertyStates.createProperty(JCR_DEFAULTVALUES, ImmutableList.of(34L), Type.LONGS); + PropertyState defaultSingleValue = PropertyStates.createProperty(JCR_DEFAULTVALUES, List.of(34L), Type.LONGS); when(propDef.getProperty(JCR_DEFAULTVALUES)).thenReturn(defaultSingleValue); when(propDef.getProperty(JCR_MULTIPLE)).thenReturn(PropertyStates.createProperty(JCR_MULTIPLE, false)); @@ -619,7 +617,7 @@ public void testAutoCreatePropertyFromDefaultValues() { @Test public void testAutoCreatePropertyFromEmptyDefaultValues() { - PropertyState defaultSingleValue = PropertyStates.createProperty(JCR_DEFAULTVALUES, ImmutableList.of(), Type.DATES); + PropertyState defaultSingleValue = PropertyStates.createProperty(JCR_DEFAULTVALUES, List.of(), Type.DATES); when(propDef.getProperty(JCR_DEFAULTVALUES)).thenReturn(defaultSingleValue); when(propDef.getProperty(JCR_MULTIPLE)).thenReturn(PropertyStates.createProperty(JCR_MULTIPLE, false)); @@ -629,7 +627,7 @@ public void testAutoCreatePropertyFromEmptyDefaultValues() { @Test public void testAutoCreatePropertyFromMvDefaultValues() { - PropertyState defaultMvValue = PropertyStates.createProperty(JCR_DEFAULTVALUES, ImmutableList.of(true, false, true), Type.BOOLEANS); + PropertyState defaultMvValue = PropertyStates.createProperty(JCR_DEFAULTVALUES, List.of(true, false, true), Type.BOOLEANS); when(propDef.getProperty(JCR_DEFAULTVALUES)).thenReturn(defaultMvValue); when(propDef.getProperty(JCR_MULTIPLE)).thenReturn(PropertyStates.createProperty(JCR_MULTIPLE, true)); @@ -643,7 +641,7 @@ public void testAutoCreatePropertyFromMvDefaultValues() { @Test public void testGetDefaultChildTypeFromNamed() { Tree def = mock(Tree.class); - Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(def)).getMock(); + Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(List.of(def)).getMock(); PropertyState ps = PropertyStates.createProperty(JCR_DEFAULTPRIMARYTYPE, NT_RESOURCE, Type.NAME); when(def.getProperty(JCR_DEFAULTPRIMARYTYPE)).thenReturn(ps); PropertyState sns = PropertyStates.createProperty(JCR_SAMENAMESIBLINGS, false, Type.BOOLEAN); @@ -652,7 +650,7 @@ public void testGetDefaultChildTypeFromNamed() { Tree named = when(mock(Tree.class).getChild("newChild")).thenReturn(definitions).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(named); - Tree emptyDefinitions = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(def)).getMock(); + Tree emptyDefinitions = when(mock(Tree.class).getChildren()).thenReturn(List.of(def)).getMock(); when(ntDef.getChild(REP_RESIDUAL_CHILD_NODE_DEFINITIONS)).thenReturn(emptyDefinitions); assertEquals(NT_RESOURCE, TreeUtil.getDefaultChildType(typeRoot, child, "newChild")); @@ -662,7 +660,7 @@ public void testGetDefaultChildTypeFromNamed() { @Test public void testGetDefaultChildTypeFromNamedWithSns() { Tree def = mock(Tree.class); - Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(def)).getMock(); + Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(List.of(def)).getMock(); PropertyState ps = PropertyStates.createProperty(JCR_DEFAULTPRIMARYTYPE, NT_RESOURCE, Type.NAME); when(def.getProperty(JCR_DEFAULTPRIMARYTYPE)).thenReturn(ps); PropertyState sns = PropertyStates.createProperty(JCR_SAMENAMESIBLINGS, true, Type.BOOLEAN); @@ -677,7 +675,7 @@ public void testGetDefaultChildTypeFromNamedWithSns() { @Test public void testGetDefaultChildTypeFromResidual() { - Tree emptyDefinitions = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree emptyDefinitions = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); Tree named = when(mock(Tree.class).getChild("newChild")).thenReturn(emptyDefinitions).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(named); @@ -686,7 +684,7 @@ public void testGetDefaultChildTypeFromResidual() { when(def.getProperty(JCR_DEFAULTPRIMARYTYPE)).thenReturn(ps); PropertyState sns = PropertyStates.createProperty(JCR_SAMENAMESIBLINGS, false, Type.BOOLEAN); when(def.getProperty(JCR_SAMENAMESIBLINGS)).thenReturn(sns); - Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(def)).getMock(); + Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(List.of(def)).getMock(); when(ntDef.getChild(REP_RESIDUAL_CHILD_NODE_DEFINITIONS)).thenReturn(definitions); assertEquals(NT_RESOURCE, TreeUtil.getDefaultChildType(typeRoot, child, "newChild")); @@ -695,7 +693,7 @@ public void testGetDefaultChildTypeFromResidual() { @Test public void testGetDefaultChildTypeFromResidualSns() { - Tree emptyDefinitions = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of()).getMock(); + Tree emptyDefinitions = when(mock(Tree.class).getChildren()).thenReturn(List.of()).getMock(); Tree named = when(mock(Tree.class).getChild("newChild")).thenReturn(emptyDefinitions).getMock(); when(ntDef.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS)).thenReturn(named); @@ -704,7 +702,7 @@ public void testGetDefaultChildTypeFromResidualSns() { when(def.getProperty(JCR_DEFAULTPRIMARYTYPE)).thenReturn(ps); PropertyState sns = PropertyStates.createProperty(JCR_SAMENAMESIBLINGS, true, Type.BOOLEAN); when(def.getProperty(JCR_SAMENAMESIBLINGS)).thenReturn(sns); - Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(def)).getMock(); + Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(List.of(def)).getMock(); when(ntDef.getChild(REP_RESIDUAL_CHILD_NODE_DEFINITIONS)).thenReturn(definitions); assertEquals(NT_RESOURCE, TreeUtil.getDefaultChildType(typeRoot, child, "newChild")); @@ -718,25 +716,25 @@ public void testGetEffectiveTypeNoPrimary() { @Test public void testGetEffectiveTypeNoMixins() { - assertEquals(ImmutableList.of(ntDef), TreeUtil.getEffectiveType(z, typeRoot)); + assertEquals(List.of(ntDef), TreeUtil.getEffectiveType(z, typeRoot)); } @Test public void testGetEffectiveType() { - assertEquals(ImmutableList.of(ntDef, ntDef, ntDef), TreeUtil.getEffectiveType(child, typeRoot)); + assertEquals(List.of(ntDef, ntDef, ntDef), TreeUtil.getEffectiveType(child, typeRoot)); } @Test public void testGetEffectiveTypeNonExistingPrimaryDef() { - assertEquals(ImmutableList.of(), TreeUtil.getEffectiveType(mockTree("/anotherTree", rootTree, false, "rep:NonExistingType"), typeRoot)); + assertEquals(List.of(), TreeUtil.getEffectiveType(mockTree("/anotherTree", rootTree, false, "rep:NonExistingType"), typeRoot)); } @Test public void testGetEffectiveTypeNonExistingMixinDef() { Tree tree = mockTree("/anotherTree", rootTree, false); - when(tree.getProperty(JCR_MIXINTYPES)).thenReturn(PropertyStates.createProperty(JCR_MIXINTYPES, ImmutableList.of("rep:NonExistingType"), Type.NAMES)); + when(tree.getProperty(JCR_MIXINTYPES)).thenReturn(PropertyStates.createProperty(JCR_MIXINTYPES, List.of("rep:NonExistingType"), Type.NAMES)); - assertEquals(ImmutableList.of(), TreeUtil.getEffectiveType(tree, typeRoot)); + assertEquals(List.of(), TreeUtil.getEffectiveType(tree, typeRoot)); } @Test @@ -748,7 +746,7 @@ public void testFindDefaultPrimaryTypeUnknownDefinition() { @Test public void testFindDefaultPrimaryType() { Tree def = mock(Tree.class); - Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(ImmutableList.of(def)).getMock(); + Tree definitions = when(mock(Tree.class).getChildren()).thenReturn(List.of(def)).getMock(); assertNull(TreeUtil.findDefaultPrimaryType(definitions, false)); assertNull(TreeUtil.findDefaultPrimaryType(definitions, true)); @@ -782,7 +780,7 @@ public void testIsNodeTypeMissingTypeProperties() { @Test public void testIsNodeTypeContainedInSupertypes() { - PropertyState supertypes = PropertyStates.createProperty(REP_SUPERTYPES, ImmutableList.of(NT_BASE), Type.NAMES); + PropertyState supertypes = PropertyStates.createProperty(REP_SUPERTYPES, List.of(NT_BASE), Type.NAMES); when(ntDef.getProperty(REP_SUPERTYPES)).thenReturn(supertypes); assertTrue(TreeUtil.isNodeType(child, NT_BASE, typeRoot)); @@ -797,7 +795,7 @@ public void testIsNodeTypeMixin() { @Test public void testIsNodeTypeMixinContainedInSupertypes() { - PropertyState supertypes = PropertyStates.createProperty(REP_SUPERTYPES, ImmutableList.of(MIX_REFERENCEABLE), Type.NAMES); + PropertyState supertypes = PropertyStates.createProperty(REP_SUPERTYPES, List.of(MIX_REFERENCEABLE), Type.NAMES); when(ntDef.getProperty(REP_SUPERTYPES)).thenReturn(supertypes); PropertyState mixinNames = PropertyStates.createProperty(JcrConstants.JCR_MIXINTYPES, List.of(JcrConstants.MIX_VERSIONABLE), Type.NAMES); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/CompositeConfigurationTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/CompositeConfigurationTest.java index 32e66e7cf0e..90c19baed09 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/CompositeConfigurationTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/CompositeConfigurationTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.plugins.tree.RootProvider; @@ -252,7 +251,7 @@ public void testGetProtectedItemImporters() { @NotNull @Override public List getProtectedItemImporters() { - return ImmutableList.of(mock(ProtectedItemImporter.class)); + return List.of(mock(ProtectedItemImporter.class)); } }; addConfiguration(withImporter); @@ -271,7 +270,7 @@ public void testGetConflictHandlers() { @NotNull @Override public List getConflictHandlers() { - return ImmutableList.of(mock(ThreeWayConflictHandler.class)); + return List.of(mock(ThreeWayConflictHandler.class)); } }; addConfiguration(withConflictHandler); @@ -290,7 +289,7 @@ public void testGetCommitHooks() { @NotNull @Override public List getCommitHooks(@NotNull String workspaceName) { - return ImmutableList.of(mock(CommitHook.class)); + return List.of(mock(CommitHook.class)); } }; addConfiguration(withCommitHook); @@ -309,7 +308,7 @@ public void testGetValidators() { @NotNull @Override public List getValidators(@NotNull String workspaceName, @NotNull Set principals, @NotNull MoveTracker moveTracker) { - return ImmutableList.of(mock(ValidatorProvider.class)); + return List.of(mock(ValidatorProvider.class)); } }; addConfiguration(withValidator); @@ -403,7 +402,7 @@ public void testGetMonitors() { @NotNull @Override public Iterable> getMonitors(@NotNull StatisticsProvider statisticsProvider) { - return ImmutableList.of(monitor); + return List.of(monitor); } }; addConfiguration(withMonitors); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/token/CompositeTokenProviderTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/token/CompositeTokenProviderTest.java index 16c53ce070e..7b2830201eb 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/token/CompositeTokenProviderTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/token/CompositeTokenProviderTest.java @@ -16,8 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authentication.token; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.Before; @@ -26,6 +24,7 @@ import javax.jcr.Credentials; import javax.jcr.GuestCredentials; import javax.jcr.SimpleCredentials; +import java.util.List; import java.util.Map; import static org.junit.Assert.assertFalse; @@ -58,7 +57,7 @@ public void before() { public void testNullProvider() { TokenProvider tp = CompositeTokenProvider.newInstance(); - assertSame(tp, CompositeTokenProvider.newInstance(ImmutableList.of())); + assertSame(tp, CompositeTokenProvider.newInstance(List.of())); Credentials creds = new Credentials() {}; @@ -82,7 +81,7 @@ public void testSingleProvider() { TokenProvider tp = CompositeTokenProvider.newInstance(base); assertSame(base, tp); - assertSame(base, CompositeTokenProvider.newInstance(ImmutableList.of(base))); + assertSame(base, CompositeTokenProvider.newInstance(List.of(base))); } @Test @@ -93,7 +92,7 @@ public void testCreateCompositeProvider() { @Test public void testCreateCompositeProviderFromList() { TokenProvider base = mock(TokenProvider.class); - TokenProvider tp = CompositeTokenProvider.newInstance(ImmutableList.of(base, base)); + TokenProvider tp = CompositeTokenProvider.newInstance(List.of(base, base)); assertTrue(tp instanceof CompositeTokenProvider); } diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ACETest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ACETest.java index bf051f79d4a..356f1567e41 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ACETest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/ACETest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry; import org.apache.jackrabbit.api.security.authorization.PrivilegeCollection; @@ -43,7 +42,9 @@ import javax.jcr.security.AccessControlException; import javax.jcr.security.Privilege; import java.security.Principal; +import java.util.Arrays; import java.util.Collections; +import java.util.List; import java.util.Set; import static org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants.JCR_READ; @@ -105,7 +106,7 @@ private Restriction createRestriction(String name, Value value) throws Exception } private Restriction createRestriction(String name, Value[] values) throws Exception { - return new RestrictionImpl(PropertyStates.createProperty(name, ImmutableList.copyOf(values)), false); + return new RestrictionImpl(PropertyStates.createProperty(name, Arrays.asList(values)), false); } @Test @@ -216,7 +217,7 @@ public void testNullRestrictions() { @Test public void testRestrictions() { Restriction r = new RestrictionImpl(PropertyStates.createProperty("r", "v"), false); - Restriction r2 = new RestrictionImpl(PropertyStates.createProperty("r2", ImmutableList.of("v"), Type.STRINGS), false); + Restriction r2 = new RestrictionImpl(PropertyStates.createProperty("r2", List.of("v"), Type.STRINGS), false); Set restrictions = Set.of(r, r2); ACE ace = mockACE(testPrincipal, PrivilegeBits.BUILT_IN.get(JCR_READ), true, restrictions); assertFalse(ace.getRestrictions().isEmpty()); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/AbstractAccessControlListTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/AbstractAccessControlListTest.java index 39c60303c06..fa2aa9b85b3 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/AbstractAccessControlListTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/accesscontrol/AbstractAccessControlListTest.java @@ -28,7 +28,6 @@ import javax.jcr.Value; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; @@ -134,7 +133,7 @@ protected List createTestEntries() throws Reposito @Test public void testGetNamePathMapper() { assertSame(getNamePathMapper(), createEmptyACL().getNamePathMapper()); - assertSame(NamePathMapper.DEFAULT, createACL(getTestPath(), ImmutableList.of(), NamePathMapper.DEFAULT).getNamePathMapper()); + assertSame(NamePathMapper.DEFAULT, createACL(getTestPath(), List.of(), NamePathMapper.DEFAULT).getNamePathMapper()); } @Test diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/permission/PermissionsTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/permission/PermissionsTest.java index da7bddc1fe1..87fdd866d0d 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/permission/PermissionsTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/permission/PermissionsTest.java @@ -24,7 +24,6 @@ import javax.jcr.Session; import org.apache.jackrabbit.guava.common.base.Splitter; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.JcrConstants; @@ -209,7 +208,7 @@ public void testGetStringAggregates() { @Test public void testIsAggregate() { - List aggregates = ImmutableList.of(Permissions.ALL, Permissions.WRITE, Permissions.READ, Permissions.SET_PROPERTY, Permissions.REMOVE); + List aggregates = List.of(Permissions.ALL, Permissions.WRITE, Permissions.READ, Permissions.SET_PROPERTY, Permissions.REMOVE); for (long permission : Permissions.PERMISSION_NAMES.keySet()) { if (aggregates.contains(permission)) { assertTrue(Permissions.getString(permission), Permissions.isAggregate(permission)); @@ -246,7 +245,7 @@ public void testAggregatesAllPermission() { assertFalse(Iterables.contains(aggregates, Permissions.ALL)); Set expected = new HashSet<>(Permissions.PERMISSION_NAMES.keySet()); - expected.removeAll(ImmutableList.of(Permissions.ALL, Permissions.WRITE, Permissions.READ, Permissions.SET_PROPERTY, Permissions.REMOVE)); + expected.removeAll(List.of(Permissions.ALL, Permissions.WRITE, Permissions.READ, Permissions.SET_PROPERTY, Permissions.REMOVE)); assertEquals(expected, CollectionUtils.toSet(aggregates)); } @@ -261,7 +260,7 @@ public void testIsRepositoryPermission() { @Test public void testRespectParentPermissions() { - List permissions = ImmutableList.of( + List permissions = List.of( Permissions.ALL, Permissions.ADD_NODE, Permissions.ADD_NODE|Permissions.ADD_PROPERTY, @@ -279,7 +278,7 @@ public void testRespectParentPermissions() { @Test public void testNotRespectParentPermissions() { - List permissions = ImmutableList.of( + List permissions = List.of( Permissions.READ, Permissions.ADD_PROPERTY, Permissions.REMOVE_PROPERTY, @@ -358,7 +357,7 @@ public void testGetPermissionsFromPermissionNameActions() { @Test public void testGetPermissionsFromInvalidActions() { TreeLocation tl = TreeLocation.create(existingTree); - List l = ImmutableList.of( + List l = List.of( Session.ACTION_READ + ",invalid", "invalid", "invalid," + Session.ACTION_REMOVE ); @@ -556,7 +555,7 @@ public void testGetPermissionsForVersionPaths() { @Test public void testGetPermissionsForRegularPaths() { - for (String path : ImmutableList.of("/", "/a/b/c", "/myfile/jcr:content")) { + for (String path : List.of("/", "/a/b/c", "/myfile/jcr:content")) { for (long defaultPermission : Permissions.PERMISSION_NAMES.keySet()) { assertEquals(defaultPermission, Permissions.getPermission(path, defaultPermission)); } diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositePatternTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositePatternTest.java index 2a808817a42..86a54e99136 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositePatternTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositePatternTest.java @@ -17,7 +17,7 @@ package org.apache.jackrabbit.oak.spi.security.authorization.restriction; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; + import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; @@ -32,24 +32,24 @@ public class CompositePatternTest { - private final RestrictionPattern alwaysMatching = CompositePattern.create(ImmutableList.of(TestRestrictionPatter.INSTANCE_TRUE, TestRestrictionPatter.INSTANCE_TRUE)); - private final RestrictionPattern neverMatching = CompositePattern.create(ImmutableList.of(TestRestrictionPatter.INSTANCE_TRUE, TestRestrictionPatter.INSTANCE_FALSE)); + private final RestrictionPattern alwaysMatching = CompositePattern.create(List.of(TestRestrictionPatter.INSTANCE_TRUE, TestRestrictionPatter.INSTANCE_TRUE)); + private final RestrictionPattern neverMatching = CompositePattern.create(List.of(TestRestrictionPatter.INSTANCE_TRUE, TestRestrictionPatter.INSTANCE_FALSE)); @Test public void testCreateFromEmptyList() { - RestrictionPattern rp = CompositePattern.create(ImmutableList.of()); + RestrictionPattern rp = CompositePattern.create(List.of()); assertSame(RestrictionPattern.EMPTY, rp); } @Test public void testCreateFromSingletonList() { - RestrictionPattern rp = CompositePattern.create(ImmutableList.of(TestRestrictionPatter.INSTANCE_TRUE)); + RestrictionPattern rp = CompositePattern.create(List.of(TestRestrictionPatter.INSTANCE_TRUE)); assertSame(TestRestrictionPatter.INSTANCE_TRUE, rp); } @Test public void testCreateFromList() { - RestrictionPattern rp = CompositePattern.create(ImmutableList.of(TestRestrictionPatter.INSTANCE_TRUE, TestRestrictionPatter.INSTANCE_FALSE)); + RestrictionPattern rp = CompositePattern.create(List.of(TestRestrictionPatter.INSTANCE_TRUE, TestRestrictionPatter.INSTANCE_FALSE)); assertTrue(rp instanceof CompositePattern); } @@ -61,7 +61,7 @@ public void testMatches() { @Test public void testMatchesPath() { - List paths = ImmutableList.of("/", "/a", "/a/b/c", ""); + List paths = List.of("/", "/a", "/a/b/c", ""); for (String path : paths) { assertTrue(alwaysMatching.matches(path)); @@ -71,7 +71,7 @@ public void testMatchesPath() { @Test public void testMatchesPathIsProperty() { - List paths = ImmutableList.of("/", "/a", "/a/b/c", ""); + List paths = List.of("/", "/a", "/a/b/c", ""); for (String path : paths) { assertTrue(alwaysMatching.matches(path, true)); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositeRestrictionProviderTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositeRestrictionProviderTest.java index f4c1ad1b622..a7091a01acb 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositeRestrictionProviderTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/CompositeRestrictionProviderTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.restriction; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; @@ -66,9 +65,9 @@ public class CompositeRestrictionProviderTest implements AccessControlConstants private static final String NAME_BOOLEAN = "boolean"; private static final Restriction GLOB_RESTRICTION = new RestrictionImpl(PropertyStates.createProperty(REP_GLOB, "*"), false); - private static final Restriction NT_PREFIXES_RESTRICTION = new RestrictionImpl(PropertyStates.createProperty(REP_PREFIXES, ImmutableList.of(), Type.STRINGS), false); + private static final Restriction NT_PREFIXES_RESTRICTION = new RestrictionImpl(PropertyStates.createProperty(REP_PREFIXES, List.of(), Type.STRINGS), false); private static final Restriction MANDATORY_BOOLEAN_RESTRICTION = new RestrictionImpl(PropertyStates.createProperty(NAME_BOOLEAN, true, Type.BOOLEAN), true); - private static final Restriction LONGS_RESTRICTION = new RestrictionImpl(PropertyStates.createProperty(NAME_LONGS, ImmutableList.of(Long.MAX_VALUE), Type.LONGS), false); + private static final Restriction LONGS_RESTRICTION = new RestrictionImpl(PropertyStates.createProperty(NAME_LONGS, List.of(Long.MAX_VALUE), Type.LONGS), false); private static final Restriction UNKNOWN_RESTRICTION = new RestrictionImpl(PropertyStates.createProperty("unknown", "string"), false); private final AbstractRestrictionProvider rp1 = spy(createRestrictionProvider(GLOB_RESTRICTION.getDefinition(), NT_PREFIXES_RESTRICTION.getDefinition())); @@ -300,7 +299,7 @@ public void testValidateRestrictionsWrongType() throws Exception { @Test(expected = AccessControlException.class) public void testValidateRestrictionsInvalidDefinition() throws Exception { - Restriction rWithInvalidDefinition = new RestrictionImpl(PropertyStates.createProperty(REP_GLOB, ImmutableList.of("str", "str2"), Type.STRINGS), false); + Restriction rWithInvalidDefinition = new RestrictionImpl(PropertyStates.createProperty(REP_GLOB, List.of("str", "str2"), Type.STRINGS), false); Tree aceTree = getAceTree(rWithInvalidDefinition, MANDATORY_BOOLEAN_RESTRICTION); RestrictionProvider rp = createRestrictionProvider(null, rWithInvalidDefinition, GLOB_RESTRICTION.getDefinition()); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/RestrictionImplTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/RestrictionImplTest.java index bc099e5f0cb..cbc4f716bd7 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/RestrictionImplTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/RestrictionImplTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.authorization.restriction; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; @@ -112,7 +111,7 @@ public void testNotEqual() { // - different type rs.add(new RestrictionImpl(PropertyStates.createProperty(name, value, Type.STRING), isMandatory)); // - different multi-value status - rs.add(new RestrictionImpl(PropertyStates.createProperty(name, ImmutableList.of(value), Type.NAMES), isMandatory)); + rs.add(new RestrictionImpl(PropertyStates.createProperty(name, List.of(value), Type.NAMES), isMandatory)); // - different name rs.add(new RestrictionImpl(createProperty("otherName", value, type), isMandatory)); // - different value @@ -151,7 +150,7 @@ public void testNotSameHashCode() { // - different type rs.add(new RestrictionImpl(PropertyStates.createProperty(name, value, Type.STRING), isMandatory)); // - different multi-value status - rs.add(new RestrictionImpl(PropertyStates.createProperty(name, ImmutableList.of(value), Type.NAMES), isMandatory)); + rs.add(new RestrictionImpl(PropertyStates.createProperty(name, List.of(value), Type.NAMES), isMandatory)); // - different name rs.add(new RestrictionImpl(createProperty("otherName", value, type), isMandatory)); // - different value diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProviderTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProviderTest.java index 7c2205bf2e0..9a5d95ba86e 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProviderTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProviderTest.java @@ -27,7 +27,6 @@ import java.util.Set; import java.util.TreeSet; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; @@ -53,7 +52,7 @@ public class CompositePrincipalProviderTest { private final TestPrincipalProvider pp1 = new TestPrincipalProvider(); private final TestPrincipalProvider pp2 = new TestPrincipalProvider("p1", "p2"); - private final PrincipalProvider cpp = CompositePrincipalProvider.of(ImmutableList.of(pp1, pp2)); + private final PrincipalProvider cpp = CompositePrincipalProvider.of(List.of(pp1, pp2)); private Iterable testPrincipals() { return Iterables.concat(pp1.getTestPrincipals(), pp2.getTestPrincipals()); @@ -65,13 +64,13 @@ private static void assertIterator(@NotNull Iterable expect @Test public void testOfEmptyList() { - assertSame(EmptyPrincipalProvider.INSTANCE, CompositePrincipalProvider.of(ImmutableList.of())); + assertSame(EmptyPrincipalProvider.INSTANCE, CompositePrincipalProvider.of(List.of())); } @Test public void testOfSingletonList() { PrincipalProvider pp = new TestPrincipalProvider(true); - assertSame(pp, CompositePrincipalProvider.of(ImmutableList.of(pp))); + assertSame(pp, CompositePrincipalProvider.of(List.of(pp))); } @Test @@ -107,7 +106,7 @@ public void testGetItemBasedPrincipal() throws Exception { ItemBasedPrincipal p = mock(ItemBasedPrincipal.class); PrincipalProvider pp = when(mock(PrincipalProvider.class).getItemBasedPrincipal(anyString())).thenReturn(p).getMock(); - assertEquals(p, CompositePrincipalProvider.of(ImmutableList.of(pp, pp2)).getItemBasedPrincipal("/any/path")); + assertEquals(p, CompositePrincipalProvider.of(List.of(pp, pp2)).getItemBasedPrincipal("/any/path")); } @Test @@ -165,7 +164,7 @@ public void findPrincipalsByTypeAll() { */ @Test public void testRangeDefault() { - List pps = ImmutableList.of(new PrincipalImpl("p0"), new PrincipalImpl("p1"), + List pps = List.of(new PrincipalImpl("p0"), new PrincipalImpl("p1"), new PrincipalImpl("p2")); PrincipalProvider pp = new PrincipalProvider() { @@ -271,7 +270,7 @@ public void testFindWithOffsetLimit() { // NOTE: CompositePrincipalProvider passes 0 offset to the aggregated provider! when(pp.findPrincipals("p", false, PrincipalManager.SEARCH_TYPE_ALL, 0, 3)).thenReturn(principals); - PrincipalProvider cpp = CompositePrincipalProvider.of(ImmutableList.of(pp, EmptyPrincipalProvider.INSTANCE)); + PrincipalProvider cpp = CompositePrincipalProvider.of(List.of(pp, EmptyPrincipalProvider.INSTANCE)); Iterator it = cpp.findPrincipals("p", false, PrincipalManager.SEARCH_TYPE_ALL, 2, 1); assertTrue(it.hasNext()); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/ImmutablePrivilegeDefinitionTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/ImmutablePrivilegeDefinitionTest.java index 06c9126bde8..dc09be37d44 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/ImmutablePrivilegeDefinitionTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/ImmutablePrivilegeDefinitionTest.java @@ -16,10 +16,10 @@ */ package org.apache.jackrabbit.oak.spi.security.privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.junit.Test; import org.mockito.Mockito; +import java.util.List; import java.util.Set; import static org.junit.Assert.assertEquals; @@ -29,7 +29,7 @@ public class ImmutablePrivilegeDefinitionTest { - private final ImmutablePrivilegeDefinition def = new ImmutablePrivilegeDefinition("name", true, ImmutableList.of("aggrName")); + private final ImmutablePrivilegeDefinition def = new ImmutablePrivilegeDefinition("name", true, List.of("aggrName")); @Test public void testGetName() { @@ -72,17 +72,17 @@ public void testNotEquals() { assertNotEquals(def, otherDef); assertNotEquals(def, null); - assertNotEquals(def, new ImmutablePrivilegeDefinition("othername", true, ImmutableList.of("aggrName"))); - assertNotEquals(def, new ImmutablePrivilegeDefinition("name", false, ImmutableList.of("aggrName"))); - assertNotEquals(def, new ImmutablePrivilegeDefinition("name", true, ImmutableList.of("anotherName"))); - assertNotEquals(def, new ImmutablePrivilegeDefinition("name", true, ImmutableList.of())); - assertNotEquals(def, new ImmutablePrivilegeDefinition("otherName", false, ImmutableList.of("aggrName","aggrName2"))); + assertNotEquals(def, new ImmutablePrivilegeDefinition("othername", true, List.of("aggrName"))); + assertNotEquals(def, new ImmutablePrivilegeDefinition("name", false, List.of("aggrName"))); + assertNotEquals(def, new ImmutablePrivilegeDefinition("name", true, List.of("anotherName"))); + assertNotEquals(def, new ImmutablePrivilegeDefinition("name", true, List.of())); + assertNotEquals(def, new ImmutablePrivilegeDefinition("otherName", false, List.of("aggrName","aggrName2"))); } @Test public void testToString() { assertEquals(def.toString(), def.toString()); assertEquals(def.toString(), new ImmutablePrivilegeDefinition(def.getName(), def.isAbstract(), def.getDeclaredAggregateNames()).toString()); - assertEquals(def.toString(), new ImmutablePrivilegeDefinition(def.getName(), def.isAbstract(), ImmutableList.of()).toString()); + assertEquals(def.toString(), new ImmutablePrivilegeDefinition(def.getName(), def.isAbstract(), List.of()).toString()); } } \ No newline at end of file diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsProviderTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsProviderTest.java index 81526f2241d..66a0c72b7cc 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsProviderTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsProviderTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.ImmutableSet; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.oak.api.PropertyState; @@ -34,6 +33,7 @@ import javax.jcr.security.AccessControlException; import javax.jcr.security.Privilege; import java.util.Collections; +import java.util.List; import java.util.Set; import static org.junit.Assert.assertEquals; @@ -111,7 +111,7 @@ public void testGetBitsEmptyString() { @Test public void testGetBitsEmptyIterable() { - assertSame(PrivilegeBits.EMPTY, bitsProvider.getBits(ImmutableList.of())); + assertSame(PrivilegeBits.EMPTY, bitsProvider.getBits(List.of())); } @Test @@ -124,7 +124,7 @@ public void testGetBitsBuiltInSingleName() { @Test public void testGetBitsBuiltInSingleton() { - PrivilegeBits bits = bitsProvider.getBits(ImmutableList.of(JCR_LOCK_MANAGEMENT)); + PrivilegeBits bits = bitsProvider.getBits(List.of(JCR_LOCK_MANAGEMENT)); assertFalse(bits.isEmpty()); assertEquals(PrivilegeBits.BUILT_IN.get(JCR_LOCK_MANAGEMENT), bits); @@ -141,7 +141,7 @@ public void testGetBitsBuiltInNames() { @Test public void testGetBitsBuiltInIterable() { - PrivilegeBits bits = bitsProvider.getBits(ImmutableList.of(JCR_ADD_CHILD_NODES, JCR_REMOVE_CHILD_NODES)); + PrivilegeBits bits = bitsProvider.getBits(List.of(JCR_ADD_CHILD_NODES, JCR_REMOVE_CHILD_NODES)); assertFalse(bits.isEmpty()); PrivilegeBits mod = PrivilegeBits.getInstance(bitsProvider.getBits(JCR_ADD_CHILD_NODES)).add(bitsProvider.getBits(JCR_REMOVE_CHILD_NODES)); @@ -167,7 +167,7 @@ public void testGetBitsKnownPrivName() { @Test public void testGetBitsTwiceSingleBuiltIn() { - Iterable names = ImmutableList.of(JCR_ADD_CHILD_NODES); + Iterable names = List.of(JCR_ADD_CHILD_NODES); PrivilegeBits bits1 = bitsProvider.getBits(names); PrivilegeBits bits2 = bitsProvider.getBits(names); @@ -180,7 +180,7 @@ public void testGetBitsTwiceSingleBuiltIn() { @Test public void testGetBitsTwiceMultipleBuiltIn() { - Iterable names = ImmutableList.of(JCR_ADD_CHILD_NODES, JCR_REMOVE_CHILD_NODES); + Iterable names = List.of(JCR_ADD_CHILD_NODES, JCR_REMOVE_CHILD_NODES); PrivilegeBits bits1 = bitsProvider.getBits(names); PrivilegeBits bits2 = bitsProvider.getBits(names); @@ -193,7 +193,7 @@ public void testGetBitsTwiceMultipleBuiltIn() { @Test public void testGetBitsTwiceKnown() { - Iterable names = ImmutableList.of(KNOWN_PRIV_NAME); + Iterable names = List.of(KNOWN_PRIV_NAME); PrivilegeBits bits1 = bitsProvider.getBits(names); PrivilegeBits bits2 = bitsProvider.getBits(names); @@ -206,7 +206,7 @@ public void testGetBitsTwiceKnown() { @Test public void testGetBitsTwiceBuitInKnown() { - Iterable names = ImmutableList.of(KNOWN_PRIV_NAME, JCR_ADD_CHILD_NODES); + Iterable names = List.of(KNOWN_PRIV_NAME, JCR_ADD_CHILD_NODES); PrivilegeBits bits1 = bitsProvider.getBits(names); PrivilegeBits bits2 = bitsProvider.getBits(names); @@ -219,7 +219,7 @@ public void testGetBitsTwiceBuitInKnown() { @Test public void testGetBitsTwiceKnownUnknown() { - Iterable names = ImmutableList.of(KNOWN_PRIV_NAME, "unknown"); + Iterable names = List.of(KNOWN_PRIV_NAME, "unknown"); PrivilegeBits bits1 = bitsProvider.getBits(names); PrivilegeBits bits2 = bitsProvider.getBits(names); @@ -245,7 +245,7 @@ public void testBitsValidateEmpty() throws Exception { @Test public void testGetBitsValidateTwiceBuitInKnown() throws Exception { - Iterable names = ImmutableList.of(KNOWN_PRIV_NAME, JCR_ADD_CHILD_NODES); + Iterable names = List.of(KNOWN_PRIV_NAME, JCR_ADD_CHILD_NODES); PrivilegeBits bits1 = bitsProvider.getBits(names, true); PrivilegeBits bits2 = bitsProvider.getBits(names, false); @@ -258,7 +258,7 @@ public void testGetBitsValidateTwiceBuitInKnown() throws Exception { @Test(expected = AccessControlException.class) public void testBitsValidateNonExistingTree() throws Exception { - Iterable names = ImmutableList.of(KNOWN_PRIV_NAME, JCR_ADD_CHILD_NODES); + Iterable names = List.of(KNOWN_PRIV_NAME, JCR_ADD_CHILD_NODES); when(privTree.exists()).thenReturn(true); when(privTree.hasChild(KNOWN_PRIV_NAME)).thenReturn(false); @@ -267,7 +267,7 @@ public void testBitsValidateNonExistingTree() throws Exception { } public void testBitsValidateFalseNonExistingTree() throws Exception { - Iterable names = ImmutableList.of(KNOWN_PRIV_NAME, JCR_ADD_CHILD_NODES); + Iterable names = List.of(KNOWN_PRIV_NAME, JCR_ADD_CHILD_NODES); when(privTree.exists()).thenReturn(true); when(privTree.hasChild(KNOWN_PRIV_NAME)).thenReturn(false); @@ -354,7 +354,7 @@ public void testGetPrivilegeNamesWithAggregation() { when(anotherPriv.exists()).thenReturn(true); when(anotherPriv.getName()).thenReturn("name2"); when(anotherPriv.hasProperty(REP_AGGREGATES)).thenReturn(true); - when(anotherPriv.getProperty(REP_AGGREGATES)).thenReturn(PropertyStates.createProperty(REP_AGGREGATES, ImmutableList.of(KNOWN_PRIV_NAME), Type.NAMES)); + when(anotherPriv.getProperty(REP_AGGREGATES)).thenReturn(PropertyStates.createProperty(REP_AGGREGATES, List.of(KNOWN_PRIV_NAME), Type.NAMES)); PropertyState bits2 = PropertyStates.createProperty(REP_BITS, 7500L); when(anotherPriv.getProperty(REP_BITS)).thenReturn(bits2); @@ -463,7 +463,7 @@ public void testGetAggregatedPrivilegeNamesMissingAggProperty() { when(privTree.getChild(KNOWN_PRIV_NAME)).thenReturn(pTree); Iterable result = bitsProvider.getAggregatedPrivilegeNames(KNOWN_PRIV_NAME); - assertTrue(Iterables.elementsEqual(ImmutableList.of(KNOWN_PRIV_NAME), result)); + assertTrue(Iterables.elementsEqual(List.of(KNOWN_PRIV_NAME), result)); } @Test diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java index 2bd45f5a43b..e66b58abb0d 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java @@ -16,7 +16,8 @@ */ package org.apache.jackrabbit.oak.spi.security.user.action; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; +import java.util.List; + import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.Group; @@ -36,6 +37,7 @@ import org.jetbrains.annotations.Nullable; import org.junit.Test; + import javax.jcr.RepositoryException; import javax.jcr.security.AccessControlManager; import javax.jcr.security.AccessControlPolicy; @@ -84,14 +86,13 @@ private AccessControlManager mockAccessControlManager(boolean addEntrySuccess) t AccessControlManager acMgr = mock(AccessControlManager.class); when(acMgr.getApplicablePolicies("/none")).thenReturn(AccessControlPolicyIteratorAdapter.EMPTY); AccessControlPolicy policy = mock(AccessControlPolicy.class); - when(acMgr.getApplicablePolicies("/nonACL")).thenReturn(new AccessControlPolicyIteratorAdapter(ImmutableList.of(policy))); + when(acMgr.getApplicablePolicies("/nonACL")).thenReturn(new AccessControlPolicyIteratorAdapter(List.of(policy))); JackrabbitAccessControlList acl = mock(JackrabbitAccessControlList.class); if (addEntrySuccess) { when(acl.addAccessControlEntry(any(Principal.class), any(Privilege[].class))).thenReturn(true); } - when(acMgr.getApplicablePolicies("/acl")).thenReturn(new AccessControlPolicyIteratorAdapter(ImmutableList.of(acl))); + when(acMgr.getApplicablePolicies("/acl")).thenReturn(new AccessControlPolicyIteratorAdapter(List.of(acl))); return acMgr; - } private AccessControlAction createAction(@NotNull String... privNames) { diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/CompositeActionProviderTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/CompositeActionProviderTest.java index 853fd718d8d..8c1898fb368 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/CompositeActionProviderTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/CompositeActionProviderTest.java @@ -17,7 +17,7 @@ package org.apache.jackrabbit.oak.spi.security.user.action; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; + import org.apache.jackrabbit.oak.spi.security.SecurityProvider; import org.jetbrains.annotations.NotNull; import org.junit.Test; @@ -47,7 +47,7 @@ public void testMultiple() { AuthorizableActionProvider aap = new TestAuthorizableActionProvider(); AuthorizableActionProvider aap2 = new TestAuthorizableActionProvider(); - assertEquals(ImmutableList.of(TestAction.INSTANCE, TestAction.INSTANCE), new CompositeActionProvider(aap, aap2).getAuthorizableActions(securityProvider)); + assertEquals(List.of(TestAction.INSTANCE, TestAction.INSTANCE), new CompositeActionProvider(aap, aap2).getAuthorizableActions(securityProvider)); } @Test @@ -55,7 +55,7 @@ public void testMultiple2() { AuthorizableActionProvider aap = new TestAuthorizableActionProvider(); AuthorizableActionProvider aap2 = new TestAuthorizableActionProvider(); - assertEquals(ImmutableList.of(TestAction.INSTANCE, TestAction.INSTANCE), new CompositeActionProvider(ImmutableList.of(aap, aap2)).getAuthorizableActions(securityProvider)); + assertEquals(List.of(TestAction.INSTANCE, TestAction.INSTANCE), new CompositeActionProvider(List.of(aap, aap2)).getAuthorizableActions(securityProvider)); } @@ -64,7 +64,7 @@ private static final class TestAuthorizableActionProvider implements Authorizabl @NotNull @Override public List getAuthorizableActions(@NotNull SecurityProvider securityProvider) { - return ImmutableList.of(TestAction.INSTANCE); + return List.of(TestAction.INSTANCE); } } diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/util/PasswordUtilTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/util/PasswordUtilTest.java index ebb36429861..6da7e4125ff 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/util/PasswordUtilTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/util/PasswordUtilTest.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.Map; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters; import org.apache.jackrabbit.oak.spi.security.user.UserConstants; import org.apache.jackrabbit.util.Text; @@ -45,7 +44,7 @@ public class PasswordUtilTest { @Before public void before() throws Exception { - plainPasswords = ImmutableList.of( + plainPasswords = List.of( "pw", "PassWord123", "_", @@ -235,7 +234,7 @@ public void testIsSameInvalidIterations() throws Exception { @Test public void testIsSameMisplacedAlgorithm() { - List broken = ImmutableList.of("}{pw", "{pw", "{pw}"); + List broken = List.of("}{pw", "{pw", "{pw}"); for (String hash : broken) { assertFalse(PasswordUtil.isSame(hash, "pw")); } diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/util/UserUtilTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/util/UserUtilTest.java index 33c0e9b7e49..60b0711ffa0 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/util/UserUtilTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/security/user/util/UserUtilTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.security.user.util; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.user.Authorizable; import org.apache.jackrabbit.api.security.user.AuthorizableTypeException; @@ -170,7 +169,7 @@ public void testGetTypeFromTree() { @Test public void testGetTypeFromTree2() { - List test = ImmutableList.of( + List test = List.of( UserConstants.NT_REP_AUTHORIZABLE, JcrConstants.NT_FILE ); @@ -252,7 +251,7 @@ public void testGetAuthorizableIdNullTree() { @Test public void testGetAuthorizableId() { - List test = ImmutableList.of(UserConstants.NT_REP_GROUP, UserConstants.NT_REP_SYSTEM_USER, UserConstants.NT_REP_USER); + List test = List.of(UserConstants.NT_REP_GROUP, UserConstants.NT_REP_SYSTEM_USER, UserConstants.NT_REP_USER); for (String ntName : test) { assertEquals("id", UserUtil.getAuthorizableId(createTree(ntName, "id"))); } @@ -260,7 +259,7 @@ public void testGetAuthorizableId() { @Test public void testGetAuthorizableIdFallback() { - List test = ImmutableList.of(UserConstants.NT_REP_GROUP, UserConstants.NT_REP_SYSTEM_USER, UserConstants.NT_REP_USER); + List test = List.of(UserConstants.NT_REP_GROUP, UserConstants.NT_REP_SYSTEM_USER, UserConstants.NT_REP_USER); for (String ntName : test) { assertEquals("nName", UserUtil.getAuthorizableId(createTree(ntName, null, "nName"))); } @@ -268,7 +267,7 @@ public void testGetAuthorizableIdFallback() { @Test public void testGetAuthorizableIdNoAuthorizableType() { - List test = ImmutableList.of(UserConstants.NT_REP_AUTHORIZABLE, JcrConstants.NT_UNSTRUCTURED); + List test = List.of(UserConstants.NT_REP_AUTHORIZABLE, JcrConstants.NT_UNSTRUCTURED); for (String ntName : test) { assertNull(UserUtil.getAuthorizableId(createTree(ntName, "id"))); } diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/NodeInfoTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/NodeInfoTest.java index f87c326efbb..eeb5c3b54c3 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/NodeInfoTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/NodeInfoTest.java @@ -16,15 +16,16 @@ */ package org.apache.jackrabbit.oak.spi.xml; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.junit.Test; +import java.util.List; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; public class NodeInfoTest { - private final NodeInfo nodeInfo = new NodeInfo("name", "primaryType", ImmutableList.of("mixin1", "mixin2"), "uuid"); + private final NodeInfo nodeInfo = new NodeInfo("name", "primaryType", List.of("mixin1", "mixin2"), "uuid"); @Test public void testGetName() { @@ -38,7 +39,7 @@ public void testGetPrimaryTypeName() { @Test public void testGetMixinTypeName() { - assertEquals(ImmutableList.of("mixin1", "mixin2"), nodeInfo.getMixinTypeNames()); + assertEquals(List.of("mixin1", "mixin2"), nodeInfo.getMixinTypeNames()); } @Test diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/PropInfoTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/PropInfoTest.java index f9b15ad8a88..1e97ff5b5d0 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/PropInfoTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/PropInfoTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.xml; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; @@ -76,14 +75,14 @@ public void testDisposeThrowing() throws Exception { @Test(expected = DisposeException.class) public void testDisposeMultipleThrowing() throws Exception { - PropInfo propInfo = new PropInfo("string", PropertyType.STRING, ImmutableList.of(mockTextValue("value", PropertyType.STRING, true))); + PropInfo propInfo = new PropInfo("string", PropertyType.STRING, List.of(mockTextValue("value", PropertyType.STRING, true))); propInfo.dispose(); } @Test public void testDisposeMultiple() throws Exception { TextValue tv = mockTextValue("value", PropertyType.STRING, false); - PropInfo propInfo = new PropInfo("string", PropertyType.STRING, ImmutableList.of(tv)); + PropInfo propInfo = new PropInfo("string", PropertyType.STRING, List.of(tv)); propInfo.dispose(); verify(tv, times(1)).dispose(); } @@ -121,10 +120,10 @@ public void testGetType() throws Exception { @Test public void testIsUnknownMultiple() throws Exception { - PropInfo propInfo = new PropInfo("boolean", PropertyType.BOOLEAN, ImmutableList.of(mockTextValue("false", PropertyType.BOOLEAN)), PropInfo.MultipleStatus.UNKNOWN); + PropInfo propInfo = new PropInfo("boolean", PropertyType.BOOLEAN, List.of(mockTextValue("false", PropertyType.BOOLEAN)), PropInfo.MultipleStatus.UNKNOWN); assertTrue(propInfo.isUnknownMultiple()); - propInfo = new PropInfo("boolean", PropertyType.BOOLEAN, ImmutableList.of(mockTextValue("false", PropertyType.BOOLEAN)), PropInfo.MultipleStatus.MULTIPLE); + propInfo = new PropInfo("boolean", PropertyType.BOOLEAN, List.of(mockTextValue("false", PropertyType.BOOLEAN)), PropInfo.MultipleStatus.MULTIPLE); assertFalse(propInfo.isUnknownMultiple()); } @@ -136,25 +135,25 @@ public void testIsUnknownMultipleSingle() throws Exception { @Test public void testIsUnknownMultipleSingleList() throws Exception { - PropInfo propInfo = new PropInfo("long", PropertyType.LONG, ImmutableList.of(mockTextValue("24", PropertyType.LONG))); + PropInfo propInfo = new PropInfo("long", PropertyType.LONG, List.of(mockTextValue("24", PropertyType.LONG))); assertTrue(propInfo.isUnknownMultiple()); } @Test public void testIsUnknownMultipleSingleList2() throws Exception { - PropInfo propInfo = new PropInfo("long", PropertyType.LONG, ImmutableList.of(mockTextValue("24", PropertyType.LONG)), PropInfo.MultipleStatus.MULTIPLE); + PropInfo propInfo = new PropInfo("long", PropertyType.LONG, List.of(mockTextValue("24", PropertyType.LONG)), PropInfo.MultipleStatus.MULTIPLE); assertFalse(propInfo.isUnknownMultiple()); } @Test public void testIsUnknownMultipleEmpty() { - PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, ImmutableList.of()); + PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, List.of()); assertFalse(propInfo.isUnknownMultiple()); } @Test public void testIsUnknownMultipleMultiple() throws Exception { - PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, ImmutableList.of(mockTextValue("24", PropertyType.LONG), mockTextValue("44", PropertyType.LONG))); + PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, List.of(mockTextValue("24", PropertyType.LONG), mockTextValue("44", PropertyType.LONG))); assertFalse(propInfo.isUnknownMultiple()); } @@ -169,14 +168,14 @@ public void testGetTextValueSingle() throws Exception { @Test public void testGetTextValueSingleList() throws Exception { TextValue tv = mockTextValue("value", PropertyType.STRING); - PropInfo propInfo = new PropInfo("string", PropertyType.STRING, ImmutableList.of(tv)); + PropInfo propInfo = new PropInfo("string", PropertyType.STRING, List.of(tv)); assertEquals(tv, propInfo.getTextValue()); } @Test(expected = RepositoryException.class) public void testGetTextValueMultiple() throws Exception { - List tvs = ImmutableList.of(mockTextValue("24", PropertyType.LONG), mockTextValue("35", PropertyType.LONG)); + List tvs = List.of(mockTextValue("24", PropertyType.LONG), mockTextValue("35", PropertyType.LONG)); PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, tvs); propInfo.getTextValue(); @@ -187,12 +186,12 @@ public void testGetTextValuesSingle() throws Exception { TextValue tv = mockTextValue("value", PropertyType.STRING); PropInfo propInfo = new PropInfo("string", PropertyType.STRING, tv); - assertEquals(ImmutableList.of(tv), propInfo.getTextValues()); + assertEquals(List.of(tv), propInfo.getTextValues()); } @Test public void testGetTextValuesMultiple() throws Exception { - List tvs = ImmutableList.of(mockTextValue("24", PropertyType.LONG)); + List tvs = List.of(mockTextValue("24", PropertyType.LONG)); PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, tvs); assertEquals(tvs, propInfo.getTextValues()); @@ -209,14 +208,14 @@ public void testGetValueSingle() throws Exception { @Test public void testGetValueSingleList() throws Exception { TextValue tv = mockTextValue("value", PropertyType.STRING); - PropInfo propInfo = new PropInfo("string", PropertyType.STRING, ImmutableList.of(tv)); + PropInfo propInfo = new PropInfo("string", PropertyType.STRING, List.of(tv)); assertEquals(tv.getValue(PropertyType.STRING), propInfo.getValue(PropertyType.STRING)); } @Test(expected = RepositoryException.class) public void testGetValueMultiple() throws Exception { - List tvs = ImmutableList.of(mockTextValue("24", PropertyType.LONG), mockTextValue("35", PropertyType.LONG)); + List tvs = List.of(mockTextValue("24", PropertyType.LONG), mockTextValue("35", PropertyType.LONG)); PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, tvs); propInfo.getValue(PropertyType.LONG); @@ -227,19 +226,19 @@ public void testGetValuesSingle() throws Exception { TextValue tv = mockTextValue("value", PropertyType.STRING); PropInfo propInfo = new PropInfo("string", PropertyType.STRING, tv); - assertEquals(ImmutableList.of(tv.getValue(PropertyType.STRING)), propInfo.getValues(PropertyType.STRING)); + assertEquals(List.of(tv.getValue(PropertyType.STRING)), propInfo.getValues(PropertyType.STRING)); } @Test public void testGetValuesEmpty() throws Exception { - PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, ImmutableList.of()); + PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, List.of()); assertTrue(propInfo.getValues(PropertyType.LONG).isEmpty()); } @Test public void testGetValuesMultiple() throws Exception { - List tvs = ImmutableList.of(mockTextValue("24", PropertyType.LONG)); + List tvs = List.of(mockTextValue("24", PropertyType.LONG)); PropInfo propInfo = new PropInfo("longs", PropertyType.LONG, tvs); assertEquals(Lists.transform(tvs, input -> { @@ -263,7 +262,7 @@ public void testAsPropertyStateSingle() throws Exception { @Test public void testAsPropertyStateEmptyList() throws Exception { - PropInfo propInfo = new PropInfo("string", PropertyType.STRING, ImmutableList.of()); + PropInfo propInfo = new PropInfo("string", PropertyType.STRING, List.of()); PropertyState ps = propInfo.asPropertyState(mockPropDef(PropertyType.STRING, true)); assertTrue(ps.isArray()); @@ -272,7 +271,7 @@ public void testAsPropertyStateEmptyList() throws Exception { @Test public void testAsPropertyStateSingleList() throws Exception { - PropInfo propInfo = new PropInfo("strings", PropertyType.STRING, ImmutableList.of(mockTextValue("a", PropertyType.STRING)), PropInfo.MultipleStatus.MULTIPLE); + PropInfo propInfo = new PropInfo("strings", PropertyType.STRING, List.of(mockTextValue("a", PropertyType.STRING)), PropInfo.MultipleStatus.MULTIPLE); PropertyState ps = propInfo.asPropertyState(mockPropDef(PropertyType.STRING, true)); assertTrue(ps.isArray()); @@ -281,7 +280,7 @@ public void testAsPropertyStateSingleList() throws Exception { @Test public void testAsPropertyStateMultiples() throws Exception { - PropInfo propInfo = new PropInfo("strings", PropertyType.STRING, ImmutableList.of(mockTextValue("a", PropertyType.STRING), mockTextValue("b", PropertyType.STRING))); + PropInfo propInfo = new PropInfo("strings", PropertyType.STRING, List.of(mockTextValue("a", PropertyType.STRING), mockTextValue("b", PropertyType.STRING))); PropertyState ps = propInfo.asPropertyState(mockPropDef(PropertyType.STRING, true)); assertTrue(ps.isArray()); diff --git a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/ReferenceChangeTrackerTest.java b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/ReferenceChangeTrackerTest.java index fa0b1ace5c8..f3042da9da7 100644 --- a/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/ReferenceChangeTrackerTest.java +++ b/oak-security-spi/src/test/java/org/apache/jackrabbit/oak/spi/xml/ReferenceChangeTrackerTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.spi.xml; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.junit.Test; @@ -53,7 +52,7 @@ public void testReferenceProcessing() { assertTrue(Iterators.elementsEqual(List.of("ref", "ref2").iterator(), rct.getProcessedReferences())); - rct.removeReferences(ImmutableList.of("ref")); + rct.removeReferences(List.of("ref")); assertTrue(Iterators.elementsEqual(List.of("ref2").iterator(), rct.getProcessedReferences())); } diff --git a/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureJournalFile.java b/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureJournalFile.java index 18da8df6ef1..086784a2646 100644 --- a/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureJournalFile.java +++ b/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureJournalFile.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.segment.azure; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import com.microsoft.azure.storage.StorageException; import com.microsoft.azure.storage.blob.CloudAppendBlob; import com.microsoft.azure.storage.blob.CloudBlob; @@ -207,7 +206,7 @@ public void truncate() throws IOException { @Override public void writeLine(String line) throws IOException { - batchWriteLines(ImmutableList.of(line)); + batchWriteLines(List.of(line)); } @Override @@ -220,10 +219,9 @@ public void batchWriteLines(List lines) throws IOException { int firstBlockSize = Math.min(lineLimit - lineCount, lines.size()); List firstBlock = lines.subList(0, firstBlockSize); List> remainingBlocks = CollectionUtils.partitionList(lines.subList(firstBlockSize, lines.size()), lineLimit); - List> allBlocks = ImmutableList.>builder() - .addAll(firstBlock.isEmpty() ? ImmutableList.of() : ImmutableList.of(firstBlock)) - .addAll(remainingBlocks) - .build(); + List> allBlocks = new ArrayList<>(); + allBlocks.addAll(firstBlock.isEmpty() ? List.of() : List.of(firstBlock)); + allBlocks.addAll(remainingBlocks); for (List entries : allBlocks) { if (lineCount >= lineLimit) { diff --git a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/proc/TarNode.java b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/proc/TarNode.java index 34554d546de..735e0b7b016 100644 --- a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/proc/TarNode.java +++ b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/proc/TarNode.java @@ -15,15 +15,14 @@ * limitations under the License. * */ - package org.apache.jackrabbit.oak.segment.file.proc; import static org.apache.jackrabbit.oak.plugins.memory.PropertyStates.createProperty; +import java.util.List; import java.util.stream.Collectors; import java.util.stream.StreamSupport; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState; import org.apache.jackrabbit.oak.segment.file.proc.Proc.Backend; @@ -45,7 +44,7 @@ class TarNode extends AbstractNode { @NotNull @Override public Iterable getProperties() { - return ImmutableList.of( + return List.of( createProperty("name", name), createProperty("size", backend.getTarSize(name).orElse(-1L)) ); diff --git a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/iotrace/BreadthFirstTrace.java b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/iotrace/BreadthFirstTrace.java index 6ba2d618a8b..ad2321edbcf 100644 --- a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/iotrace/BreadthFirstTrace.java +++ b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/iotrace/BreadthFirstTrace.java @@ -30,7 +30,6 @@ import java.util.function.Consumer; import java.util.function.Function; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.jetbrains.annotations.NotNull; @@ -113,7 +112,7 @@ private void traverse(@NotNull Queue nodes, int depth) { } private static void updateContext(@NotNull Consumer> context, int depth, int count) { - context.accept(ImmutableList.of(valueOf(depth), valueOf(count))); + context.accept(List.of(valueOf(depth), valueOf(count))); } } diff --git a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/iotrace/DepthFirstTrace.java b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/iotrace/DepthFirstTrace.java index 396824c1175..87705aca77b 100644 --- a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/iotrace/DepthFirstTrace.java +++ b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/iotrace/DepthFirstTrace.java @@ -15,7 +15,6 @@ * limitations under the License. * */ - package org.apache.jackrabbit.oak.segment.tool.iotrace; import static org.apache.jackrabbit.oak.commons.conditions.Validate.checkArgument; @@ -29,7 +28,6 @@ import java.util.function.Consumer; import java.util.function.Function; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.jetbrains.annotations.NotNull; @@ -100,7 +98,7 @@ private void traverse(NodeState node, int depth, @NotNull String path) { private static void updateContext( @NotNull Consumer> context, int depth, int count, @NotNull String path) { - context.accept(ImmutableList.of(valueOf(depth), valueOf(count), path)); + context.accept(List.of(valueOf(depth), valueOf(count), path)); } } diff --git a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/iotrace/IOTraceMonitor.java b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/iotrace/IOTraceMonitor.java index c6ac98affdf..a7c790d68b2 100644 --- a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/iotrace/IOTraceMonitor.java +++ b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/iotrace/IOTraceMonitor.java @@ -30,7 +30,6 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitor; import org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitorAdapter; import org.jetbrains.annotations.NotNull; @@ -43,7 +42,7 @@ public class IOTraceMonitor extends IOMonitorAdapter implements Flushable { @NotNull private final AtomicReference> context = - new AtomicReference<>(ImmutableList.of()); + new AtomicReference<>(List.of()); @NotNull private final IOTraceWriter traceWriter; diff --git a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/iotrace/RandomAccessTrace.java b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/iotrace/RandomAccessTrace.java index 2c7f63b60ea..f58bfbc5beb 100644 --- a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/iotrace/RandomAccessTrace.java +++ b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/iotrace/RandomAccessTrace.java @@ -15,7 +15,6 @@ * limitations under the License. * */ - package org.apache.jackrabbit.oak.segment.tool.iotrace; import static java.util.Objects.requireNonNull; @@ -28,7 +27,6 @@ import java.util.Random; import java.util.function.Consumer; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.jetbrains.annotations.NotNull; @@ -73,7 +71,7 @@ public void run(@NotNull NodeState root) { if(!paths.isEmpty()) { for (int c = 0; c < count; c++) { String path = paths.get(rnd.nextInt(paths.size())); - context.accept(ImmutableList.of(path)); + context.accept(List.of(path)); NodeState node = root; for (String name : elements(getParentPath(path))) { diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentDataStoreBlobGCIT.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentDataStoreBlobGCIT.java index dc2fa923114..b214bac8e8b 100644 --- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentDataStoreBlobGCIT.java +++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentDataStoreBlobGCIT.java @@ -43,8 +43,6 @@ import ch.qos.logback.classic.Level; import org.apache.jackrabbit.guava.common.base.Stopwatch; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.guava.common.collect.Sets; import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.FileFilterUtils; @@ -345,7 +343,7 @@ public void consistencyCheckWithRenegadeDelete() throws Exception { Random rand = new Random(87); List existing = new ArrayList<>(state.blobsPresent); - long count = blobStore.countDeleteChunks(ImmutableList.of(existing.get(rand.nextInt(existing.size()))), 0); + long count = blobStore.countDeleteChunks(List.of(existing.get(rand.nextInt(existing.size()))), 0); ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10); MarkSweepGarbageCollector gcObj = init(86400, executor); diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentParserTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentParserTest.java index 2ea0bc251c6..d9789d14d01 100644 --- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentParserTest.java +++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentParserTest.java @@ -46,7 +46,6 @@ import java.util.Map; import java.util.Random; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.Blob; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob; @@ -229,7 +228,7 @@ public void template() throws IOException { builder.setChildNode("n"); builder.setProperty("p", 1); builder.setProperty("jcr:primaryType", "type", NAME); - builder.setProperty("jcr:mixinTypes", ImmutableList.of("type1", "type2"), NAMES); + builder.setProperty("jcr:mixinTypes", List.of("type1", "type2"), NAMES); SegmentNodeState node = new SegmentNodeState(store.getReader(), writer, store.getBlobStore(), writer.writeNode(builder.getNodeState())); NodeInfo nodeInfo = new TestParser(store.getReader(), "template") { @Override @@ -320,7 +319,7 @@ protected void onProperty(RecordId parentId, RecordId propertyId, PropertyTempla @Test public void multiValueProperty() throws IOException { NodeBuilder builder = EMPTY_NODE.builder(); - builder.setProperty("p", ImmutableList.of(1L, 2L, 3L, 4L), LONGS); + builder.setProperty("p", List.of(1L, 2L, 3L, 4L), LONGS); SegmentNodeState node = new SegmentNodeState(store.getReader(), writer, store.getBlobStore(), writer.writeNode(builder.getNodeState())); NodeInfo nodeInfo = new TestParser(store.getReader(), "multiValueProperty") { @Override diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/spi/monitor/CompositeIOMonitorTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/spi/monitor/CompositeIOMonitorTest.java index eaa91f98c88..7d8100061ef 100644 --- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/spi/monitor/CompositeIOMonitorTest.java +++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/spi/monitor/CompositeIOMonitorTest.java @@ -15,14 +15,13 @@ * limitations under the License. * */ - package org.apache.jackrabbit.oak.segment.spi.monitor; import static org.junit.Assert.assertEquals; import java.io.File; +import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.whiteboard.Registration; import org.junit.Test; @@ -31,8 +30,8 @@ public class CompositeIOMonitorTest { @Test public void testComposition() { - ImmutableList ioMonitors = - ImmutableList.of(new IOMonitorAssertion(), new IOMonitorAssertion()); + List ioMonitors = + List.of(new IOMonitorAssertion(), new IOMonitorAssertion()); IOMonitor ioMonitor = new CompositeIOMonitor(ioMonitors); ioMonitor.beforeSegmentRead(FILE, 0, 0, 0); @@ -50,8 +49,8 @@ public void testComposition() { @Test public void testUnregisterComposition() { - ImmutableList ioMonitors = - ImmutableList.of(new IOMonitorAssertion(), new IOMonitorAssertion()); + List ioMonitors = + List.of(new IOMonitorAssertion(), new IOMonitorAssertion()); CompositeIOMonitor ioMonitor = new CompositeIOMonitor(); ioMonitor.registerIOMonitor(ioMonitors.get(0)); diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/BreadthFirstTraceTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/BreadthFirstTraceTest.java index b64deaf958e..e46f0235097 100644 --- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/BreadthFirstTraceTest.java +++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/BreadthFirstTraceTest.java @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.jetbrains.annotations.NotNull; @@ -46,7 +45,7 @@ public void testTraverseEmptyTree() { List> trace = new ArrayList<>(); new BreadthFirstTrace(4, "/", trace::add).run(createTree(0)); assertEquals(1, trace.size()); - assertEquals(ImmutableList.of("0", "1"), trace.get(0)); + assertEquals(List.of("0", "1"), trace.get(0)); } @Test @@ -54,8 +53,8 @@ public void testTraverseDepth1Tree() { List> trace = new ArrayList<>(); new BreadthFirstTrace(4, "/", trace::add).run(createTree(1)); assertEquals(2, trace.size()); - assertEquals(ImmutableList.of("0", "1"), trace.get(0)); - assertEquals(ImmutableList.of("1", "2"), trace.get(1)); + assertEquals(List.of("0", "1"), trace.get(0)); + assertEquals(List.of("1", "2"), trace.get(1)); } @Test @@ -63,9 +62,9 @@ public void testTraverseDepth2Tree() { List> trace = new ArrayList<>(); new BreadthFirstTrace(4, "/", trace::add).run(createTree(2)); assertEquals(3, trace.size()); - assertEquals(ImmutableList.of("0", "1"), trace.get(0)); - assertEquals(ImmutableList.of("1", "2"), trace.get(1)); - assertEquals(ImmutableList.of("2", "3"), trace.get(2)); + assertEquals(List.of("0", "1"), trace.get(0)); + assertEquals(List.of("1", "2"), trace.get(1)); + assertEquals(List.of("2", "3"), trace.get(2)); } @Test @@ -73,9 +72,9 @@ public void testTraverseDepth3TreeWithLimit2() { List> trace = new ArrayList<>(); new BreadthFirstTrace(2, "/", trace::add).run(createTree(3)); assertEquals(3, trace.size()); - assertEquals(ImmutableList.of("0", "1"), trace.get(0)); - assertEquals(ImmutableList.of("1", "2"), trace.get(1)); - assertEquals(ImmutableList.of("2", "3"), trace.get(2)); + assertEquals(List.of("0", "1"), trace.get(0)); + assertEquals(List.of("1", "2"), trace.get(1)); + assertEquals(List.of("2", "3"), trace.get(2)); } } diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/DepthFirstTraceTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/DepthFirstTraceTest.java index 5f3ef1902a1..079b4d5413f 100644 --- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/DepthFirstTraceTest.java +++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/DepthFirstTraceTest.java @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.jetbrains.annotations.NotNull; @@ -46,7 +45,7 @@ public void testTraverseEmptyTree() { List> trace = new ArrayList<>(); new DepthFirstTrace(4, "/", trace::add).run(createTree(0)); assertEquals(1, trace.size()); - assertEquals(ImmutableList.of("0", "1", "/"), trace.get(0)); + assertEquals(List.of("0", "1", "/"), trace.get(0)); } @Test @@ -54,8 +53,8 @@ public void testTraverseDepth1Tree() { List> trace = new ArrayList<>(); new DepthFirstTrace(4, "/", trace::add).run(createTree(1)); assertEquals(2, trace.size()); - assertEquals(ImmutableList.of("0", "1", "/"), trace.get(0)); - assertEquals(ImmutableList.of("1", "2", "/node-0"), trace.get(1)); + assertEquals(List.of("0", "1", "/"), trace.get(0)); + assertEquals(List.of("1", "2", "/node-0"), trace.get(1)); } @Test @@ -63,9 +62,9 @@ public void testTraverseDepth2Tree() { List> trace = new ArrayList<>(); new DepthFirstTrace(4, "/", trace::add).run(createTree(2)); assertEquals(3, trace.size()); - assertEquals(ImmutableList.of("0", "1", "/"), trace.get(0)); - assertEquals(ImmutableList.of("1", "2", "/node-0"), trace.get(1)); - assertEquals(ImmutableList.of("2", "3", "/node-0/node-1"), trace.get(2)); + assertEquals(List.of("0", "1", "/"), trace.get(0)); + assertEquals(List.of("1", "2", "/node-0"), trace.get(1)); + assertEquals(List.of("2", "3", "/node-0/node-1"), trace.get(2)); } @Test @@ -73,9 +72,9 @@ public void testTraverseDepth3TreeWithLimit2() { List> trace = new ArrayList<>(); new DepthFirstTrace(2, "/", trace::add).run(createTree(3)); assertEquals(3, trace.size()); - assertEquals(ImmutableList.of("0", "1", "/"), trace.get(0)); - assertEquals(ImmutableList.of("1", "2", "/node-0"), trace.get(1)); - assertEquals(ImmutableList.of("2", "3", "/node-0/node-1"), trace.get(2)); + assertEquals(List.of("0", "1", "/"), trace.get(0)); + assertEquals(List.of("1", "2", "/node-0"), trace.get(1)); + assertEquals(List.of("2", "3", "/node-0/node-1"), trace.get(2)); } } diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/IOTracerTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/IOTracerTest.java index c088d724e62..e5b05ec0ab5 100644 --- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/IOTracerTest.java +++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/IOTracerTest.java @@ -39,7 +39,6 @@ import java.util.Set; import java.util.function.Function; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.segment.SegmentNodeBuilder; import org.apache.jackrabbit.oak.segment.SegmentNodeState; import org.apache.jackrabbit.oak.segment.file.FileStore; @@ -176,7 +175,7 @@ public void collectRandomAccessTrace() throws IOException { Function factory = this::createFileStore; IOTracer ioTracer = newIOTracer(factory, out, RandomAccessTrace.CONTEXT_SPEC); - ImmutableList paths = ImmutableList.of("/1a", "/1b", "/foo"); + List paths = List.of("/1a", "/1b", "/foo"); ioTracer.collectTrace( new RandomAccessTrace(paths, 0, 10, ioTracer::setContext)); diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/RandomTraceTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/RandomTraceTest.java index e2e6b04ed69..170c78c7a6d 100644 --- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/RandomTraceTest.java +++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/tool/iotrace/RandomTraceTest.java @@ -26,7 +26,6 @@ import java.util.ArrayList; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.jetbrains.annotations.NotNull; @@ -61,16 +60,16 @@ public void testTraverseEmptyTree() { @Test public void testTraverseNonExistingPath() { List> trace = new ArrayList<>(); - new RandomAccessTrace(ImmutableList.of("/not/here"), 0, 1, trace::add) + new RandomAccessTrace(List.of("/not/here"), 0, 1, trace::add) .run(createTree(emptyList())); assertEquals(1, trace.size()); - assertEquals(ImmutableList.of("/not/here"), trace.get(0)); + assertEquals(List.of("/not/here"), trace.get(0)); } @Test public void testTraverse() { List> trace = new ArrayList<>(); - ImmutableList paths = ImmutableList.of("/a/b/c", "/d/e/f"); + List paths = List.of("/a/b/c", "/d/e/f"); new RandomAccessTrace(paths, 0, 2, trace::add) .run(createTree(paths)); assertEquals(2, trace.size()); diff --git a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndexProvider.java b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndexProvider.java index 7d7574cc72a..20cc356acc4 100644 --- a/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndexProvider.java +++ b/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndexProvider.java @@ -17,7 +17,6 @@ package org.apache.jackrabbit.oak.plugins.index.solr.query; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider; import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider; import org.apache.jackrabbit.oak.spi.query.QueryIndex; @@ -51,7 +50,7 @@ public SolrQueryIndexProvider(@NotNull SolrServerProvider solrServerProvider, @N @NotNull @Override public List getQueryIndexes(NodeState nodeState) { - return ImmutableList.of(new SolrQueryIndex(aggregator, oakSolrConfigurationProvider, solrServerProvider)); + return List.of(new SolrQueryIndex(aggregator, oakSolrConfigurationProvider, solrServerProvider)); } } diff --git a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexIT.java b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexIT.java index a1a57ba78a7..442093b54c8 100644 --- a/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexIT.java +++ b/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexIT.java @@ -20,8 +20,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.Iterator; +import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.api.ContentRepository; @@ -322,7 +322,7 @@ public void testTokenizeCN() throws Exception { Tree one = t.addChild("one"); one.setProperty("t", "美女衬衫"); root.commit(); - assertQuery("//*[jcr:contains(., '美女')]", "xpath", ImmutableList.of(one.getPath())); + assertQuery("//*[jcr:contains(., '美女')]", "xpath", List.of(one.getPath())); } @Test @@ -364,13 +364,13 @@ public void contains() throws Exception { stmt.append("/jcr:root//*[jcr:contains(., '").append(h); stmt.append("')]"); assertQuery(stmt.toString(), "xpath", - ImmutableList.of("/test/a", "/test/b")); + List.of("/test/a", "/test/b")); // query 'world' stmt = new StringBuffer(); stmt.append("/jcr:root//*[jcr:contains(., '").append(w); stmt.append("')]"); - assertQuery(stmt.toString(), "xpath", ImmutableList.of("/test/a")); + assertQuery(stmt.toString(), "xpath", List.of("/test/a")); } @@ -384,9 +384,9 @@ public void containsDash() throws Exception { root.commit(); assertQuery("/jcr:root//*[jcr:contains(., 'hello-wor*')]", "xpath", - ImmutableList.of("/test/a", "/test/b")); + List.of("/test/a", "/test/b")); assertQuery("/jcr:root//*[jcr:contains(., '*hello-wor*')]", "xpath", - ImmutableList.of("/test/a", "/test/b")); + List.of("/test/a", "/test/b")); } @@ -398,7 +398,7 @@ public void multiPhraseQuery() throws Exception { assertQuery( "/jcr:root//*[jcr:contains(@dc:format, 'type:appli*')]", - "xpath", ImmutableList.of("/test/a")); + "xpath", List.of("/test/a")); } @@ -411,19 +411,19 @@ public void testFulltextOperators() throws Exception { assertQuery( "/jcr:root//*[jcr:contains(., 'lazy AND brown')]", - "xpath", ImmutableList.of("/test/a")); + "xpath", List.of("/test/a")); assertQuery( "/jcr:root//*[jcr:contains(., 'lazy OR eat')]", - "xpath", ImmutableList.of("/test/a", "/test/b")); + "xpath", List.of("/test/a", "/test/b")); assertQuery( "/jcr:root//*[jcr:contains(., 'lazy AND bones')]", - "xpath", ImmutableList.of("/test/b")); + "xpath", List.of("/test/b")); assertQuery( "/jcr:root//*[jcr:contains(., 'lazy OR dog')]", - "xpath", ImmutableList.of("/test/a", "/test/b")); + "xpath", List.of("/test/a", "/test/b")); } @Test @@ -433,7 +433,7 @@ public void containsPath() throws Exception { test.addChild("a").setProperty("name", "/parent/child/node"); root.commit(); - assertQuery("//*[jcr:contains(., '/parent/child')]", "xpath", ImmutableList.of("/test/a")); + assertQuery("//*[jcr:contains(., '/parent/child')]", "xpath", List.of("/test/a")); } @@ -445,7 +445,7 @@ public void containsPathNum() throws Exception { a.setProperty("name", "/segment1/segment2/segment3"); root.commit(); - assertQuery("//*[jcr:contains(., '/segment1/segment2')]", "xpath", ImmutableList.of("/test/a")); + assertQuery("//*[jcr:contains(., '/segment1/segment2')]", "xpath", List.of("/test/a")); } @@ -470,7 +470,7 @@ public void testOAK1208() throws Exception { root.commit(); assertQuery("//*[jcr:contains(., 'media') and (@p = 'dam/smartcollection' or @p = 'dam/collection') ]", "xpath", - ImmutableList.of(one.getPath(), two.getPath())); + List.of(one.getPath(), two.getPath())); } @Test diff --git a/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreServiceTest.java b/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreServiceTest.java index d52f8c07e53..aab0f42e482 100644 --- a/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreServiceTest.java +++ b/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreServiceTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.composite; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import java.util.List; import java.util.Map; @@ -72,8 +71,8 @@ public void bootstrapMultiMount() throws CommitFailedException { nodeStoreLibs.merge(libsRoot, EmptyHook.INSTANCE, CommitInfo.EMPTY); // Define read-only mounts - registerActivateMountInfoConfig("libs", ImmutableList.of("/libs")); - registerActivateMountInfoConfig("apps", ImmutableList.of("/apps")); + registerActivateMountInfoConfig("libs", List.of("/libs")); + registerActivateMountInfoConfig("apps", List.of("/apps")); registerMountInfoProviderService("libs", "apps"); diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CachingCommitValueResolver.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CachingCommitValueResolver.java index 4af0e07fee4..7732472daf1 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CachingCommitValueResolver.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/CachingCommitValueResolver.java @@ -28,7 +28,6 @@ import org.slf4j.LoggerFactory; import static org.apache.jackrabbit.guava.common.cache.CacheBuilder.newBuilder; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; /** * Resolves the commit value for a given change revision on a document. @@ -36,7 +35,7 @@ final class CachingCommitValueResolver implements CommitValueResolver { private static final List COMMIT_ROOT_OR_REVISIONS - = of(NodeDocument.COMMIT_ROOT, NodeDocument.REVISIONS); + = List.of(NodeDocument.COMMIT_ROOT, NodeDocument.REVISIONS); private final Cache commitValueCache; diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java index db2f1e12a53..18b6f58c25b 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java @@ -136,9 +136,7 @@ import org.apache.jackrabbit.guava.common.base.Stopwatch; import org.apache.jackrabbit.guava.common.base.Strings; - import org.apache.jackrabbit.guava.common.base.Suppliers; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; @@ -164,7 +162,7 @@ public final class DocumentNodeStore * List of meta properties which are created by DocumentNodeStore and which needs to be * retained in any cloned copy of DocumentNodeState. */ - public static final List META_PROP_NAMES = ImmutableList.of( + public static final List META_PROP_NAMES = List.of( DocumentBundlor.META_PROP_PATTERN, DocumentBundlor.META_PROP_BUNDLING_PATH, DocumentBundlor.META_PROP_NON_BUNDLED_CHILD, diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/FormatVersion.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/FormatVersion.java index 5f7f4ed5799..43cede1b151 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/FormatVersion.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/FormatVersion.java @@ -20,7 +20,6 @@ import java.util.List; import org.apache.jackrabbit.guava.common.collect.ComparisonChain; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import static java.util.Objects.requireNonNull; import static org.apache.jackrabbit.oak.plugins.document.Collection.SETTINGS; @@ -98,7 +97,7 @@ public final class FormatVersion implements Comparable { * @return well known format versions. */ public static Iterable values() { - return ImmutableList.of(V0, V1_0, V1_2, V1_4, V1_6, V1_8); + return List.of(V0, V1_0, V1_2, V1_4, V1_6, V1_8); } /** diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java index 039781089b7..4eaf1367e50 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java @@ -19,7 +19,6 @@ import static java.util.Objects.requireNonNull; import static java.util.stream.Collectors.toSet; import static org.apache.jackrabbit.oak.commons.conditions.Validate.checkArgument; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static org.apache.jackrabbit.guava.common.collect.Iterables.filter; import static org.apache.jackrabbit.guava.common.collect.Iterables.mergeSorted; import static org.apache.jackrabbit.guava.common.collect.Iterables.transform; @@ -55,7 +54,6 @@ import org.apache.jackrabbit.guava.common.cache.Cache; import org.apache.jackrabbit.guava.common.collect.AbstractIterator; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Maps; import org.apache.jackrabbit.guava.common.collect.Ordering; @@ -766,7 +764,7 @@ Revision getNewestRevision(final RevisionContext context, // if we don't have clusterIds, we can use the local changes only boolean fullScan = true; Iterable changes = Iterables.mergeSorted( - ImmutableList.of( + List.of( getLocalRevisions().keySet(), getLocalCommitRoot().keySet()), getLocalRevisions().comparator() @@ -777,7 +775,7 @@ Revision getNewestRevision(final RevisionContext context, // include previous documents as well (only needed in rare cases) fullScan = false; changes = Iterables.mergeSorted( - ImmutableList.of( + List.of( changes, getChanges(REVISIONS, lower), getChanges(COMMIT_ROOT, lower) @@ -1561,7 +1559,7 @@ NodeDocument findPrevReferencingDoc(Revision revision, int height) { */ Iterable getAllChanges() { RevisionVector empty = new RevisionVector(); - return Iterables.mergeSorted(ImmutableList.of( + return Iterables.mergeSorted(List.of( getChanges(REVISIONS, empty), getChanges(COMMIT_ROOT, empty) ), StableRevisionComparator.REVERSE); @@ -1820,7 +1818,7 @@ public Iterator> iterator() { } }; } else { - changes = Iterables.concat(transform(copyOf(ranges), rangeToChanges::apply)); + changes = Iterables.concat(transform(List.copyOf(ranges), rangeToChanges::apply)); } return filter(changes, input -> !readRev.isRevisionNewer(input.getKey())); } diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtils.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtils.java index 2da4803dbe4..f2d772c666d 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtils.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtils.java @@ -27,9 +27,9 @@ import java.util.Set; import java.util.function.Predicate; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.jetbrains.annotations.NotNull; @@ -86,7 +86,7 @@ public static Set getChildNodeNames(Collection keys, Matcher mat int expectedDepth = matcher.depth() + 1; for (String key : keys){ - List elements = ImmutableList.copyOf(PathUtils.elements(key)); + List elements = CollectionUtils.toList(PathUtils.elements(key)); int depth = elements.size() - 1; if (depth == expectedDepth diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlor.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlor.java index 30fbb255186..eb060ba1e8f 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlor.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlor.java @@ -21,7 +21,6 @@ import java.util.ArrayList; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; @@ -95,7 +94,7 @@ public static DocumentBundlor from(PropertyState prop){ private DocumentBundlor(List includes) { checkArgument(!includes.isEmpty(), "Include list cannot be empty"); - this.includes = ImmutableList.copyOf(includes); + this.includes = List.copyOf(includes); } public boolean isBundled(String relativePath) { diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/Include.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/Include.java index 5fea58f80e8..b0076156176 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/Include.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/Include.java @@ -22,8 +22,8 @@ import java.util.ArrayList; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import static org.apache.jackrabbit.guava.common.base.Preconditions.checkElementIndex; @@ -53,7 +53,7 @@ enum Directive {ALL, NONE} private final String pattern; public Include(String pattern){ - List pathElements = ImmutableList.copyOf(PathUtils.elements(pattern)); + List pathElements = CollectionUtils.toList(PathUtils.elements(pattern)); List elementList = new ArrayList<>(pathElements.size()); Directive directive = Directive.NONE; for (int i = 0; i < pathElements.size(); i++) { diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java index aee7b7af64b..9f8ec9feb6d 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java @@ -40,7 +40,6 @@ import java.util.stream.StreamSupport; import org.apache.jackrabbit.guava.common.base.Stopwatch; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.guava.common.collect.Lists; @@ -2056,7 +2055,7 @@ public Map getMetadata() { @Override public Map getStats() { Map builder = new HashMap<>(); - List> all = ImmutableList.of(nodes, clusterNodes, settings, journal); + List> all = List.of(nodes, clusterNodes, settings, journal); all.forEach(c -> toMapBuilder(builder, connection.getDatabase().runCommand( new BasicDBObject("collStats", c.getNamespace().getCollectionName()), diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStoreMetrics.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStoreMetrics.java index 72f46012eee..12eb91a8b0e 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStoreMetrics.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStoreMetrics.java @@ -16,10 +16,10 @@ */ package org.apache.jackrabbit.oak.plugins.document.mongo; +import java.util.List; import java.util.Set; import java.util.TreeSet; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import com.mongodb.BasicDBObject; import com.mongodb.MongoException; @@ -39,7 +39,7 @@ public final class MongoDocumentStoreMetrics implements Runnable { private static final Logger LOG = LoggerFactory.getLogger(MongoDocumentStoreMetrics.class); - private static final ImmutableList> COLLECTIONS = ImmutableList.of( + private static final List> COLLECTIONS = List.of( Collection.NODES, Collection.JOURNAL, Collection.CLUSTER_NODES, Collection.SETTINGS, Collection.BLOBS ); diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreBuilder.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreBuilder.java index d54c45d1c96..37d8975ec19 100644 --- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreBuilder.java +++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreBuilder.java @@ -16,13 +16,11 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.document.secondary; import java.util.Collections; import java.util.List; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.plugins.document.NodeStateDiffer; import org.apache.jackrabbit.oak.spi.filter.PathFilter; import org.apache.jackrabbit.oak.spi.state.NodeStore; @@ -57,7 +55,7 @@ public SecondaryStoreBuilder statisticsProvider(StatisticsProvider statisticsPro } public SecondaryStoreBuilder metaPropNames(List metaPropNames) { - this.metaPropNames = ImmutableList.copyOf(metaPropNames); + this.metaPropNames = List.copyOf(metaPropNames); return this; } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobReferenceIteratorTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobReferenceIteratorTest.java index 55731e41abc..3d16e380f65 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobReferenceIteratorTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BlobReferenceIteratorTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.document; import java.util.ArrayList; @@ -24,10 +23,10 @@ import java.util.List; import java.util.concurrent.TimeUnit; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import com.mongodb.ReadPreference; import org.apache.jackrabbit.oak.api.Blob; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.blob.ReferencedBlob; import org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats; import org.apache.jackrabbit.oak.plugins.document.mongo.MongoTestUtils; @@ -133,7 +132,7 @@ public void testBlobIterator() throws Exception { store.merge(b1, EmptyHook.INSTANCE, CommitInfo.EMPTY); } - List collectedBlobs = ImmutableList.copyOf(store.getReferencedBlobsIterator()); + List collectedBlobs = CollectionUtils.toList(store.getReferencedBlobsIterator()); assertEquals(blobs.size(), collectedBlobs.size()); assertEquals(new HashSet<>(blobs), new HashSet<>(collectedBlobs)); } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java index 7dafb539bb3..9a95ae55416 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java @@ -16,7 +16,6 @@ */ package org.apache.jackrabbit.oak.plugins.document; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static java.util.Collections.emptyList; import static java.util.Collections.synchronizedList; import static java.util.concurrent.TimeUnit.SECONDS; @@ -3920,28 +3919,28 @@ public void getChildNodeCountTest() throws Exception { final long UL = Long.MAX_VALUE; // unknown // childNodeCount = none getChildNodeCountTest(0, - of(0L, 1L), - of(0L, 0L) + List.of(0L, 1L), + List.of(0L, 0L) ); // childNodeCount = less than initial fetch size 42 getChildNodeCountTest(42, - of( 0L, 1L, 41L, 42L, 43L, 100L), - of(42L, 42L, 42L, 42L, 42L, 42L) + List.of( 0L, 1L, 41L, 42L, 43L, 100L), + List.of(42L, 42L, 42L, 42L, 42L, 42L) ); // childNodeCount = initial fetch size (100) getChildNodeCountTest(100, - of( 0L, 1L, 99L, 100L, 101L, 200L), - of(100L, 100L, 100L, 100L, 100L, 100L) + List.of( 0L, 1L, 99L, 100L, 101L, 200L), + List.of(100L, 100L, 100L, 100L, 100L, 100L) ); // childNodeCount = initial fetch size + 1 (100 + 1) getChildNodeCountTest(101, - of(0L, 1L, 99L, 100L, 101L, 200L), - of(UL, UL, UL, UL, 101L, 101L) + List.of(0L, 1L, 99L, 100L, 101L, 200L), + List.of(UL, UL, UL, UL, 101L, 101L) ); // childNodeCount = first two fetches (100 + 200) getChildNodeCountTest(300, - of(0L, 1L, 99L, 100L, 101L, 200L, 299L, 300L, 301L, 400L), - of(UL, UL, UL, UL, 300L, 300L, 300L, 300L, 300L, 300L) + List.of(0L, 1L, 99L, 100L, 101L, 200L, 299L, 300L, 301L, 400L), + List.of(UL, UL, UL, UL, 300L, 300L, 300L, 300L, 300L, 300L) ); } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java index 8b8e72b5da0..9cfe93c690c 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentSplitTest.java @@ -26,7 +26,6 @@ import java.util.Set; import java.util.TreeSet; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; import org.apache.jackrabbit.oak.api.CommitFailedException; @@ -49,7 +48,6 @@ import org.apache.jackrabbit.guava.common.collect.Iterables; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES; import static org.apache.jackrabbit.oak.plugins.document.MongoBlobGCTest.randomStream; import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.DOC_SIZE_THRESHOLD; @@ -353,7 +351,7 @@ public void testSplitDocNoChild() throws Exception{ } ns.runBackgroundOperations(); NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo")); - List prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(doc.getAllPreviousDocs()); assertEquals(1, prevDocs.size()); assertEquals(SplitDocType.DEFAULT_LEAF, prevDocs.get(0).getSplitDocType()); } @@ -376,7 +374,7 @@ public void testSplitPropAndCommitOnly() throws Exception{ } ns.runBackgroundOperations(); NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo")); - List prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(doc.getAllPreviousDocs()); assertEquals(1, prevDocs.size()); assertEquals(SplitDocType.COMMIT_ROOT_ONLY, prevDocs.get(0).getSplitDocType()); } @@ -398,7 +396,7 @@ public void splitDocWithHasBinary() throws Exception{ } ns.runBackgroundOperations(); NodeDocument doc = store.find(NODES, Utils.getIdFromPath("/test/foo")); - List prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(doc.getAllPreviousDocs()); assertEquals(1, prevDocs.size()); //Check for hasBinary @@ -451,7 +449,7 @@ private void cascadingSplit(String path) { assertNotNull(doc); assertEquals(2, doc.getPreviousRanges().size()); - List prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(doc.getAllPreviousDocs()); //1 intermediate and 11 previous doc assertEquals(1 + 11, prevDocs.size()); assertTrue(prevDocs.stream().anyMatch(input -> input.getSplitDocType() == SplitDocType.INTERMEDIATE)); @@ -916,7 +914,7 @@ public void splitDocumentWithBinary() throws Exception { NodeDocument foo = store.find(NODES, Utils.getIdFromPath("/foo")); assertNotNull(foo); - List prevDocs = copyOf(foo.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(foo.getAllPreviousDocs()); // all but most recent value are moved to individual previous docs assertEquals(9, prevDocs.size()); } @@ -950,7 +948,7 @@ public void noBinarySplitWhenRemoved() throws Exception { // now the old binary value must be moved to a previous document foo = store.find(NODES, Utils.getIdFromPath("/foo")); assertNotNull(foo); - List prevDocs = copyOf(foo.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(foo.getAllPreviousDocs()); assertEquals(1, prevDocs.size()); } @@ -973,7 +971,7 @@ public void noSplitForSmallBinary() throws Exception { NodeDocument foo = store.find(NODES, Utils.getIdFromPath("/foo")); assertNotNull(foo); - List prevDocs = copyOf(foo.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(foo.getAllPreviousDocs()); // must not create split documents for small binaries less 4k assertEquals(0, prevDocs.size()); } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsTest.java index 8a3071fbd4d..6a7ad6ce40e 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentStoreStatsTest.java @@ -16,10 +16,10 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.document; import java.lang.management.ManagementFactory; +import java.util.List; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -35,7 +35,6 @@ import org.junit.Test; import org.slf4j.LoggerFactory; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.oak.plugins.document.Collection.JOURNAL; import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES; import static org.apache.jackrabbit.oak.plugins.document.DocumentStoreStats.JOURNAL_CREATE; @@ -116,11 +115,11 @@ public void doneQuery_Journal() throws Exception{ @Test public void doneCreate_Journal() throws Exception{ - stats.doneCreate(100, Collection.JOURNAL, of("a", "b"), true); + stats.doneCreate(100, Collection.JOURNAL, List.of("a", "b"), true); assertEquals(2, getMeter(DocumentStoreStats.JOURNAL_CREATE).getCount()); assertEquals(100, getTimer(DocumentStoreStats.JOURNAL_CREATE_TIMER).getSnapshot().getMax()); - stats.doneCreate(100, JOURNAL, of("c", "d"), false); + stats.doneCreate(100, JOURNAL, List.of("c", "d"), false); assertEquals(4, getMeter(JOURNAL_CREATE).getCount()); assertEquals(100, getTimer(JOURNAL_CREATE_TIMER).getSnapshot().getMax()); } @@ -129,24 +128,24 @@ public void doneCreate_Journal() throws Exception{ public void doneCreate_Nodes() { // empty list of ids - stats.doneCreate(100, NODES, of(), true); + stats.doneCreate(100, NODES, List.of(), true); assertEquals(0, getMeter(NODES_CREATE).getCount()); assertEquals(0, getMeter(NODES_CREATE_SPLIT).getCount()); assertEquals(0, getTimer(NODES_CREATE_TIMER).getSnapshot().getMax()); - stats.doneCreate(100, NODES, of("a", "b"), true); + stats.doneCreate(100, NODES, List.of("a", "b"), true); assertEquals(2, getMeter(NODES_CREATE).getCount()); assertEquals(0, getMeter(NODES_CREATE_SPLIT).getCount()); assertEquals(50, getTimer(NODES_CREATE_TIMER).getSnapshot().getMax()); // adding an Id with previous doc - stats.doneCreate(200, NODES, of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), true); + stats.doneCreate(200, NODES, List.of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), true); assertEquals(3, getMeter(NODES_CREATE).getCount()); assertEquals(1, getMeter(NODES_CREATE_SPLIT).getCount()); assertEquals(200, getTimer(NODES_CREATE_TIMER).getSnapshot().getMax()); // if insert is not successful - stats.doneCreate(200, NODES, of("c"), false); + stats.doneCreate(200, NODES, List.of("c"), false); assertEquals(3, getMeter(NODES_CREATE).getCount()); assertEquals(1, getMeter(NODES_CREATE_SPLIT).getCount()); assertEquals(200, getTimer(NODES_CREATE_TIMER).getSnapshot().getMax()); @@ -160,24 +159,24 @@ public void doneCreate_Nodes() { public void doneCreateOrUpdate() { // empty list of ids - stats.doneCreateOrUpdate(100, NODES, of()); + stats.doneCreateOrUpdate(100, NODES, List.of()); assertEquals(0, getMeter(NODES_CREATE_UPSERT).getCount()); assertEquals(0, getMeter(NODES_CREATE_SPLIT).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax()); - stats.doneCreateOrUpdate(100, NODES, of("a", "b")); + stats.doneCreateOrUpdate(100, NODES, List.of("a", "b")); assertEquals(2, getMeter(NODES_CREATE_UPSERT).getCount()); assertEquals(0, getMeter(NODES_CREATE_SPLIT).getCount()); assertEquals(50, getTimer(NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax()); // adding an Id with previous Doc - stats.doneCreateOrUpdate(200, NODES, of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3")); + stats.doneCreateOrUpdate(200, NODES, List.of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3")); assertEquals(3, getMeter(NODES_CREATE_UPSERT).getCount()); assertEquals(1, getMeter(NODES_CREATE_SPLIT).getCount()); assertEquals(200, getTimer(NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax()); // insert is done for journal collection - stats.doneCreateOrUpdate(200, JOURNAL, of("c")); + stats.doneCreateOrUpdate(200, JOURNAL, List.of("c")); assertEquals(3, getMeter(NODES_CREATE_UPSERT).getCount()); assertEquals(1, getMeter(NODES_CREATE_SPLIT).getCount()); assertEquals(200, getTimer(NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax()); @@ -199,21 +198,21 @@ public void doneFindAndModify() throws Exception{ public void doneBulkFindAndModify() { // no node had been updated i.e. empty list of Ids - stats.doneFindAndModify(100, NODES, of(), true, 0); + stats.doneFindAndModify(100, NODES, List.of(), true, 0); assertEquals(0, getMeter(NODES_CREATE_UPSERT).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax()); assertEquals(0, getMeter(NODES_UPDATE).getCount()); assertEquals(0, getTimer(NODES_UPDATE_TIMER).getSnapshot().getMax()); // 2 nodes had been updated - stats.doneFindAndModify(100, NODES, of("foo", "bar"), true, 0); + stats.doneFindAndModify(100, NODES, List.of("foo", "bar"), true, 0); assertEquals(0, getMeter(NODES_CREATE_UPSERT).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax()); assertEquals(2, getMeter(NODES_UPDATE).getCount()); assertEquals(50, getTimer(NODES_UPDATE_TIMER).getSnapshot().getMax()); // fails to update 2 nodes without retrying - stats.doneFindAndModify(100, NODES, of("foo", "bar"), false, 0); + stats.doneFindAndModify(100, NODES, List.of("foo", "bar"), false, 0); assertEquals(0, getMeter(NODES_CREATE_UPSERT).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax()); assertEquals(2, getMeter(NODES_UPDATE).getCount()); @@ -222,7 +221,7 @@ public void doneBulkFindAndModify() { assertEquals(1, getMeter(NODES_UPDATE_FAILURE).getCount()); // update is done on Journal collection - stats.doneFindAndModify(100, JOURNAL, of("foo", "bar"), true, 0); + stats.doneFindAndModify(100, JOURNAL, List.of("foo", "bar"), true, 0); assertEquals(0, getMeter(NODES_CREATE_UPSERT).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_TIMER).getSnapshot().getMax()); assertEquals(2, getMeter(NODES_UPDATE).getCount()); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/FormatVersionTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/FormatVersionTest.java index dcf2ea492ed..e94038e9344 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/FormatVersionTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/FormatVersionTest.java @@ -19,8 +19,6 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; - import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore; import org.junit.Test; @@ -102,7 +100,7 @@ public void writeTo() throws Exception { // must not write dummy version assertFalse(V0.writeTo(store)); // upgrade - for (FormatVersion v : ImmutableList.of(V1_0, V1_2, V1_4, V1_6, V1_8)) { + for (FormatVersion v : List.of(V1_0, V1_2, V1_4, V1_6, V1_8)) { assertTrue(v.writeTo(store)); assertSame(v, FormatVersion.versionOf(store)); } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoBlobGCTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoBlobGCTest.java index 274769ecffe..b5fbbea014c 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoBlobGCTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoBlobGCTest.java @@ -36,8 +36,6 @@ import org.apache.jackrabbit.guava.common.base.Splitter; import org.apache.jackrabbit.guava.common.base.Stopwatch; import org.apache.jackrabbit.guava.common.base.Strings; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.guava.common.collect.Sets; import org.apache.jackrabbit.guava.common.io.Closeables; import com.mongodb.BasicDBObject; @@ -320,8 +318,8 @@ public void consistencyCheckWithRenegadeDelete() throws Exception { GarbageCollectableBlobStore store = (GarbageCollectableBlobStore) mk.getNodeStore().getBlobStore(); - long count = store.countDeleteChunks(ImmutableList.of(existing.get(rand.nextInt(existing.size()))), 0); - + long count = store.countDeleteChunks(List.of(existing.get(rand.nextInt(existing.size()))), 0); + ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10); MarkSweepGarbageCollector gcObj = init(86400, executor); long candidates = gcObj.checkConsistency(); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ThrottlingStatsCollectorImplTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ThrottlingStatsCollectorImplTest.java index 6bd4c02838d..ea7a75b17d6 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ThrottlingStatsCollectorImplTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/ThrottlingStatsCollectorImplTest.java @@ -25,9 +25,9 @@ import org.junit.After; import org.junit.Test; +import java.util.List; import java.util.concurrent.ScheduledExecutorService; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static java.lang.management.ManagementFactory.getPlatformMBeanServer; import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; import static org.apache.jackrabbit.oak.plugins.document.Collection.JOURNAL; @@ -65,16 +65,16 @@ public void shutDown(){ @Test public void doneCreateJournal() { - stats.doneCreate(100, JOURNAL, of("a", "b"), true); + stats.doneCreate(100, JOURNAL, List.of("a", "b"), true); assertEquals(2, getMeter(JOURNAL_CREATE_THROTTLING).getCount()); assertEquals(100, getTimer(JOURNAL_CREATE_THROTTLING_TIMER).getSnapshot().getMax()); - stats.doneCreate(200, JOURNAL, of("c", "d"), true); + stats.doneCreate(200, JOURNAL, List.of("c", "d"), true); assertEquals(4, getMeter(JOURNAL_CREATE_THROTTLING).getCount()); assertEquals(200, getTimer(JOURNAL_CREATE_THROTTLING_TIMER).getSnapshot().getMax()); // journal metrics updated even if insert is not successful - stats.doneCreate(200, JOURNAL, of("e", "f"), false); + stats.doneCreate(200, JOURNAL, List.of("e", "f"), false); assertEquals(6, getMeter(JOURNAL_CREATE_THROTTLING).getCount()); assertEquals(200, getTimer(JOURNAL_CREATE_THROTTLING_TIMER).getSnapshot().getMax()); @@ -88,24 +88,24 @@ public void doneCreateJournal() { public void doneCreateNodes() { // empty list of ids - stats.doneCreate(100, NODES, of(), true); + stats.doneCreate(100, NODES, List.of(), true); assertEquals(0, getMeter(NODES_CREATE_THROTTLING).getCount()); assertEquals(0, getMeter(NODES_CREATE_SPLIT_THROTTLING).getCount()); assertEquals(0, getTimer(NODES_CREATE_THROTTLING_TIMER).getSnapshot().getMax()); - stats.doneCreate(100, NODES, of("a", "b"), true); + stats.doneCreate(100, NODES, List.of("a", "b"), true); assertEquals(2, getMeter(NODES_CREATE_THROTTLING).getCount()); assertEquals(0, getMeter(NODES_CREATE_SPLIT_THROTTLING).getCount()); assertEquals(50, getTimer(NODES_CREATE_THROTTLING_TIMER).getSnapshot().getMax()); // adding an Id with previous Doc - stats.doneCreate(200, NODES, of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), true); + stats.doneCreate(200, NODES, List.of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), true); assertEquals(3, getMeter(NODES_CREATE_THROTTLING).getCount()); assertEquals(1, getMeter(NODES_CREATE_SPLIT_THROTTLING).getCount()); assertEquals(200, getTimer(NODES_CREATE_THROTTLING_TIMER).getSnapshot().getMax()); // insert is not successful - stats.doneCreate(200, NODES, of("c"), false); + stats.doneCreate(200, NODES, List.of("c"), false); assertEquals(3, getMeter(NODES_CREATE_THROTTLING).getCount()); assertEquals(1, getMeter(NODES_CREATE_SPLIT_THROTTLING).getCount()); assertEquals(200, getTimer(NODES_CREATE_THROTTLING_TIMER).getSnapshot().getMax()); @@ -119,24 +119,24 @@ public void doneCreateNodes() { public void doneCreateOrUpdate() { // empty list of ids - stats.doneCreateOrUpdate(100, NODES, of()); + stats.doneCreateOrUpdate(100, NODES, List.of()); assertEquals(0, getMeter(NODES_CREATE_UPSERT_THROTTLING).getCount()); assertEquals(0, getMeter(NODES_CREATE_SPLIT_THROTTLING).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_THROTTLING_TIMER).getSnapshot().getMax()); - stats.doneCreateOrUpdate(100, NODES, of("a", "b")); + stats.doneCreateOrUpdate(100, NODES, List.of("a", "b")); assertEquals(2, getMeter(NODES_CREATE_UPSERT_THROTTLING).getCount()); assertEquals(0, getMeter(NODES_CREATE_SPLIT_THROTTLING).getCount()); assertEquals(50, getTimer(NODES_CREATE_UPSERT_THROTTLING_TIMER).getSnapshot().getMax()); // adding an Id with previous Doc - stats.doneCreateOrUpdate(200, NODES, of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3")); + stats.doneCreateOrUpdate(200, NODES, List.of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3")); assertEquals(3, getMeter(NODES_CREATE_UPSERT_THROTTLING).getCount()); assertEquals(1, getMeter(NODES_CREATE_SPLIT_THROTTLING).getCount()); assertEquals(200, getTimer(NODES_CREATE_UPSERT_THROTTLING_TIMER).getSnapshot().getMax()); // insert is done for journal collection - stats.doneCreateOrUpdate(200, JOURNAL, of("c")); + stats.doneCreateOrUpdate(200, JOURNAL, List.of("c")); assertEquals(3, getMeter(NODES_CREATE_UPSERT_THROTTLING).getCount()); assertEquals(1, getMeter(NODES_CREATE_SPLIT_THROTTLING).getCount()); assertEquals(200, getTimer(NODES_CREATE_UPSERT_THROTTLING_TIMER).getSnapshot().getMax()); @@ -178,7 +178,7 @@ public void doneFindAndModify() { public void doneBulkFindAndModify() { // no node had been updated i.e. empty list of Ids - stats.doneFindAndModify(100, NODES, of(), true, 0); + stats.doneFindAndModify(100, NODES, List.of(), true, 0); assertEquals(0, getMeter(NODES_CREATE_UPSERT_THROTTLING).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_THROTTLING_TIMER).getSnapshot().getMax()); assertEquals(0, getMeter(NODES_UPDATE_THROTTLING).getCount()); @@ -186,14 +186,14 @@ public void doneBulkFindAndModify() { assertEquals(0, getMeter(NODES_UPDATE_RETRY_COUNT_THROTTLING).getCount()); // 2 nodes had been updated - stats.doneFindAndModify(100, NODES, of("foo", "bar"), true, 0); + stats.doneFindAndModify(100, NODES, List.of("foo", "bar"), true, 0); assertEquals(0, getMeter(NODES_CREATE_UPSERT_THROTTLING).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_THROTTLING_TIMER).getSnapshot().getMax()); assertEquals(2, getMeter(NODES_UPDATE_THROTTLING).getCount()); assertEquals(50, getTimer(NODES_UPDATE_THROTTLING_TIMER).getSnapshot().getMax()); // fails to update 2 nodes without retrying - stats.doneFindAndModify(100, NODES, of("foo", "bar"), false, 0); + stats.doneFindAndModify(100, NODES, List.of("foo", "bar"), false, 0); assertEquals(0, getMeter(NODES_CREATE_UPSERT_THROTTLING).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_THROTTLING_TIMER).getSnapshot().getMax()); assertEquals(2, getMeter(NODES_UPDATE_THROTTLING).getCount()); @@ -202,14 +202,14 @@ public void doneBulkFindAndModify() { assertEquals(1, getMeter(NODES_UPDATE_FAILURE_THROTTLING).getCount()); // entry updated after 3 retries - stats.doneFindAndModify(100, NODES, of("foo", "bar"), true, 3); + stats.doneFindAndModify(100, NODES, List.of("foo", "bar"), true, 3); assertEquals(4, getMeter(NODES_UPDATE_THROTTLING).getCount()); assertEquals(50, getTimer(NODES_UPDATE_THROTTLING_TIMER).getSnapshot().getMax()); assertEquals(3, getMeter(NODES_UPDATE_RETRY_COUNT_THROTTLING).getCount()); assertEquals(1, getMeter(NODES_UPDATE_FAILURE_THROTTLING).getCount()); // update is done on Journal collection - stats.doneFindAndModify(100, JOURNAL, of("foo", "bar"), true, 0); + stats.doneFindAndModify(100, JOURNAL, List.of("foo", "bar"), true, 0); assertEquals(0, getMeter(NODES_CREATE_UPSERT_THROTTLING).getCount()); assertEquals(0, getTimer(NODES_CREATE_UPSERT_THROTTLING_TIMER).getSnapshot().getMax()); assertEquals(4, getMeter(NODES_UPDATE_THROTTLING).getCount()); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java index 9fc0a3a8c63..a6f1020b67b 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java @@ -103,9 +103,7 @@ import org.apache.jackrabbit.guava.common.cache.Cache; import org.apache.jackrabbit.guava.common.collect.AbstractIterator; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterators; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.guava.common.collect.Queues; import com.mongodb.ReadPreference; @@ -3070,11 +3068,11 @@ private void gcSplitDocsInternal(String subNodeName) throws Exception { store1.runBackgroundOperations(); List previousDocTestFoo = - ImmutableList.copyOf(getDoc("/test/" + subNodeName).getAllPreviousDocs()); + CollectionUtils.toList(getDoc("/test/" + subNodeName).getAllPreviousDocs()); List previousDocTestFoo2 = - ImmutableList.copyOf(getDoc("/test2/" + subNodeName).getAllPreviousDocs()); + CollectionUtils.toList(getDoc("/test2/" + subNodeName).getAllPreviousDocs()); List previousDocRoot = - ImmutableList.copyOf(getDoc("/").getAllPreviousDocs()); + CollectionUtils.toList(getDoc("/").getAllPreviousDocs()); assertEquals(1, previousDocTestFoo.size()); assertEquals(1, previousDocTestFoo2.size()); @@ -3096,7 +3094,7 @@ private void gcSplitDocsInternal(String subNodeName) throws Exception { //Following would not work for Mongo as the delete happened on the server side //And entries from cache are not evicted - //assertTrue(ImmutableList.copyOf(getDoc("/test2/foo").getAllPreviousDocs()).isEmpty()); + //assertTrue(List.copyOf(getDoc("/test2/foo").getAllPreviousDocs()).isEmpty()); } /** @@ -3813,7 +3811,7 @@ public void gcDefaultNoBranchSplitDoc() throws Exception { NodeDocument doc = getDoc("/foo"); assertNotNull(doc); - List prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(doc.getAllPreviousDocs()); assertEquals(1, prevDocs.size()); assertEquals(SplitDocType.DEFAULT_NO_BRANCH, prevDocs.get(0).getSplitDocType()); @@ -3824,7 +3822,7 @@ public void gcDefaultNoBranchSplitDoc() throws Exception { doc = getDoc("/foo"); assertNotNull(doc); - prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs()); + prevDocs = CollectionUtils.toList(doc.getAllPreviousDocs()); assertEquals(0, prevDocs.size()); assertEquals(value, store1.getRoot().getChildNode("foo").getString("prop")); @@ -3851,7 +3849,7 @@ public void gcWithOldSweepRev() throws Exception { // now /foo must have previous docs NodeDocument doc = getDoc("/foo"); - List prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs()); + List prevDocs = CollectionUtils.toList(doc.getAllPreviousDocs()); assertEquals(1, prevDocs.size()); assertEquals(SplitDocType.DEFAULT_NO_BRANCH, prevDocs.get(0).getSplitDocType()); @@ -3877,7 +3875,7 @@ public void gcWithOldSweepRev() throws Exception { doc = getDoc("/foo"); assertNotNull(doc); - prevDocs = ImmutableList.copyOf(doc.getAllPreviousDocs()); + prevDocs = CollectionUtils.toList(doc.getAllPreviousDocs()); assertEquals(0, prevDocs.size()); // check value assertEquals(value, store1.getRoot().getChildNode("foo").getString("prop")); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/RDBBlobStoreTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/RDBBlobStoreTest.java index 06dd7dcec38..9dc5f19cf25 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/RDBBlobStoreTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/RDBBlobStoreTest.java @@ -47,9 +47,6 @@ import org.slf4j.LoggerFactory; import org.slf4j.event.Level; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; -import org.apache.jackrabbit.guava.common.collect.Lists; - /** * Tests the RDBBlobStore implementation. */ @@ -199,7 +196,7 @@ public void testUpdateAndDelete() throws Exception { RDBBlobStoreFriend.storeBlock(blobStore, digest, 0, data); // Metadata row should not have been touched Assert.assertFalse("entry was cleaned although it shouldn't have", - blobStore.deleteChunks(ImmutableList.of(id), beforeUpdateTs)); + blobStore.deleteChunks(List.of(id), beforeUpdateTs)); // Actual data row should still be present Assert.assertNotNull(RDBBlobStoreFriend.readBlockFromBackend(blobStore, digest)); } @@ -228,7 +225,7 @@ public void testDeleteChunks() throws Exception { byte[] digest2 = getDigest(data2); RDBBlobStoreFriend.storeBlock(blobStore, digest2, 0, data2); - Assert.assertEquals("meta entry was not removed", 1, blobStore.countDeleteChunks(ImmutableList.of(id1), now)); + Assert.assertEquals("meta entry was not removed", 1, blobStore.countDeleteChunks(List.of(id1), now)); Assert.assertFalse("data entry was not removed", RDBBlobStoreFriend.isDataEntryPresent(blobStore, digest1)); } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledDocumentDifferTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledDocumentDifferTest.java index a833ad94cb3..e1a56780172 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledDocumentDifferTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledDocumentDifferTest.java @@ -20,7 +20,7 @@ package org.apache.jackrabbit.oak.plugins.document.bundlor; import java.util.Collections; - +import java.util.List; import org.apache.jackrabbit.guava.common.collect.ArrayListMultimap; import org.apache.jackrabbit.guava.common.collect.ListMultimap; @@ -47,7 +47,6 @@ import org.junit.Rule; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore.SYS_PROP_DISABLE_JOURNAL; import static org.apache.jackrabbit.oak.plugins.document.TestUtils.childBuilder; import static org.apache.jackrabbit.oak.plugins.document.TestUtils.createChild; @@ -185,7 +184,7 @@ public void diffFewChildren() throws Exception{ @Test public void jsopDiff() throws Exception{ JsopWriter w = new JsopBuilder(); - differ.diffChildren(of("a", "b"), of("b", "c"), w); + differ.diffChildren(List.of("a", "b"), List.of("b", "c"), w); //removed a //changed b @@ -246,7 +245,7 @@ private AbstractDocumentNodeState adns(NodeState root, String path){ } private SecondaryStoreCache configureSecondary(){ - SecondaryStoreBuilder builder = createBuilder(new PathFilter(of("/"), Collections.emptyList())); + SecondaryStoreBuilder builder = createBuilder(new PathFilter(List.of("/"), Collections.emptyList())); builder.metaPropNames(DocumentNodeStore.META_PROP_NAMES); SecondaryStoreCache cache = builder.buildCache(); SecondaryStoreObserver observer = builder.buildObserver(cache); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java index 9e0f958c535..63ab8c5e904 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java @@ -26,13 +26,13 @@ import java.util.Set; import org.apache.jackrabbit.guava.common.collect.Iterables; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.jackrabbit.oak.api.Blob; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.document.Collection; import org.apache.jackrabbit.oak.plugins.document.Document; import org.apache.jackrabbit.oak.plugins.document.DocumentMKBuilderProvider; @@ -67,7 +67,6 @@ import static java.lang.String.format; import static java.util.Objects.requireNonNull; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf; import static org.apache.commons.io.FileUtils.ONE_MB; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.oak.commons.PathUtils.concat; @@ -1047,7 +1046,7 @@ private static void dump(NodeState state){ } private static List childNames(NodeState state, String path){ - return copyOf(getNode(state, path).getChildNodeNames()); + return CollectionUtils.toList(getNode(state, path).getChildNodeNames()); } static NodeBuilder newNode(String typeName){ diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreCacheTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreCacheTest.java index 4e855dc26a3..7c0ee5eb1f4 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreCacheTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreCacheTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.document.secondary; import java.io.IOException; @@ -51,7 +50,6 @@ import org.junit.Rule; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; import static org.apache.jackrabbit.oak.plugins.document.secondary.SecondaryStoreObserverTest.create; import static org.apache.jackrabbit.oak.plugins.document.secondary.SecondaryStoreObserverTest.documentState; @@ -78,7 +76,7 @@ public void setUp() throws IOException { @Test public void basicTest() throws Exception{ - SecondaryStoreCache cache = createCache(new PathFilter(of("/a"), empty)); + SecondaryStoreCache cache = createCache(new PathFilter(List.of("/a"), empty)); NodeBuilder nb = primary.getRoot().builder(); create(nb, "/a/b", "/a/c", "/x/y/z"); @@ -92,7 +90,7 @@ public void basicTest() throws Exception{ @Test public void updateAndReadAtReadRev() throws Exception{ - SecondaryStoreCache cache = createCache(new PathFilter(of("/a"), empty)); + SecondaryStoreCache cache = createCache(new PathFilter(List.of("/a"), empty)); NodeBuilder nb = primary.getRoot().builder(); create(nb, "/a/b", "/a/c", "/x/y/z"); @@ -130,7 +128,7 @@ public void updateAndReadAtReadRev() throws Exception{ @Test public void updateAndReadAtPrevRevision() throws Exception { - SecondaryStoreCache cache = createCache(new PathFilter(of("/a"), empty)); + SecondaryStoreCache cache = createCache(new PathFilter(List.of("/a"), empty)); NodeBuilder nb = primary.getRoot().builder(); create(nb, "/a/b", "/a/c"); @@ -154,7 +152,7 @@ public void updateAndReadAtPrevRevision() throws Exception { @Test public void binarySearch() throws Exception{ - SecondaryStoreCache cache = createCache(new PathFilter(of("/a"), empty)); + SecondaryStoreCache cache = createCache(new PathFilter(List.of("/a"), empty)); List roots = new ArrayList<>(); List revs = new ArrayList<>(); @@ -185,7 +183,7 @@ public void binarySearch() throws Exception{ @Test public void readWithSecondaryLagging() throws Exception{ - PathFilter pathFilter = new PathFilter(of("/a"), empty); + PathFilter pathFilter = new PathFilter(List.of("/a"), empty); SecondaryStoreCache cache = createBuilder(pathFilter).buildCache(); SecondaryStoreObserver observer = createBuilder(pathFilter).buildObserver(cache); @@ -220,7 +218,7 @@ public void readWithSecondaryLagging() throws Exception{ @Test public void isCached() throws Exception{ - SecondaryStoreCache cache = createCache(new PathFilter(of("/a"), empty)); + SecondaryStoreCache cache = createCache(new PathFilter(List.of("/a"), empty)); assertTrue(cache.isCached(Path.fromString("/a"))); assertTrue(cache.isCached(Path.fromString("/a/b"))); @@ -229,7 +227,7 @@ public void isCached() throws Exception{ @Test public void bundledNodes() throws Exception{ - SecondaryStoreCache cache = createCache(new PathFilter(of("/"), empty)); + SecondaryStoreCache cache = createCache(new PathFilter(List.of("/"), empty)); primary.setNodeStateCache(cache); NodeBuilder builder = primary.getRoot().builder(); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreObserverTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreObserverTest.java index dee3e0b948b..14762e9912f 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreObserverTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreObserverTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.document.secondary; import java.io.IOException; @@ -40,7 +39,6 @@ import org.junit.Rule; import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -61,7 +59,7 @@ public void setUp() throws IOException { @Test public void basicSetup() throws Exception{ - PathFilter pathFilter = new PathFilter(of("/a"), empty); + PathFilter pathFilter = new PathFilter(List.of("/a"), empty); SecondaryStoreObserver observer = createBuilder(pathFilter).buildObserver(); primary.addObserver(observer); @@ -77,7 +75,7 @@ public void basicSetup() throws Exception{ @Test public void childNodeAdded() throws Exception{ - PathFilter pathFilter = new PathFilter(of("/a"), empty); + PathFilter pathFilter = new PathFilter(List.of("/a"), empty); SecondaryStoreObserver observer = createBuilder(pathFilter).buildObserver(); primary.addObserver(observer); @@ -95,7 +93,7 @@ public void childNodeAdded() throws Exception{ @Test public void childNodeChangedAndExclude() throws Exception{ - PathFilter pathFilter = new PathFilter(of("/a"), of("/a/b")); + PathFilter pathFilter = new PathFilter(List.of("/a"), List.of("/a/b")); SecondaryStoreObserver observer = createBuilder(pathFilter).buildObserver(); primary.addObserver(observer); @@ -112,7 +110,7 @@ public void childNodeChangedAndExclude() throws Exception{ @Test public void childNodeDeleted() throws Exception{ - PathFilter pathFilter = new PathFilter(of("/a"), empty); + PathFilter pathFilter = new PathFilter(List.of("/a"), empty); SecondaryStoreObserver observer = createBuilder(pathFilter).buildObserver(); primary.addObserver(observer); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/BaseUpdaterTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/BaseUpdaterTest.java index c3c3985cd1c..c302b002c21 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/BaseUpdaterTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/BaseUpdaterTest.java @@ -20,14 +20,13 @@ import com.codahale.metrics.Meter; import com.codahale.metrics.Timer; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser; import org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider; import org.junit.After; +import java.util.List; import java.util.concurrent.ScheduledExecutorService; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; import static java.lang.management.ManagementFactory.getPlatformMBeanServer; import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; @@ -61,7 +60,7 @@ public abstract class BaseUpdaterTest { static final String NODES_REMOVE_THROTTLING_TIMER = "NODES_REMOVE_THROTTLING_TIMER"; final ScheduledExecutorService executor = newSingleThreadScheduledExecutor(); final MetricStatisticsProvider provider = new MetricStatisticsProvider(getPlatformMBeanServer(), executor); - final ImmutableList ids = of("a", "b"); + final List ids = List.of("a", "b"); Meter getMeter(String name) { return provider.getRegistry().getMeters().get(name); diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/CreateMetricUpdaterTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/CreateMetricUpdaterTest.java index d15c3d01a0a..c04742ae511 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/CreateMetricUpdaterTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/CreateMetricUpdaterTest.java @@ -20,7 +20,8 @@ import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; +import java.util.List; + import static org.apache.jackrabbit.oak.plugins.document.Collection.BLOBS; import static org.apache.jackrabbit.oak.plugins.document.Collection.CLUSTER_NODES; import static org.apache.jackrabbit.oak.plugins.document.Collection.JOURNAL; @@ -84,10 +85,10 @@ public void updateNodes() { @Test public void updateNodesWithPreviousDocId() { - cMUWithoutThrottling.update(NODES, 100, of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); + cMUWithoutThrottling.update(NODES, 100, List.of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); assertNodesWithoutThrottling(1, 1, 100); - cMUWithThrottling.update(NODES, 100, of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); + cMUWithThrottling.update(NODES, 100, List.of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); assertNodesWithThrottling(1, 1, 100); } @@ -99,17 +100,17 @@ public void updateNodesNotSuccessfully() { @Test public void updateNodesEmptyList() { - cMUWithoutThrottling.update(NODES, 100, of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); + cMUWithoutThrottling.update(NODES, 100, List.of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); assertNodesWithoutThrottling(0, 0, 0); } @Test public void updateNonNodesJournalCollection() { - cMUWithoutThrottling.update(BLOBS, 100, of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); + cMUWithoutThrottling.update(BLOBS, 100, List.of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); assertNodesWithoutThrottling(0, 0, 0); assertJournalWithoutThrottling(0, 0); - cMUWithThrottling.update(CLUSTER_NODES, 100, of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); + cMUWithThrottling.update(CLUSTER_NODES, 100, List.of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); assertNodesWithThrottling(0, 0, 0); assertJournalWithThrottling(0, 0); } @@ -134,10 +135,10 @@ public void updateWithJournalNotSuccessfully() { @Test public void updateWithJournalEmptyList() { - cMUWithThrottling.update(JOURNAL, 100, of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); + cMUWithThrottling.update(JOURNAL, 100, List.of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); assertJournalWithThrottling(0, 100); - cMUWithoutThrottling.update(JOURNAL, 100, of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); + cMUWithoutThrottling.update(JOURNAL, 100, List.of(), true, isNodesCollectionUpdated(), getCreateStatsConsumer(), c -> c == JOURNAL, getJournalStatsConsumer()); assertJournalWithoutThrottling(0, 100); } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UpsertMetricUpdaterTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UpsertMetricUpdaterTest.java index 18b5ff9431a..58dc36c5bd7 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UpsertMetricUpdaterTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UpsertMetricUpdaterTest.java @@ -18,7 +18,8 @@ import org.junit.Test; -import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of; +import java.util.List; + import static org.apache.jackrabbit.oak.plugins.document.Collection.JOURNAL; import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES; import static org.apache.jackrabbit.oak.plugins.document.util.StatsCollectorUtil.getCreateStatsConsumer; @@ -54,31 +55,31 @@ public void updateWithNullStatsConsumer() { @Test public void updateNodesEmptyList() { - uMUWithoutThrottling.update(NODES, 100, of(), isNodesCollectionUpdated(), getCreateStatsConsumer()); + uMUWithoutThrottling.update(NODES, 100, List.of(), isNodesCollectionUpdated(), getCreateStatsConsumer()); assertWithoutThrottling(0, 0, 0); } @Test public void updateNonNodesCollection() { - uMUWithThrottling.update(JOURNAL, 100, of(), isNodesCollectionUpdated(), getCreateStatsConsumer()); + uMUWithThrottling.update(JOURNAL, 100, List.of(), isNodesCollectionUpdated(), getCreateStatsConsumer()); assertWithThrottling(0, 0, 0); } @Test public void updateNodes() { - uMUWithThrottling.update(NODES, 100, of("a", "b"), isNodesCollectionUpdated(), getCreateStatsConsumer()); + uMUWithThrottling.update(NODES, 100, List.of("a", "b"), isNodesCollectionUpdated(), getCreateStatsConsumer()); assertWithThrottling(2, 0, 50); - uMUWithoutThrottling.update(NODES, 100, of("a", "b"), isNodesCollectionUpdated(), getCreateStatsConsumer()); + uMUWithoutThrottling.update(NODES, 100, List.of("a", "b"), isNodesCollectionUpdated(), getCreateStatsConsumer()); assertWithoutThrottling(2, 0, 50); } @Test public void updateNodesWithPreviousDocId() { - uMUWithThrottling.update(NODES, 100, of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), isNodesCollectionUpdated(), getCreateStatsConsumer()); + uMUWithThrottling.update(NODES, 100, List.of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), isNodesCollectionUpdated(), getCreateStatsConsumer()); assertWithThrottling(1, 1, 100); - uMUWithoutThrottling.update(NODES, 100, of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), isNodesCollectionUpdated(), getCreateStatsConsumer()); + uMUWithoutThrottling.update(NODES, 100, List.of("15:p/a/b/c/d/e/f/g/h/i/j/k/l/m/r182f83543dd-0-0/3"), isNodesCollectionUpdated(), getCreateStatsConsumer()); assertWithoutThrottling(1, 1, 100); } diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UtilsTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UtilsTest.java index 36fc0143ae9..5e2e671fb50 100644 --- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UtilsTest.java +++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/UtilsTest.java @@ -22,7 +22,6 @@ import java.util.Random; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.collect.Iterables; import org.apache.commons.codec.binary.Hex; @@ -443,34 +442,34 @@ public void getAllDocuments() throws CommitFailedException { @Test public void getMaxExternalRevisionTime() { int localClusterId = 1; - List revs = ImmutableList.of(); + List revs = Collections.emptyList(); long revTime = Utils.getMaxExternalTimestamp(revs, localClusterId); assertEquals(Long.MIN_VALUE, revTime); - revs = ImmutableList.of(Revision.fromString("r1-0-1")); + revs = List.of(Revision.fromString("r1-0-1")); revTime = Utils.getMaxExternalTimestamp(revs, localClusterId); assertEquals(Long.MIN_VALUE, revTime); - revs = ImmutableList.of( + revs = List.of( Revision.fromString("r1-0-1"), Revision.fromString("r2-0-2")); revTime = Utils.getMaxExternalTimestamp(revs, localClusterId); assertEquals(2, revTime); - revs = ImmutableList.of( + revs = List.of( Revision.fromString("r3-0-1"), Revision.fromString("r2-0-2")); revTime = Utils.getMaxExternalTimestamp(revs, localClusterId); assertEquals(2, revTime); - revs = ImmutableList.of( + revs = List.of( Revision.fromString("r1-0-1"), Revision.fromString("r2-0-2"), Revision.fromString("r2-0-3")); revTime = Utils.getMaxExternalTimestamp(revs, localClusterId); assertEquals(2, revTime); - revs = ImmutableList.of( + revs = List.of( Revision.fromString("r1-0-1"), Revision.fromString("r3-0-2"), Revision.fromString("r2-0-3")); diff --git a/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/json/JsonSerializer.java b/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/json/JsonSerializer.java index cff18a54330..3b0415a93c1 100644 --- a/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/json/JsonSerializer.java +++ b/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/json/JsonSerializer.java @@ -30,10 +30,10 @@ import java.util.List; import java.util.regex.Pattern; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.jetbrains.annotations.NotNull; import javax.jcr.PropertyType; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.commons.json.JsopBuilder; import org.apache.jackrabbit.oak.api.Blob; import org.apache.jackrabbit.oak.api.PropertyState; @@ -188,7 +188,7 @@ public void serialize(NodeState node, String basePath) { private Iterable getChildNodeEntries(NodeState node, String basePath) { PropertyState order = node.getProperty(":childOrder"); if (order != null) { - List names = ImmutableList.copyOf(order.getValue(NAMES)); + List names = Collections.unmodifiableList(CollectionUtils.toList(order.getValue(NAMES))); List entries = new ArrayList<>(names.size()); for (String name : names) { try { diff --git a/oak-store-spi/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java b/oak-store-spi/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java index d90dca96b5b..e4d649c0184 100644 --- a/oak-store-spi/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java +++ b/oak-store-spi/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java @@ -24,9 +24,9 @@ import static org.junit.Assert.fail; import java.util.Collection; +import java.util.List; import java.util.Set; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.spi.state.AbstractNodeState; import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry; @@ -57,7 +57,7 @@ public static Collection fixtures() { builder.child("y"); builder.child("z"); NodeState base = builder.getNodeState(); - return ImmutableList.of( + return List.of( new Object[] { base }, new Object[] { ModifiedNodeState.squeeze(base) } ); diff --git a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java index 106a79af12a..db5bf90ebf8 100644 --- a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java +++ b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java @@ -57,7 +57,6 @@ import javax.jcr.PropertyType; import javax.jcr.RepositoryException; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.ReferenceBinary; import org.apache.jackrabbit.core.RepositoryContext; import org.apache.jackrabbit.core.id.NodeId; @@ -137,7 +136,7 @@ class JackrabbitNodeState extends AbstractNodeState { private final Map nodeStateCache; - private final List ignoredPaths = ImmutableList.of("/jcr:system/jcr:nodeTypes"); + private final List ignoredPaths = List.of("/jcr:system/jcr:nodeTypes"); public static JackrabbitNodeState createRootNodeState( RepositoryContext context, diff --git a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java index 2457bc7df8d..b9207991b56 100644 --- a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java +++ b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java @@ -34,6 +34,7 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Arrays; import java.util.Calendar; import java.util.Collection; import java.util.HashMap; @@ -44,6 +45,7 @@ import java.util.Properties; import java.util.Set; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import javax.jcr.NamespaceException; import javax.jcr.Node; @@ -58,9 +60,7 @@ import javax.jcr.security.Privilege; import org.apache.jackrabbit.guava.common.base.Stopwatch; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; -import org.apache.jackrabbit.guava.common.collect.Lists; import org.apache.commons.collections4.bidimap.DualHashBidiMap; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; @@ -774,8 +774,9 @@ private void copyCustomPrivileges(PrivilegeManager pMgr) throws RepositoryExcept while (it.hasNext()) { Privilege aggrPriv = it.next(); - List aggrNames = Lists.transform(ImmutableList.copyOf(aggrPriv.getDeclaredAggregatePrivileges()), - input -> (input == null) ? null : input.getName()); + List aggrNames = Arrays.stream(aggrPriv.getDeclaredAggregatePrivileges()). + map(input -> (input == null) ? null : input.getName()).collect(Collectors.toList()); + if (allAggregatesRegistered(pMgr, aggrNames)) { pMgr.registerPrivilege(aggrPriv.getName(), aggrPriv.isAbstract(), aggrNames.toArray(new String[aggrNames.size()])); it.remove(); diff --git a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/MigrationFactory.java b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/MigrationFactory.java index e02443207f2..849bab245dc 100644 --- a/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/MigrationFactory.java +++ b/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/MigrationFactory.java @@ -17,13 +17,14 @@ package org.apache.jackrabbit.oak.upgrade.cli; import java.io.IOException; -import java.util.Iterator; +import java.util.Collections; import java.util.List; import java.util.ServiceLoader; import javax.jcr.RepositoryException; import org.apache.jackrabbit.core.RepositoryContext; +import org.apache.jackrabbit.oak.commons.collections.CollectionUtils; import org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore; import org.apache.jackrabbit.oak.spi.blob.BlobStore; import org.apache.jackrabbit.oak.spi.commit.CommitHook; @@ -35,7 +36,6 @@ import org.apache.jackrabbit.oak.upgrade.cli.parser.MigrationOptions; import org.apache.jackrabbit.oak.upgrade.cli.parser.StoreArguments; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.guava.common.io.Closer; public class MigrationFactory { @@ -123,9 +123,7 @@ private RepositorySidegrade createSidegrade(NodeStore srcStore, NodeStore dstSto private List loacCommitHooks() { ServiceLoader loader = ServiceLoader.load(CommitHook.class); - Iterator iterator = loader.iterator(); - ImmutableList.Builder builder = ImmutableList. builder().addAll(iterator); - return builder.build(); + return Collections.unmodifiableList(CollectionUtils.toList(loader.iterator())); } } diff --git a/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/PrivilegeUpgradeTest.java b/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/PrivilegeUpgradeTest.java index cc7fd536843..dbe7f4bbb75 100644 --- a/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/PrivilegeUpgradeTest.java +++ b/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/PrivilegeUpgradeTest.java @@ -30,7 +30,6 @@ import javax.jcr.Session; import javax.jcr.security.Privilege; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.api.JackrabbitWorkspace; import org.apache.jackrabbit.api.security.authorization.PrivilegeManager; @@ -187,7 +186,7 @@ public void verifyCustomPrivileges() throws Exception { assertNotNull(aggregate); assertFalse(aggregate.isAbstract()); assertTrue(aggregate.isAggregate()); - List agg = ImmutableList.copyOf(aggregate.getDeclaredAggregatePrivileges()); + List agg = List.of(aggregate.getDeclaredAggregatePrivileges()); assertEquals(2, agg.size()); assertTrue(agg.contains(privilege)); assertTrue(agg.contains(manager.getPrivilege(JCR_READ))); @@ -196,7 +195,7 @@ public void verifyCustomPrivileges() throws Exception { assertNotNull(aggregate2); assertTrue(aggregate2.isAbstract()); assertTrue(aggregate2.isAggregate()); - List agg2 = ImmutableList.copyOf(aggregate2.getDeclaredAggregatePrivileges()); + List agg2 = List.of(aggregate2.getDeclaredAggregatePrivileges()); assertEquals(2, agg2.size()); assertTrue(agg2.contains(aggregate)); assertTrue(agg2.contains(privilege2)); diff --git a/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/util/VersionCopyTestUtils.java b/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/util/VersionCopyTestUtils.java index 6b4a6c4b4b6..d728fc8fd74 100644 --- a/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/util/VersionCopyTestUtils.java +++ b/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/util/VersionCopyTestUtils.java @@ -27,7 +27,6 @@ import javax.jcr.version.VersionIterator; import javax.jcr.version.VersionManager; -import org.apache.jackrabbit.guava.common.collect.ImmutableList; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.plugins.migration.version.VersionCopyConfiguration; @@ -37,7 +36,7 @@ public class VersionCopyTestUtils { - public static List LABELS = ImmutableList.of("1.0", "1.1", "1.2"); + public static List LABELS = List.of("1.0", "1.1", "1.2"); public static Node getOrAddNode(Node parent, String relPath) throws RepositoryException { Node currentParent = parent;