@Test public void testAssignedRepositories_multipleRulesAndRepositories() throws Exception { Repository repository2 = mock(Repository.class); Repository repository3 = mock(Repository.class); when(repository2.getName()).thenReturn("test-repo-2"); when(repository3.getName()).thenReturn("test-repo-3"); when(repositoryManager.browse()).thenReturn(ImmutableList.of(repository, repository2, repository3)); configureRepositoryMock(repository, "rule-1"); configureRepositoryMock(repository2, "rule-2"); configureRepositoryMock(repository3, "rule-2"); Map<EntityId, List<Repository>> assignedRepositoryMap = underTest.calculateAssignedRepositories(); assertEquals(2, assignedRepositoryMap.size()); assertEquals(ImmutableList.of(repository), assignedRepositoryMap.get(new DetachedEntityId("rule-1"))); assertEquals(ImmutableList.of(repository2, repository3), assignedRepositoryMap.get(new DetachedEntityId("rule-2"))); }
@Override public Map<EntityId, List<Repository>> calculateAssignedRepositories() { return StreamSupport.stream(repositoryManager.browse().spliterator(), false) .filter(repository -> routingRuleCache.getRoutingRuleId(repository) != null) .collect(groupingBy(routingRuleCache::getRoutingRuleId, toList())); }
RoutingRuleHelperImpl implements RoutingRuleHelper { @Override public Map<EntityId, List<Repository>> calculateAssignedRepositories() { return StreamSupport.stream(repositoryManager.browse().spliterator(), false) .filter(repository -> routingRuleCache.getRoutingRuleId(repository) != null) .collect(groupingBy(routingRuleCache::getRoutingRuleId, toList())); } }
RoutingRuleHelperImpl implements RoutingRuleHelper { @Override public Map<EntityId, List<Repository>> calculateAssignedRepositories() { return StreamSupport.stream(repositoryManager.browse().spliterator(), false) .filter(repository -> routingRuleCache.getRoutingRuleId(repository) != null) .collect(groupingBy(routingRuleCache::getRoutingRuleId, toList())); } @Inject  RoutingRuleHelperImpl(
      final RoutingRuleCache routingRuleCache,
      final RepositoryManager repositoryManager,
      final RepositoryPermissionChecker repositoryPermissionChecker); }
RoutingRuleHelperImpl implements RoutingRuleHelper { @Override public Map<EntityId, List<Repository>> calculateAssignedRepositories() { return StreamSupport.stream(repositoryManager.browse().spliterator(), false) .filter(repository -> routingRuleCache.getRoutingRuleId(repository) != null) .collect(groupingBy(routingRuleCache::getRoutingRuleId, toList())); } @Inject  RoutingRuleHelperImpl(
      final RoutingRuleCache routingRuleCache,
      final RepositoryManager repositoryManager,
      final RepositoryPermissionChecker repositoryPermissionChecker); @Override boolean isAllowed(final Repository repository, final String path); boolean isAllowed(final RoutingRule routingRule, final String path); @Override boolean isAllowed(final RoutingMode mode, final List<String> matchers, final String path); @Override Map<EntityId, List<Repository>> calculateAssignedRepositories(); @Override void ensureUserHasPermissionToRead(); }
RoutingRuleHelperImpl implements RoutingRuleHelper { @Override public Map<EntityId, List<Repository>> calculateAssignedRepositories() { return StreamSupport.stream(repositoryManager.browse().spliterator(), false) .filter(repository -> routingRuleCache.getRoutingRuleId(repository) != null) .collect(groupingBy(routingRuleCache::getRoutingRuleId, toList())); } @Inject  RoutingRuleHelperImpl(
      final RoutingRuleCache routingRuleCache,
      final RepositoryManager repositoryManager,
      final RepositoryPermissionChecker repositoryPermissionChecker); @Override boolean isAllowed(final Repository repository, final String path); boolean isAllowed(final RoutingRule routingRule, final String path); @Override boolean isAllowed(final RoutingMode mode, final List<String> matchers, final String path); @Override Map<EntityId, List<Repository>> calculateAssignedRepositories(); @Override void ensureUserHasPermissionToRead();  }