ValidateAccessRightsImpl implements ValidateAccessRights { @Override public void validate(boolean simulate) { try { validators.sort(new AccessRightValidatorComparator()); ValidateAccessRightsTable table = new ValidateAccessRightsTable(); for (AccessRightValidator validator : validators) { table.add(validator, simulate); } StringBuilder output = new StringBuilder(); output.append(String.join("\n", warnings)); output.append("\n"); output.append(table.getText()); output.append("\n\n"); scriptContext.getPrintStream().append(output.toString()); if (table.hasErrors() && failOnError) { throw new IllegalStateException("Rights check failed"); } } finally { context.cleanup(); } } ValidateAccessRightsImpl(ResourceResolverFactory resourceResolverFactory, ResourceResolver resolver,
            Replicator replicator, ScriptContext scriptContext); @Override ValidateAccessRights forPaths(String... paths); @Override ValidateAccessRights forGroups(String... groups); @Override ValidateAccessRights canRead(); @Override ValidateAccessRights cannotRead(); @Override ValidateAccessRights canModify(); @Override ValidateAccessRights cannotModify(); @Override ValidateAccessRights canCreate(); @Override ValidateAccessRights cannotCreate(); @Override ValidateAccessRights canDelete(); @Override ValidateAccessRights cannotDelete(); @Override ValidateAccessRights canReplicate(); @Override ValidateAccessRights cannotReplicate(); @Override ValidateAccessRights canReadAcl(); @Override ValidateAccessRights cannotReadAcl(); @Override ValidateAccessRights canWriteAcl(); @Override ValidateAccessRights cannotWriteAcl(); @Override ValidateAccessRights canReadPage(); @Override ValidateAccessRights cannotReadPage(); @Override ValidateAccessRights canCreatePage(String templatePath); @Override ValidateAccessRights cannotCreatePage(String templatePath); @Override ValidateAccessRights canModifyPage(); @Override ValidateAccessRights cannotModifyPage(); @Override ValidateAccessRights canDeletePage(); @Override ValidateAccessRights cannotDeletePage(); @Override ValidateAccessRights canReplicatePage(ReplicationActionType type); @Override ValidateAccessRights canReplicatePage(); @Override ValidateAccessRights cannotReplicatePage(); @Override ValidateAccessRights cannotReplicatePage(ReplicationActionType type); @Override void validate(boolean simulate); @Override void validate(); @Override void simulate(); @Override ValidateAccessRights failOnError(); @Override ValidateAccessRights failOnError(boolean fail);  }
@Test public void validate() { validateRights.forPaths(new String[] {TESTPATH}); validateRights.forGroups(new String[] {TESTGROUP}); assertNotNull(validateRights.cannotRead()); validateRights.validate(); verify(stream).append("\n┌─────────┬─────┬───────────────┐\n" + "│Group │Path │Rights │\n" + "├─────────┼─────┼───────────────┤\n" + "│testgroup│/test│OK: Cannot Read│\n" + "└─────────┴─────┴───────────────┘\n\n"); }