@Test public void testLeafMembers() throws Exception { Repository hosted1 = hostedRepository("hosted1"); Repository hosted2 = hostedRepository("hosted2"); Repository group1 = groupRepository("group1", hosted1); Config config = new Config(); config.memberNames = ImmutableSet.of(hosted1.getName(), hosted2.getName(), group1.getName()); Configuration configuration = mock(Configuration.class); when(configuration.attributes(CONFIG_KEY)).thenReturn(new NestedAttributesMap( "dummy", ImmutableMap.of("memberNames", config.memberNames) )); when(configurationFacet.readSection(configuration, CONFIG_KEY, Config.class)).thenReturn(config); underTest.doConfigure(configuration); assertThat(underTest.leafMembers(), contains(hosted1, hosted2)); }
@Override public List<Repository> leafMembers() { Set<Repository> leafMembers = new LinkedHashSet<>(); for (Repository repository : members()) { if (groupType.equals(repository.getType())) { leafMembers.addAll(repository.facet(GroupFacet.class).leafMembers()); } else { leafMembers.add(repository); } } return new ArrayList<>(leafMembers); }
GroupFacetImpl extends FacetSupport implements GroupFacet { @Override public List<Repository> leafMembers() { Set<Repository> leafMembers = new LinkedHashSet<>(); for (Repository repository : members()) { if (groupType.equals(repository.getType())) { leafMembers.addAll(repository.facet(GroupFacet.class).leafMembers()); } else { leafMembers.add(repository); } } return new ArrayList<>(leafMembers); } }
GroupFacetImpl extends FacetSupport implements GroupFacet { @Override public List<Repository> leafMembers() { Set<Repository> leafMembers = new LinkedHashSet<>(); for (Repository repository : members()) { if (groupType.equals(repository.getType())) { leafMembers.addAll(repository.facet(GroupFacet.class).leafMembers()); } else { leafMembers.add(repository); } } return new ArrayList<>(leafMembers); } @Inject  GroupFacetImpl(final RepositoryManager repositoryManager,
                        final ConstraintViolationFactory constraintViolationFactory,
                        @Named(GroupType.NAME) final Type groupType); }
GroupFacetImpl extends FacetSupport implements GroupFacet { @Override public List<Repository> leafMembers() { Set<Repository> leafMembers = new LinkedHashSet<>(); for (Repository repository : members()) { if (groupType.equals(repository.getType())) { leafMembers.addAll(repository.facet(GroupFacet.class).leafMembers()); } else { leafMembers.add(repository); } } return new ArrayList<>(leafMembers); } @Inject  GroupFacetImpl(final RepositoryManager repositoryManager,
                        final ConstraintViolationFactory constraintViolationFactory,
                        @Named(GroupType.NAME) final Type groupType); @Override @Guarded(by = STARTED) boolean member(final String repositoryName); @Override @Guarded(by = STARTED) boolean member(final Repository repository); @Override @Guarded(by = STARTED) List<Repository> members(); @Override List<Repository> leafMembers(); @Override List<Repository> allMembers(); @Override void invalidateGroupCaches(); @Override boolean isStale(@Nullable final Content content); @Override void maintainCacheInfo(final AttributesMap attributesMap); }
GroupFacetImpl extends FacetSupport implements GroupFacet { @Override public List<Repository> leafMembers() { Set<Repository> leafMembers = new LinkedHashSet<>(); for (Repository repository : members()) { if (groupType.equals(repository.getType())) { leafMembers.addAll(repository.facet(GroupFacet.class).leafMembers()); } else { leafMembers.add(repository); } } return new ArrayList<>(leafMembers); } @Inject  GroupFacetImpl(final RepositoryManager repositoryManager,
                        final ConstraintViolationFactory constraintViolationFactory,
                        @Named(GroupType.NAME) final Type groupType); @Override @Guarded(by = STARTED) boolean member(final String repositoryName); @Override @Guarded(by = STARTED) boolean member(final Repository repository); @Override @Guarded(by = STARTED) List<Repository> members(); @Override List<Repository> leafMembers(); @Override List<Repository> allMembers(); @Override void invalidateGroupCaches(); @Override boolean isStale(@Nullable final Content content); @Override void maintainCacheInfo(final AttributesMap attributesMap); static final String CONFIG_KEY; }