RepositoryPermissionChecker { public List<Repository> userHasRepositoryAdminPermission( final Iterable<Repository> repositories, final String... actions) { Repository[] repos = Iterables.toArray(repositories, Repository.class); return userHasPermission(r -> new RepositoryAdminPermission(r, actions), repos); } @Inject  RepositoryPermissionChecker(final SecurityHelper securityHelper, final SelectorManager selectorManager); boolean userCanBrowseRepository(final Repository repository); boolean userCanDeleteInRepository(final Repository repository); List<Repository> userCanBrowseRepositories(final Repository... repositories); void ensureUserHasAnyPermissionOrAdminAccess(
      final Iterable<Permission> permissions,
      final String action,
      final Iterable<Repository> repositories); List<Repository> userCanBrowseRepositories(final Iterable<Repository> repositories); List<Repository> userHasRepositoryAdminPermission(
      final Iterable<Repository> repositories,
      final String... actions); void ensureUserCanAdmin(final String action, final Repository repository); void ensureUserCanAdmin(final String action, final String format, final String repositoryName);  }
@Test public void testUserHasRepositoryAdminPermission() { List<Repository> permittedRepositories = underTest.userHasRepositoryAdminPermission(Arrays.asList(repository, repository1, repository2), READ); assertThat(permittedRepositories, contains(repository)); verify(securityHelper).isPermitted(subject, createAdminPermissions(READ, RepositoryAdminPermission::new, repository, repository1, repository2)); }