class BrowseServiceImpl extends ComponentSupport implements BrowseService {

  @VisibleForTesting
  Map<String, List<String>> getRepoToContainedGroupMap(List<Repository> repositories) {
    Map<String, List<String>> repoToContainedGroupMap = new HashMap<>();
    for (Repository repository : repositories) {
      List<String> groupNames = new ArrayList<>();
      groupNames.add(repository.getName());
      groupNames.addAll(repositories.stream().filter(groupRepository -> {
        Optional<GroupFacet> groupFacet = groupRepository.optionalFacet(GroupFacet.class);
        return groupFacet.isPresent() && groupFacet.get().leafMembers().stream()
            .anyMatch(leafMember -> repository.getName().equals(leafMember.getName()));
      }).map(groupRepository -> groupRepository.getName()).collect(Collectors.toSet()));
      repoToContainedGroupMap.put(repository.getName(), groupNames);
    }
    return repoToContainedGroupMap;
  }

  @Inject public  BrowseServiceImpl(@Named(GroupType.NAME) final Type groupType,
                           final ComponentEntityAdapter componentEntityAdapter,
                           final VariableResolverAdapterManager variableResolverAdapterManager,
                           final ContentPermissionChecker contentPermissionChecker,
                           final AssetEntityAdapter assetEntityAdapter,
                           final BrowseAssetIterableFactory browseAssetIterableFactory,
                           final BrowseAssetsSqlBuilder browseAssetsSqlBuilder,
                           final BrowseComponentsSqlBuilder browseComponentsSqlBuilder,
                           final BucketStore bucketStore,
                           final RepositoryManager repositoryManager);

}