@Test public void testDoValidate_fail_group_contains_a_group_which_contains_a_group_which_contains_itself() { Config config = new Config(); config.memberNames = ImmutableSet.of("repository2"); assertNotNull(underTest.validateGroupDoesNotContainItself("repositoryUnderTest", config)); }
ConstraintViolation<?> validateGroupDoesNotContainItself(String repositoryName, Config config) { Set<Repository> checkedGroups = new HashSet<>(); for (String memberName : config.memberNames) { Repository repository = repositoryManager.get(memberName); if (repository.getName().equals(repositoryName) || (groupType.equals(repository.getType()) && containsGroup(repository, repositoryName, checkedGroups))) { return constraintViolationFactory.createViolation(CONFIG_KEY + ".memberNames", "Group '" + repository.getName() + "' has a member repository '" + repositoryName + "' and cannot be added to this list."); } } return null; }
GroupFacetImpl extends FacetSupport implements GroupFacet { ConstraintViolation<?> validateGroupDoesNotContainItself(String repositoryName, Config config) { Set<Repository> checkedGroups = new HashSet<>(); for (String memberName : config.memberNames) { Repository repository = repositoryManager.get(memberName); if (repository.getName().equals(repositoryName) || (groupType.equals(repository.getType()) && containsGroup(repository, repositoryName, checkedGroups))) { return constraintViolationFactory.createViolation(CONFIG_KEY + ".memberNames", "Group '" + repository.getName() + "' has a member repository '" + repositoryName + "' and cannot be added to this list."); } } return null; } }
GroupFacetImpl extends FacetSupport implements GroupFacet { ConstraintViolation<?> validateGroupDoesNotContainItself(String repositoryName, Config config) { Set<Repository> checkedGroups = new HashSet<>(); for (String memberName : config.memberNames) { Repository repository = repositoryManager.get(memberName); if (repository.getName().equals(repositoryName) || (groupType.equals(repository.getType()) && containsGroup(repository, repositoryName, checkedGroups))) { return constraintViolationFactory.createViolation(CONFIG_KEY + ".memberNames", "Group '" + repository.getName() + "' has a member repository '" + repositoryName + "' and cannot be added to this list."); } } return null; } @Inject  GroupFacetImpl(final RepositoryManager repositoryManager,
                        final ConstraintViolationFactory constraintViolationFactory,
                        @Named(GroupType.NAME) final Type groupType); }
GroupFacetImpl extends FacetSupport implements GroupFacet { ConstraintViolation<?> validateGroupDoesNotContainItself(String repositoryName, Config config) { Set<Repository> checkedGroups = new HashSet<>(); for (String memberName : config.memberNames) { Repository repository = repositoryManager.get(memberName); if (repository.getName().equals(repositoryName) || (groupType.equals(repository.getType()) && containsGroup(repository, repositoryName, checkedGroups))) { return constraintViolationFactory.createViolation(CONFIG_KEY + ".memberNames", "Group '" + repository.getName() + "' has a member repository '" + repositoryName + "' and cannot be added to this list."); } } return null; } @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 { ConstraintViolation<?> validateGroupDoesNotContainItself(String repositoryName, Config config) { Set<Repository> checkedGroups = new HashSet<>(); for (String memberName : config.memberNames) { Repository repository = repositoryManager.get(memberName); if (repository.getName().equals(repositoryName) || (groupType.equals(repository.getType()) && containsGroup(repository, repositoryName, checkedGroups))) { return constraintViolationFactory.createViolation(CONFIG_KEY + ".memberNames", "Group '" + repository.getName() + "' has a member repository '" + repositoryName + "' and cannot be added to this list."); } } return null; } @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; }