This is an automated email from the ASF dual-hosted git repository.

reschke pushed a commit to branch OAK-11278
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git

commit 7a890cc3fc8258e600e87ca7d04e7aac9e5e1986
Author: Julian Reschke <[email protected]>
AuthorDate: Thu Nov 28 14:22:59 2024 +0100

     OAK-11278: remove ImmutableMap.of - multiple argument case - oak-exercise
---
 .../advanced/L4_CustomAccessControlManagementTest.java    |  7 +++----
 .../permission/L2_PermissionDiscoveryTest.java            | 15 +++++++--------
 .../permission/L4_PrivilegesAndPermissionsTest.java       | 15 +++++++--------
 .../security/privilege/L7_PrivilegeDiscoveryTest.java     | 13 ++++++-------
 .../exercise/security/user/L3_UserVsPrincipalTest.java    |  3 +--
 5 files changed, 24 insertions(+), 29 deletions(-)

diff --git 
a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/advanced/L4_CustomAccessControlManagementTest.java
 
b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/advanced/L4_CustomAccessControlManagementTest.java
index 49edeb49c2..36438d8ab8 100644
--- 
a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/advanced/L4_CustomAccessControlManagementTest.java
+++ 
b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/advanced/L4_CustomAccessControlManagementTest.java
@@ -32,7 +32,6 @@ import javax.jcr.security.AccessControlPolicy;
 import javax.jcr.security.AccessControlPolicyIterator;
 import javax.jcr.security.NamedAccessControlPolicy;
 
-import org.apache.jackrabbit.guava.common.collect.ImmutableMap;
 import org.apache.jackrabbit.api.security.principal.PrincipalManager;
 import org.apache.jackrabbit.oak.AbstractSecurityTest;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
