PermissionEntryProviderImpl implements PermissionEntryProvider { @Override @NotNull public Iterator<PermissionEntry> getEntryIterator(@NotNull EntryPredicate predicate) { init(); if (noExistingNames) { return Collections.emptyIterator(); } else { return new EntryIterator(predicate); } } PermissionEntryProviderImpl(@NotNull PermissionStore store, @NotNull Set<String> principalNames, @NotNull ConfigurationParameters options); @Override void flush(); @Override @NotNull Iterator<PermissionEntry> getEntryIterator(@NotNull EntryPredicate predicate); @Override @NotNull Collection<PermissionEntry> getEntries(@NotNull Tree accessControlledTree);  }
@Test public void testInitLongOverflow() throws Exception { MockPermissionStore store = new MockPermissionStore(); Set<String> principalNames = ImmutableSet.of(GROUP_LONG_MAX); PermissionEntryProviderImpl provider = new PermissionEntryProviderImpl(store, principalNames, ConfigurationParameters.EMPTY); assertFalse(getBooleanField(provider, "noExistingNames")); assertNotSame(Collections.emptyIterator(), provider.getEntryIterator(EntryPredicate.create())); }
@Test public void testInitLongOverflow2() throws Exception { MockPermissionStore store = new MockPermissionStore(); Set<String> principalNames = ImmutableSet.of(GROUP_LONG_MAX_MINUS_10, GROUP_50); PermissionEntryProviderImpl provider = new PermissionEntryProviderImpl(store, principalNames, ConfigurationParameters.EMPTY); assertFalse(getBooleanField(provider, "noExistingNames")); assertNotSame(Collections.emptyIterator(), provider.getEntryIterator(EntryPredicate.create())); }
@Test public void testNoExistingName() throws Exception { MockPermissionStore store = new MockPermissionStore(); Set<String> principalNames = Sets.newHashSet("noEntries", "noEntries2", "noEntries3"); PermissionEntryProviderImpl provider = new PermissionEntryProviderImpl(store, principalNames, ConfigurationParameters.EMPTY); assertFalse(getBooleanField(provider, "noExistingNames")); provider.getEntryIterator(EntryPredicate.create()); assertTrue(getBooleanField(provider, "noExistingNames")); }