Skip to content

Commit

Permalink
Revert "OAK-11105: Remove usage of Guava ImmutableMap.of() - zero arg…
Browse files Browse the repository at this point in the history
…ument case"

This reverts commit 9fdfbb6.
  • Loading branch information
reschke committed Nov 18, 2024
1 parent 9fdfbb6 commit 607f849
Show file tree
Hide file tree
Showing 35 changed files with 88 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public Iterable<ExternalIdentityRef> getDeclaredGroups() {
@NotNull
@Override
public Map<String, ?> getProperties() {
return Map.of();
return ImmutableMap.of();
}
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private static void assertAuthorizableConfig(@NotNull DefaultSyncConfig.Authoriz

assertSame(authorizableConfig, authorizableConfig.setPropertyMapping(ImmutableMap.of("a", "b")));
assertEquals(ImmutableMap.of("a", "b"), authorizableConfig.getPropertyMapping());
assertEquals(Map.of(), authorizableConfig.setPropertyMapping(null).getPropertyMapping());
assertEquals(ImmutableMap.of(), authorizableConfig.setPropertyMapping(null).getPropertyMapping());

assertEquals(0, authorizableConfig.getExpirationTime());
assertSame(authorizableConfig, authorizableConfig.setExpirationTime(Long.MAX_VALUE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ public void testSyncPropertiesEmptyMap() throws Exception {
ExternalUser externalUser = idp.getUser(TestIdentityProvider.ID_SECOND_USER);
Authorizable a = syncCtx.createUser(externalUser);

syncCtx.syncProperties(externalUser, a, Map.of());
syncCtx.syncProperties(externalUser, a, ImmutableMap.of());

for (String propName : externalUser.getProperties().keySet()) {
assertFalse(a.hasProperty(propName));
Expand All @@ -1076,7 +1076,7 @@ public void testSyncPropertiesEmptyMapExistingProps() throws Exception {
a.setProperty(propName, anyValue);
}

syncCtx.syncProperties(externalUser, a, Map.of());
syncCtx.syncProperties(externalUser, a, ImmutableMap.of());
for (String propName : extProps.keySet()) {
assertTrue(a.hasProperty(propName));
assertEquals(anyValue, a.getProperty(propName)[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public String getUserId(@NotNull Credentials credentials) {
if (credentials instanceof TestCredentials) {
return attributes;
} else {
return Map.of();
return ImmutableMap.of();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void testSyncAllUsersBeforeSaveError() throws Exception {
Root r = preventRootCommit(delegatee);

String[] result = delegatee.syncAllUsers(false);
assertResultMessages(result, Map.of());
assertResultMessages(result, ImmutableMap.of());
assertFalse(r.hasPendingChanges());
}

Expand Down Expand Up @@ -459,7 +459,7 @@ public void refresh() {

@Override
public void commit() throws CommitFailedException {
commit(Map.of());
commit(ImmutableMap.of());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public void testAddingSyncHandler() {
Map<String, Object> disableProps = ImmutableMap.of(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, false);

SyncHandler sh = new DefaultSyncHandler();
context.registerService(SyncHandler.class, sh, Map.of());
context.registerService(SyncHandler.class, sh, ImmutableMap.of());
assertIsEnabled(externalPrincipalConfiguration, false);

context.registerService(SyncHandler.class, sh, disableProps);
Expand All @@ -365,7 +365,7 @@ public void testAddingCustomSyncHandler() {
Map<String, Object> enableProps = ImmutableMap.of(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, true);

SyncHandler sh = new TestSyncHandler();
context.registerService(SyncHandler.class, sh, Map.of());
context.registerService(SyncHandler.class, sh, ImmutableMap.of());
assertIsEnabled(externalPrincipalConfiguration, false);

context.registerService(SyncHandler.class, sh, enableProps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ public void testBefore() throws Exception {
// - root : lifecycleMgt
policy = (PrincipalPolicyImpl) acMgr.getApplicablePolicies(validPrincipal2)[0];
Map<String, Value> restrictions = ImmutableMap.of(getNamePathMapper().getJcrName(REP_GLOB), getValueFactory(root).createValue("/*/glob"));
policy.addEntry(jcrEffectivePath, privilegesFromNames(JCR_READ), restrictions, Map.of());
policy.addEntry(jcrEffectivePath, privilegesFromNames(JCR_READ), restrictions, ImmutableMap.of());

String ntJcrName = getNamePathMapper().getJcrName(JcrConstants.NT_RESOURCE);
Map<String, Value[]> mvRestrictions = ImmutableMap.of(getNamePathMapper().getJcrName(REP_NT_NAMES), new Value[] {getValueFactory(root).createValue(ntJcrName, PropertyType.NAME)});
policy.addEntry(PathUtils.ROOT_PATH, privilegesFromNames(PrivilegeConstants.JCR_LIFECYCLE_MANAGEMENT), Map.of(), mvRestrictions);
policy.addEntry(PathUtils.ROOT_PATH, privilegesFromNames(PrivilegeConstants.JCR_LIFECYCLE_MANAGEMENT), ImmutableMap.of(), mvRestrictions);

acMgr.setPolicy(policy.getPath(), policy);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public void testIsGrantedOnNonExistingRestrictionTree() throws Exception {
public void testIsGrantedOnRestrictionTree() throws Exception {
PrincipalPolicyImpl policy = getPrincipalPolicyImpl(testPrincipal, getAccessControlManager(root));
Map<String, Value> restr = ImmutableMap.of(getNamePathMapper().getJcrName(REP_GLOB), getValueFactory(root).createValue(REP_RESTRICTIONS + "*"));
policy.addEntry(accessControlledPath, privilegesFromNames(JCR_READ_ACCESS_CONTROL), restr, Map.of());
policy.addEntry(accessControlledPath, privilegesFromNames(JCR_READ_ACCESS_CONTROL), restr, ImmutableMap.of());
root.commit();
permissionProvider.refresh();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void grantReadOnVersionStoreTrees() throws Exception {
JackrabbitAccessControlManager jacm = getAccessControlManager(root);
PrincipalPolicyImpl policy = getPrincipalPolicyImpl(testPrincipal, jacm);
Map<String, Value[]> restr = ImmutableMap.of(REP_NT_NAMES, new Value[] {getValueFactory(root).createValue(REP_VERSIONSTORAGE, PropertyType.NAME)});
policy.addEntry(PathUtils.ROOT_PATH, privilegesFromNames(PrivilegeConstants.JCR_READ), Map.of(), restr);
policy.addEntry(PathUtils.ROOT_PATH, privilegesFromNames(PrivilegeConstants.JCR_READ), ImmutableMap.of(), restr);
jacm.setPolicy(policy.getPath(), policy);
root.commit();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.junit.Rule;
import org.junit.Test;

import java.util.Map;
import java.util.Set;

import static org.junit.Assert.assertEquals;
Expand All @@ -56,7 +55,7 @@ public class PrincipalBasedAuthorizationConfigurationOsgiTest extends AbstractPr

@Test(expected = ReferenceViolationException.class)
public void testMissingMandatoryReferences() {
context.registerInjectActivateService(pbac, Map.of());
context.registerInjectActivateService(pbac, ImmutableMap.of());
}

@Test(expected = ReferenceViolationException.class)
Expand All @@ -68,7 +67,7 @@ public void testMissingMountInfoProviderReference() {
@Test(expected = ReferenceViolationException.class)
public void testMissingFilterProviderReference() {
context.registerInjectActivateService(new MountInfoProviderService());
context.registerInjectActivateService(pbac, Map.of());
context.registerInjectActivateService(pbac, ImmutableMap.of());
}

@Test
Expand All @@ -80,7 +79,7 @@ public void testMountCollidingWithFilterRoot() {
context.registerInjectActivateService(mipService, ImmutableMap.of("mountedPaths", new String[] {SUPPORTED_PATH + "/some/subtree", "/etc"}));

try {
context.registerInjectActivateService(pbac, Map.of());
context.registerInjectActivateService(pbac, ImmutableMap.of());
} catch (RuntimeException e) {
assertTrue(e.getCause() instanceof IllegalStateException);
}
Expand All @@ -94,7 +93,7 @@ public void testMountMatchingFilterRoot() {
MountInfoProviderService mipService = new MountInfoProviderService();
context.registerInjectActivateService(mipService, ImmutableMap.of("mountedPaths", new String[] {SUPPORTED_PATH}));

context.registerInjectActivateService(pbac, Map.of());
context.registerInjectActivateService(pbac, ImmutableMap.of());
}

@Test
Expand All @@ -105,7 +104,7 @@ public void testMountAboveFilterRoot() {
MountInfoProviderService mipService = new MountInfoProviderService();
context.registerInjectActivateService(mipService, ImmutableMap.of("mountedPaths", new String[] {Text.getRelativeParent(SUPPORTED_PATH, 1)}));

context.registerInjectActivateService(pbac, Map.of());
context.registerInjectActivateService(pbac, ImmutableMap.of());
}

@Test
Expand All @@ -116,7 +115,7 @@ public void testMountsElsewhere() {
MountInfoProviderService mipService = new MountInfoProviderService();
context.registerInjectActivateService(mipService, ImmutableMap.of("mountedPaths", new String[] {"/etc", "/var/some/mount", UserConstants.DEFAULT_GROUP_PATH}));

context.registerInjectActivateService(pbac, Map.of());
context.registerInjectActivateService(pbac, ImmutableMap.of());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void before() throws Exception {
JackrabbitAccessControlManager jacm = getAccessControlManager(root);
policy = getPrincipalPolicyImpl(testPrincipal, jacm);
Map<String, Value[]> restrictions = ImmutableMap.of(REP_NT_NAMES, new Value[] {getValueFactory(root).createValue(NT_FOLDER, PropertyType.NAME)});
policy.addEntry(childPath, privilegesFromNames(JCR_REMOVE_NODE), Map.of(), restrictions);
policy.addEntry(childPath, privilegesFromNames(JCR_REMOVE_NODE), ImmutableMap.of(), restrictions);
jacm.setPolicy(policy.getPath(), policy);
root.commit();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public void testAddEntriesForSamePath() throws Exception {
@Test
public void testAddEntriesWithRestrictionsForSamePath() throws Exception {
assertTrue(emptyPolicy.addEntry(testJcrPath, privilegesFromNames(PrivilegeConstants.JCR_ADD_CHILD_NODES)));
assertTrue(emptyPolicy.addEntry(testJcrPath, privilegesFromNames(PrivilegeConstants.JCR_REMOVE_CHILD_NODES), Map.of(), createMvRestrictions(REP_ITEM_NAMES, PropertyType.NAME, "removable")));
assertTrue(emptyPolicy.addEntry(testJcrPath, privilegesFromNames(PrivilegeConstants.JCR_REMOVE_CHILD_NODES), ImmutableMap.of(), createMvRestrictions(REP_ITEM_NAMES, PropertyType.NAME, "removable")));

PrivilegeBitsProvider bitsProvider = new PrivilegeBitsProvider(root);

Expand All @@ -260,8 +260,8 @@ public void testAddEntriesWithRestrictionsForSamePath() throws Exception {

@Test
public void testAddEntriesWithMultipleRestrictionsForSamePath() throws Exception {
assertTrue(emptyPolicy.addEntry(testJcrPath, privilegesFromNames(PrivilegeConstants.JCR_ADD_CHILD_NODES), createGlobRestriction("/any*/glob"), Map.of()));
assertTrue(emptyPolicy.addEntry(testJcrPath, privilegesFromNames(PrivilegeConstants.JCR_REMOVE_CHILD_NODES), Map.of(), createMvRestrictions(REP_ITEM_NAMES, PropertyType.NAME, "removable")));
assertTrue(emptyPolicy.addEntry(testJcrPath, privilegesFromNames(PrivilegeConstants.JCR_ADD_CHILD_NODES), createGlobRestriction("/any*/glob"), ImmutableMap.of()));
assertTrue(emptyPolicy.addEntry(testJcrPath, privilegesFromNames(PrivilegeConstants.JCR_REMOVE_CHILD_NODES), ImmutableMap.of(), createMvRestrictions(REP_ITEM_NAMES, PropertyType.NAME, "removable")));

PrivilegeBitsProvider bitsProvider = new PrivilegeBitsProvider(root);

Expand Down Expand Up @@ -310,7 +310,7 @@ public void testAddEntryMissingMandatoryRestriction() throws Exception {
PrincipalPolicyImpl plc = new PrincipalPolicyImpl(principal, POLICY_OAK_PATH, mp);
String jcrName = namePathMapper.getJcrName("oak:mandatory");
Map<String,Value[]> mvRestrictions = ImmutableMap.of(jcrName, new Value[] {getValueFactory(root).createValue(1)});
plc.addEntry(testJcrPath, privilegesFromNames(PrivilegeConstants.JCR_VERSION_MANAGEMENT), Map.of(), mvRestrictions);
plc.addEntry(testJcrPath, privilegesFromNames(PrivilegeConstants.JCR_VERSION_MANAGEMENT), ImmutableMap.of(), mvRestrictions);
}

@Test(expected = AccessControlException.class)
Expand All @@ -324,7 +324,7 @@ public void testAddEntryMissingMandatoryMVRestriction() throws Exception {
PrincipalPolicyImpl plc = new PrincipalPolicyImpl(principal, POLICY_OAK_PATH, mp);
String jcrName = namePathMapper.getJcrName("oak:mandatory");
Map<String,Value> svRestrictions = ImmutableMap.of(jcrName, getValueFactory(root).createValue(1));
plc.addEntry(testJcrPath, privilegesFromNames(PrivilegeConstants.JCR_VERSION_MANAGEMENT), svRestrictions, Map.of());
plc.addEntry(testJcrPath, privilegesFromNames(PrivilegeConstants.JCR_VERSION_MANAGEMENT), svRestrictions, ImmutableMap.of());
}

@Test(expected = AccessControlException.class)
Expand All @@ -336,7 +336,7 @@ public void testAddEntryMandatoryRestrictionWithOakName() throws Exception {

PrincipalPolicyImpl plc = new PrincipalPolicyImpl(principal, POLICY_OAK_PATH, mp);
Map<String,Value> svRestrictions = ImmutableMap.of("oak:mandatory", getValueFactory(root).createValue(1));
plc.addEntry(testJcrPath, privilegesFromNames(PrivilegeConstants.JCR_VERSION_MANAGEMENT), svRestrictions, Map.of());
plc.addEntry(testJcrPath, privilegesFromNames(PrivilegeConstants.JCR_VERSION_MANAGEMENT), svRestrictions, ImmutableMap.of());
}

@Test
Expand All @@ -355,7 +355,7 @@ public void testAddEntryMandatoryRestriction() throws Exception {

PrincipalPolicyImpl plc = new PrincipalPolicyImpl(principal, POLICY_OAK_PATH, mp);
Map<String,Value> svRestrictions = ImmutableMap.of("mandatory", getValueFactory(root).createValue(1));
plc.addEntry(testJcrPath, privilegesFromNames(PrivilegeConstants.JCR_VERSION_MANAGEMENT), svRestrictions, Map.of());
plc.addEntry(testJcrPath, privilegesFromNames(PrivilegeConstants.JCR_VERSION_MANAGEMENT), svRestrictions, ImmutableMap.of());

assertTrue(plc.getEntries().get(0).getRestrictions().contains(r));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ public void testStartChildInfoNestedRestriction() throws Exception {

importer.startChildInfo(mockNodeInfo("entry", getJcrName(NT_REP_PRINCIPAL_ENTRY)), mockPropInfos("/effective/path", PrivilegeConstants.REP_WRITE));
importer.startChildInfo(mockNodeInfo(getJcrName(REP_RESTRICTIONS), getJcrName(NT_REP_RESTRICTIONS)), mockPropInfos(ImmutableMap.of(getJcrName(REP_GLOB), "/some/glob"), PropertyType.STRING));
importer.startChildInfo(mockNodeInfo(getJcrName(REP_RESTRICTIONS), getJcrName(NT_REP_RESTRICTIONS)), mockPropInfos(Map.of()));
importer.startChildInfo(mockNodeInfo(getJcrName(REP_RESTRICTIONS), getJcrName(NT_REP_RESTRICTIONS)), mockPropInfos(ImmutableMap.of()));
}

@Test(expected = IllegalStateException.class)
Expand All @@ -604,7 +604,7 @@ public void testStartChildInfoNestedMvRestriction() throws Exception {

importer.startChildInfo(mockNodeInfo("entry", getJcrName(NT_REP_PRINCIPAL_ENTRY)), mockPropInfos("/effective/path", PrivilegeConstants.REP_WRITE));
importer.startChildInfo(mockNodeInfo(getJcrName(REP_RESTRICTIONS), getJcrName(NT_REP_RESTRICTIONS)), mockPropInfos(ImmutableMap.of(getJcrName(REP_NT_NAMES), new Value[0])));
importer.startChildInfo(mockNodeInfo(getJcrName(REP_RESTRICTIONS), getJcrName(NT_REP_RESTRICTIONS)), mockPropInfos(Map.of()));
importer.startChildInfo(mockNodeInfo(getJcrName(REP_RESTRICTIONS), getJcrName(NT_REP_RESTRICTIONS)), mockPropInfos(ImmutableMap.of()));
}

@Test(expected = IllegalStateException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public Iterable<ExternalIdentityRef> getDeclaredGroups() {
@NotNull
@Override
public Map<String, ?> getProperties() {
return Map.of();
return ImmutableMap.of();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import javax.security.auth.login.Configuration;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL;
Expand Down Expand Up @@ -127,11 +126,11 @@ public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
new AppConfigurationEntry(
GuestLoginModule.class.getName(),
OPTIONAL,
Map.of()),
ImmutableMap.of()),
new AppConfigurationEntry(
TokenLoginModule.class.getName(),
SUFFICIENT,
Map.of()),
ImmutableMap.of()),
new AppConfigurationEntry(
ExternalLoginModule.class.getName(),
SUFFICIENT,
Expand All @@ -141,7 +140,7 @@ public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
new AppConfigurationEntry(
LoginModuleImpl.class.getName(),
SUFFICIENT,
Map.of())
ImmutableMap.of())
};
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicLong;
Expand Down Expand Up @@ -189,11 +188,11 @@ public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
new AppConfigurationEntry(
GuestLoginModule.class.getName(),
OPTIONAL,
Map.of()),
ImmutableMap.of()),
new AppConfigurationEntry(
TokenLoginModule.class.getName(),
SUFFICIENT,
Map.of()),
ImmutableMap.of()),
new AppConfigurationEntry(
ExternalLoginModule.class.getName(),
SUFFICIENT,
Expand All @@ -203,7 +202,7 @@ public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
new AppConfigurationEntry(
LoginModuleImpl.class.getName(),
SUFFICIENT,
Map.of())
ImmutableMap.of())
};
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicLong;
Expand Down Expand Up @@ -150,11 +149,11 @@ public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
new AppConfigurationEntry(
GuestLoginModule.class.getName(),
OPTIONAL,
Map.of()),
ImmutableMap.of()),
new AppConfigurationEntry(
TokenLoginModule.class.getName(),
SUFFICIENT,
Map.of()),
ImmutableMap.of()),
new AppConfigurationEntry(
ExternalLoginModule.class.getName(),
SUFFICIENT,
Expand All @@ -164,7 +163,7 @@ public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
new AppConfigurationEntry(
LoginModuleImpl.class.getName(),
SUFFICIENT,
Map.of())
ImmutableMap.of())
};
}
};
Expand Down
Loading

0 comments on commit 607f849

Please sign in to comment.