### Question:
DefaultAclManager implements AclManager { protected static String printAcl( final Acl acl ) { final Map< String, List< Principal > > permissionPrincipals = new TreeMap<>(); final Enumeration< AclEntry > entries = acl.aclEntries(); while( entries.hasMoreElements() ) { final AclEntry entry = entries.nextElement(); final Principal principal = entry.getPrincipal(); final Enumeration< Permission > permissions = entry.permissions(); while( permissions.hasMoreElements() ) { final Permission permission = permissions.nextElement(); List< Principal > principals = permissionPrincipals.get( permission.getActions() ); if (principals == null) { principals = new ArrayList<>(); final String action = permission.getActions(); if( action.indexOf(',') != -1 ) { throw new IllegalStateException("AclEntry permission cannot have multiple targets."); } permissionPrincipals.put( action, principals ); } principals.add( principal ); } } final StringBuilder s = new StringBuilder(); for( final Map.Entry< String, List< Principal > > entry : permissionPrincipals.entrySet() ) { final String action = entry.getKey(); final List< Principal > principals = entry.getValue(); principals.sort( new PrincipalComparator() ); s.append( "[{ALLOW " ).append( action ).append( " " ); for( int i = 0; i < principals.size(); i++ ) { final Principal principal = principals.get( i ); s.append( principal.getName() ); if( i < ( principals.size() - 1 ) ) { s.append( "," ); } } s.append( "}]\n" ); } return s.toString(); }  @Override void initialize( final Engine engine, final Properties props ); @Override Acl parseAcl( final Page page, final String ruleLine ); @Override Acl getPermissions( final Page page ); @Override void setPermissions( final Page page, final Acl acl ); static final Pattern ACL_PATTERN; }### Answer:
@Test public void testPrintAcl() { final Page page = m_engine.getManager( PageManager.class ).getPage( "TestAclPage" ); Acl acl = m_engine.getManager( AclManager.class ).getPermissions( page ); final String aclString = DefaultAclManager.printAcl( acl ); Assertions.assertEquals( "[{ALLOW edit Charlie,Herman}]\n", aclString ); acl = Wiki.acls().acl(); AclEntry entry = Wiki.acls().entry(); entry.setPrincipal( new WikiPrincipal( "Charlie" ) ); entry.addPermission( PermissionFactory.getPagePermission( "Main:Foo", "view" ) ); entry.addPermission( PermissionFactory.getPagePermission( "Main:Foo", "edit" ) ); acl.addEntry( entry ); entry = Wiki.acls().entry(); entry.setPrincipal( new WikiPrincipal( "Devin" ) ); entry.addPermission( PermissionFactory.getPagePermission( "Main:Foo", "edit" ) ); entry.addPermission( PermissionFactory.getPagePermission( "Main:Foo", "delete" ) ); acl.addEntry( entry ); final String expectedValue = "[{ALLOW delete Devin}]\n[{ALLOW edit Charlie,Devin}]\n[{ALLOW view Charlie}]\n"; Assertions.assertEquals( expectedValue, DefaultAclManager.printAcl( acl ) ); }