test_class.file: oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionCacheBuilderTest.java
test_class.identifier: PermissionCacheBuilderTest
test_class.superclass: extends AbstractCacheTest
test_case.body: @Test
      public void testInitNumEntriesExceedMaxPathExact() {
          long maxPaths = 2;
          when(store.getNumEntries(anyString(), anyLong())).thenReturn(NumEntries.valueOf(maxPaths+1, true));
  
          assertFalse(permissionCacheBuilder.init(ImmutableSet.of("a", "b", "c"), createStrategy(Long.MAX_VALUE, maxPaths, false)));
  
          verify(store, times(3)).getNumEntries(anyString(), anyLong());
          verify(store, never()).load(anyString());
          verify(store, never()).load(anyString(), anyString());
      }
test_case.class_method_signature: PermissionCacheBuilderTest.testInitNumEntriesExceedMaxPathExact()
test_case.full_signature: @Test public void testInitNumEntriesExceedMaxPathExact()
test_case.identifier: testInitNumEntriesExceedMaxPathExact
test_case.invocations: thenReturn when getNumEntries anyString anyLong valueOf assertFalse init of createStrategy getNumEntries verify times anyString anyLong load verify never anyString load verify never anyString anyString
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testInitNumEntriesExceedMaxPathExact()
focal_class.declarator: store
focal_class.modifier: private final
focal_class.original_string: private final PermissionStore store;
focal_class.type: PermissionStore
focal_class.var_name: store
focal_class.declarator: peCache
focal_class.modifier: private final
focal_class.original_string: private final PermissionEntryCache peCache;
focal_class.type: PermissionEntryCache
focal_class.var_name: peCache
focal_class.declarator: existingNames
focal_class.modifier: private
focal_class.original_string: private Set<String> existingNames;
focal_class.type: Set<String>
focal_class.var_name: existingNames
focal_class.declarator: usePathEntryMap
focal_class.modifier: private
focal_class.original_string: private boolean usePathEntryMap;
focal_class.type: boolean
focal_class.var_name: usePathEntryMap
focal_class.declarator: initialized = false
focal_class.modifier: private
focal_class.original_string: private boolean initialized = false;
focal_class.type: boolean
focal_class.var_name: initialized
focal_class.file: oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionCacheBuilder.java
focal_class.identifier: PermissionCacheBuilder
focal_class.class_method_signature: PermissionCacheBuilder.PermissionCacheBuilder(@NotNull PermissionStore store)
focal_class.full_signature:   PermissionCacheBuilder(@NotNull PermissionStore store)
focal_class.identifier: PermissionCacheBuilder
focal_class.parameters: (@NotNull PermissionStore store)
focal_class.signature:  PermissionCacheBuilder(@NotNull PermissionStore store)
focal_class.class_method_signature: PermissionCacheBuilder.init(@NotNull Set<String> principalNames, @NotNull CacheStrategy cacheStrategy)
focal_class.full_signature:  boolean init(@NotNull Set<String> principalNames, @NotNull CacheStrategy cacheStrategy)
focal_class.identifier: init
focal_class.parameters: (@NotNull Set<String> principalNames, @NotNull CacheStrategy cacheStrategy)
focal_class.return: boolean
focal_class.signature: boolean init(@NotNull Set<String> principalNames, @NotNull CacheStrategy cacheStrategy)
focal_class.class_method_signature: PermissionCacheBuilder.build()
focal_class.full_signature: @NotNull PermissionCache build()
focal_class.identifier: build
focal_class.modifiers: @NotNull
focal_class.parameters: ()
focal_class.return: PermissionCache
focal_class.signature: PermissionCache build()
focal_method.body: boolean init(@NotNull Set<String> principalNames, @NotNull CacheStrategy cacheStrategy) {
          existingNames = new HashSet<>();
          long cnt = 0;
          for (String name : principalNames) {
              NumEntries ne = store.getNumEntries(name, cacheStrategy.maxSize());
              long n = ne.size;
              /*
              if getNumEntries (n) returns a number bigger than 0, we
              remember this principal name int the 'existingNames' set
              */
              if (n > 0) {
                  existingNames.add(name);
                  if (cacheStrategy.loadFully(n, cnt)) {
                      peCache.getFullyLoadedEntries(store, name);
                  } else {
                      long expectedSize = (ne.isExact) ? n : Long.MAX_VALUE;
                      peCache.init(name, expectedSize);
                  }
              }
              /*
              Estimate the total number of access controlled paths (cnt) defined
              for the given set of principals in order to be able to determine if
              the pathEntryMap should be loaded upfront.
              Note however that cache.getNumEntries (n) may return Long.MAX_VALUE
              if the underlying implementation does not know the exact value, and
              the child node count is higher than maxSize (see OAK-2465).
              */
              if (cnt < Long.MAX_VALUE) {
                  if (Long.MAX_VALUE == n) {
                      cnt = Long.MAX_VALUE;
                  } else {
                      cnt = LongUtils.safeAdd(cnt, n);
                  }
              }
          }
  
          usePathEntryMap = cacheStrategy.usePathEntryMap(cnt);
          initialized = true;
          return existingNames.isEmpty();
      }
focal_method.class_method_signature: PermissionCacheBuilder.init(@NotNull Set<String> principalNames, @NotNull CacheStrategy cacheStrategy)
focal_method.full_signature:  boolean init(@NotNull Set<String> principalNames, @NotNull CacheStrategy cacheStrategy)
focal_method.identifier: init
focal_method.invocations: getNumEntries maxSize add loadFully getFullyLoadedEntries init safeAdd usePathEntryMap isEmpty
focal_method.parameters: (@NotNull Set<String> principalNames, @NotNull CacheStrategy cacheStrategy)
focal_method.return: boolean
focal_method.signature: boolean init(@NotNull Set<String> principalNames, @NotNull CacheStrategy cacheStrategy)