@@ -308,7 +307,7 @@ public class L4_CustomAccessControlManagementTest extends 
AbstractSecurityTest {
     @Test
     public void testGetEffectivePolicies() throws Exception {
         // EXERCISE: set expected number of effective policies for all paths 
in the map.
-        Map<String,Integer> m = ImmutableMap.of("/", -1, "/test", -1, 
"/test/a/b", -1, "/outside", -1);
+        Map<String,Integer> m = Map.of("/", -1, "/test", -1, "/test/a/b", -1, 
"/outside", -1);
 
         for (String path : m.keySet()) {
             AccessControlPolicy[] policies = 
getAcManager(root).getEffectivePolicies(path);
@@ -326,7 +325,7 @@ public class L4_CustomAccessControlManagementTest extends 
AbstractSecurityTest {
     @Test
     public void testGetApplicablePolicies() throws Exception {
         // EXERCISE: set expected number of applicable policies for all paths 
in the map.
-        Map<String,Integer> m = ImmutableMap.of("/test/a", -1, "/test/a/b", 
-1, "/outside", -1);
+        Map<String,Integer> m = Map.of("/test/a", -1, "/test/a/b", -1, 
"/outside", -1);
 
         for (String path : m.keySet()) {
             AccessControlPolicyIterator it = 
getAcManager(root).getApplicablePolicies(path);
@@ -352,7 +351,7 @@ public class L4_CustomAccessControlManagementTest extends 
AbstractSecurityTest {
         root.commit();
 
         PrincipalManager pm = getPrincipalManager(root);
-        Map<Principal,Long> m = ImmutableMap.of(
+        Map<Principal,Long> m = Map.of(
                 getTestUser().getPrincipal(), Permissions.NO_PERMISSION,
                 pm.getEveryone(), Permissions.NO_PERMISSION,
                 pm.getPrincipal("principalR"), Permissions.READ,
diff --git 
a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/permission/L2_PermissionDiscoveryTest.java
 
b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/permission/L2_PermissionDiscoveryTest.java
index 12114f1895..0bd6cbe603 100644
--- 
a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/permission/L2_PermissionDiscoveryTest.java
+++ 
b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/permission/L2_PermissionDiscoveryTest.java
@@ -24,7 +24,6 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.security.Privilege;
 
-import org.apache.jackrabbit.guava.common.collect.ImmutableMap;
 import org.apache.jackrabbit.api.JackrabbitSession;
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.User;
@@ -172,7 +171,7 @@ public class L2_PermissionDiscoveryTest extends 
AbstractJCRTest {
 
     public void testReadAccess() throws RepositoryException {
         // EXERCISE: fill in the expected values
-        Map<String, Boolean[]> nodeTests = ImmutableMap.of(
+        Map<String, Boolean[]> nodeTests = Map.of(
                 "/", existsAndHasPermission(null, null),
                 testRoot, existsAndHasPermission(null, null),
                 childPath, existsAndHasPermission(null, null),
@@ -187,7 +186,7 @@ public class L2_PermissionDiscoveryTest extends 
AbstractJCRTest {
         }
 
         // EXERCISE: fill in the expected values
-        Map<String, Boolean[]> propertyTests = ImmutableMap.of(
+        Map<String, Boolean[]> propertyTests = Map.of(
                 "/jcr:primaryType", existsAndHasPermission(null, null),
                 propertyPath, existsAndHasPermission(null, null),
                 childPath + "/new", existsAndHasPermission(null, null)
@@ -203,7 +202,7 @@ public class L2_PermissionDiscoveryTest extends 
AbstractJCRTest {
 
     public void testModifyPermissions() throws RepositoryException {
         // EXERCISE: fill in the expected values
-        Map<String, Boolean> modifyPropertyTests = ImmutableMap.of(
+        Map<String, Boolean> modifyPropertyTests = Map.of(
                 "/jcr:primaryType", null,
                 testRoot, null,
                 propertyPath, null
@@ -216,7 +215,7 @@ public class L2_PermissionDiscoveryTest extends 
AbstractJCRTest {
 
     public void testRemovePermissions() throws RepositoryException {
         // EXERCISE: fill in the expected values
-        Map<String, Boolean> removePropertyTests = ImmutableMap.of(
+        Map<String, Boolean> removePropertyTests = Map.of(
                 "/jcr:primaryType", null,
                 propertyPath, null,
                 childPath + "/new", null
@@ -227,7 +226,7 @@ public class L2_PermissionDiscoveryTest extends 
AbstractJCRTest {
         }
 
         // EXERCISE: fill in the expected values
-        Map<String, Boolean> removeNodesTests = ImmutableMap.of(
+        Map<String, Boolean> removeNodesTests = Map.of(
                 "/", null,
                 testRoot, null,
                 childPath, null,
@@ -256,7 +255,7 @@ public class L2_PermissionDiscoveryTest extends 
AbstractJCRTest {
 
     public void testAddPermissions() throws RepositoryException {
         // EXERCISE: fill in the expected values
-        Map<String, Boolean> addPropertyTests = ImmutableMap.of(
+        Map<String, Boolean> addPropertyTests = Map.of(
                 "/propertyName1", null,
                 testRoot, null,
                 propertyPath, null,
@@ -268,7 +267,7 @@ public class L2_PermissionDiscoveryTest extends 
AbstractJCRTest {
         }
 
         // EXERCISE: fill in the expected values
-        Map<String, Boolean> addNodesTests = ImmutableMap.of(
+        Map<String, Boolean> addNodesTests = Map.of(
                 "/childNode", null,
                 testRoot, null,
                 testRoot + "/new", null,
diff --git 
a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/permission/L4_PrivilegesAndPermissionsTest.java
 
b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/permission/L4_PrivilegesAndPermissionsTest.java
index 08a3da91c8..b52527bd5a 100644
--- 
a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/permission/L4_PrivilegesAndPermissionsTest.java
+++ 
b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/authorization/permission/L4_PrivilegesAndPermissionsTest.java
@@ -29,7 +29,6 @@ import javax.jcr.Value;
 import javax.jcr.security.AccessControlManager;
 import javax.jcr.security.Privilege;
 
-import org.apache.jackrabbit.guava.common.collect.ImmutableMap;
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.api.JackrabbitSession;
 import org.apache.jackrabbit.api.security.user.Authorizable;
@@ -261,7 +260,7 @@ public class L4_PrivilegesAndPermissionsTest extends 
AbstractJCRTest {
 
         // EXERCISE: fill in the expected return values for 
Session.hasPermission as performed below
         // EXERCISE: verify that the test passes and explain the individual 
results
-        Map<String, Boolean> pathHasPermissionMap = ImmutableMap.of(
+        Map<String, Boolean> pathHasPermissionMap = Map.of(
                 testRootNode.getPath(), null,
                 childPath, null,
                 childPath + "/toCreate", null,
@@ -276,7 +275,7 @@ public class L4_PrivilegesAndPermissionsTest extends 
AbstractJCRTest {
 
         // EXERCISE: fill in the expected return values for 
AccessControlManager#getPrivileges as performed below
         // EXERCISE: verify that the test passes and compare the results with 
your findings from the permission-discovery
-        Map<String, Privilege[]> pathPrivilegesMap = ImmutableMap.of(
+        Map<String, Privilege[]> pathPrivilegesMap = Map.of(
                 testRootNode.getPath(), null,
                 childPath, null,
                 childPath + "/toCreate", null,
@@ -301,7 +300,7 @@ public class L4_PrivilegesAndPermissionsTest extends 
AbstractJCRTest {
 
         // EXERCISE: fill in the expected return values for 
Session.hasPermission as performed below
         // EXERCISE: verify that the test passes and explain the individual 
results
-        Map<String, Boolean[]> pathHasPermissionMap = ImmutableMap.of(
+        Map<String, Boolean[]> pathHasPermissionMap = Map.of(
                 propertyPath, new Boolean[]{null, null},
                 childPath + "/newProp", new Boolean[]{null, null},
                 childPropertyPath, new Boolean[]{null, null},
@@ -322,7 +321,7 @@ public class L4_PrivilegesAndPermissionsTest extends 
AbstractJCRTest {
         // EXERCISE: setup the correct set of privileges such that the test 
passes
         superuser.save();
 
-        Map<String, Boolean> pathHasPermissionMap = ImmutableMap.of(
+        Map<String, Boolean> pathHasPermissionMap = Map.of(
                 testRootNode.getPath(), false,
                 childPath, false,
                 grandChildPath, true
@@ -348,7 +347,7 @@ public class L4_PrivilegesAndPermissionsTest extends 
AbstractJCRTest {
         AccessControlUtils.addAccessControlEntry(superuser, childPath, 
testPrincipal, new String[] {PrivilegeConstants.REP_REMOVE_PROPERTIES}, true);
         superuser.save();
 
-        Map<String, Boolean> pathCanRemoveMap = ImmutableMap.of(
+        Map<String, Boolean> pathCanRemoveMap = Map.of(
                 propertyPath, false,
                 childPropertyPath, true,
                 grandChildPath + "/" + JcrConstants.JCR_PRIMARYTYPE, false,
@@ -382,7 +381,7 @@ public class L4_PrivilegesAndPermissionsTest extends 
AbstractJCRTest {
         superuser.save();
 
         // EXERCISE: fill in the expected values for 
Session.hasPermission(path, Session.ACTION_REMOVE) and explain
-        Map<String, Boolean> pathHasPermission = ImmutableMap.of(
+        Map<String, Boolean> pathHasPermission = Map.of(
                 childPath + "_non_existing_sibling", null,
                 childPath + "/_non_existing_childitem", null,
                 grandChildPath + "/_non_existing_child_item", null
@@ -404,7 +403,7 @@ public class L4_PrivilegesAndPermissionsTest extends 
AbstractJCRTest {
         superuser.save();
 
         // EXERCISE: Fill if setting the property at the path(s) is expected 
to pass or not
-        Map<String, Boolean> pathCanModify = ImmutableMap.of(
+        Map<String, Boolean> pathCanModify = Map.of(
                 propertyPath, null,
                 childPropertyPath, null,
                 grandChildPath + "/" + JcrConstants.JCR_PRIMARYTYPE, null,
diff --git 
a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L7_PrivilegeDiscoveryTest.java
 
b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L7_PrivilegeDiscoveryTest.java
index 0a7cfcc149..68776e651b 100644
--- 
a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L7_PrivilegeDiscoveryTest.java
+++ 
b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/privilege/L7_PrivilegeDiscoveryTest.java
@@ -26,7 +26,6 @@ import javax.jcr.SimpleCredentials;
 import javax.jcr.security.AccessControlManager;
 import javax.jcr.security.Privilege;
 
-import org.apache.jackrabbit.guava.common.collect.ImmutableMap;
 import org.apache.jackrabbit.guava.common.collect.ImmutableSet;
 import org.apache.jackrabbit.api.JackrabbitSession;
 import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager;
@@ -191,7 +190,7 @@ public class L7_PrivilegeDiscoveryTest extends 
AbstractJCRTest {
     public void testHasPrivileges() throws Exception {
         AccessControlManager acMgr = userSession.getAccessControlManager();
 
-        Map<String, String[]> expectedAllow = ImmutableMap.of(
+        Map<String, String[]> expectedAllow = Map.of(
                 testRoot, new String[] {null, null, null, null, null, "..."}, 
// EXERCISE
                 testPath, new String[] {null, null, null, null, null, "..."}, 
// EXERCISE
                 childPath, new String[] {null, null, null, null, null, "..."} 
// EXERCISE
@@ -200,7 +199,7 @@ public class L7_PrivilegeDiscoveryTest extends 
AbstractJCRTest {
             assertTrue(acMgr.hasPrivileges(path, 
AccessControlUtils.privilegesFromNames(userSession, expectedAllow.get(path))));
         }
 
-        Map<String, String[]> expectedDeny = ImmutableMap.of(
+        Map<String, String[]> expectedDeny = Map.of(
                 testRoot, new String[] {null, null, null, null, null, "..."}, 
// EXERCISE
                 testPath, new String[] {null, null, null, null, null, "..."}, 
// EXERCISE
                 childPath, new String[] {null, null, null, null, null, "..."} 
// EXERCISE
@@ -257,7 +256,7 @@ public class L7_PrivilegeDiscoveryTest extends 
AbstractJCRTest {
 
         // 1. EXERCISE: expected privileges for the 'uPrincipal' only
         Set<Principal> principals = Set.of(uPrincipal);
-        Map<String, Set<Privilege>> expected = ImmutableMap.of(
+        Map<String, Set<Privilege>> expected = Map.of(
                 testRoot, null, // EXERCISE
                 testPath, null, // EXERCISE
                 childPath, null // EXERCISE
@@ -270,7 +269,7 @@ public class L7_PrivilegeDiscoveryTest extends 
AbstractJCRTest {
 
         // 2. EXERCISE: expected privileges for the 'gPrincipal' only
         principals = Set.of(gPrincipal);
-        expected = ImmutableMap.of(
+        expected = Map.of(
                 testRoot, null,
                 testPath, null,
                 childPath, null
@@ -283,7 +282,7 @@ public class L7_PrivilegeDiscoveryTest extends 
AbstractJCRTest {
 
         // 3. EXERCISE: expected privileges for the 'uPrincipal' and 
'gPrincipal'
         principals = Set.of(uPrincipal, gPrincipal);
-        expected = ImmutableMap.of(
+        expected = Map.of(
                 testRoot, null,
                 testPath, null,
                 childPath, null
@@ -296,7 +295,7 @@ public class L7_PrivilegeDiscoveryTest extends 
AbstractJCRTest {
 
         // 4. EXERCISE: expected privileges for the 'uPrincipal', 'gPrincipal' 
+ everyone
         principals = Set.of(uPrincipal, gPrincipal, 
EveryonePrincipal.getInstance());
-        expected = ImmutableMap.of(
+        expected = Map.of(
                 testRoot, null,
                 testPath, null,
                 childPath, null
diff --git 
a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L3_UserVsPrincipalTest.java
 
b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L3_UserVsPrincipalTest.java
index 244fec6430..b41617472e 100644
--- 
a/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L3_UserVsPrincipalTest.java
+++ 
b/oak-exercise/src/test/java/org/apache/jackrabbit/oak/exercise/security/user/L3_UserVsPrincipalTest.java
@@ -23,7 +23,6 @@ import javax.jcr.RepositoryException;
 import javax.jcr.security.AccessControlList;
 import javax.jcr.security.AccessControlManager;
 
-import org.apache.jackrabbit.guava.common.collect.ImmutableMap;
 import org.apache.jackrabbit.api.security.principal.PrincipalManager;
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.Group;
@@ -139,7 +138,7 @@ public class L3_UserVsPrincipalTest extends 
AbstractSecurityTest {
 
     @Test
     public void testLookup() throws RepositoryException {
-        Map<String, Object[]> resultMap = ImmutableMap.of(
+        Map<String, Object[]> resultMap = Map.of(
                 testId, new Object[]{null, null, null},
                 testPrincipal.getName(), new Object[]{null, null, null},
                 testGroupId, new Object[]{null, null},

Reply via email to