### Question:
RepositoryAclServiceImpl implements AclService { @SuppressWarnings({ "rawtypes", "unchecked" }) public Acl readAclById(ObjectIdentity object) throws NotFoundException { InternalURI uri = getInternalUriFor(object); if(!uri.getProtocol().startsWith("repo")){ return _old_readAclById(object); } Acl result = new JasperServerAclImpl(uri,null); List<AccessControlEntry> aces = new ArrayList<AccessControlEntry>(); if (isImportRunning()) { Sid sid = sidRetrievalStrategy.getSid(SecurityContextHolder.getContext().getAuthentication().getPrincipal()); aces.add(new AccessControlEntryImpl(null,result,sid,JasperServerPermission.ADMINISTRATION,true,false,false)); return new JasperServerAclImpl(uri,aces,true); } Object[] existingAcl = new Object[2]; List objectPermisions = permissionService.getObjectPermissionsForObject(null, uri, existingAcl); result = unwindObjectPermissions(uri, (Collection<ObjectPermission>)objectPermisions, existingAcl); if(result == null){ result = new JasperServerAclImpl(uri, aces); } validateAcl(result); return result; }  @Override List<ObjectIdentity> findChildren(ObjectIdentity parentIdentity); @SuppressWarnings({ "rawtypes", "unchecked" }) Acl readAclById(ObjectIdentity object); @Override Acl readAclById(ObjectIdentity object, List<Sid> incomeSids); @Override Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects); @Override Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects, List<Sid> sids); void setPermissionService(ObjectPermissionService permissionService); void setSidRetrievalStrategy(JasperServerSidRetrievalStrategyImpl sidRetrievalStrategy); void setAclLookupStrategy(AclService aclLookupStrategy); AclService getAclLookupStrategy(); static final String RECIPIENT_USED_FOR_INHERITANCE_MARKER; }### Answer:
@Test public void readRootACLTest() throws Exception { assertEquals(decodeAcl(rootAcl), decodeAcl(service.readAclById(rootFolder))); }
@Test public void readHierarchyAcl() throws Exception { assertEquals(decodeAcl(orgAcl), decodeAcl(service.readAclById(orgFolder))); assertEquals(decodeAcl(org1Acl), decodeAcl(service.readAclById(org1Folder))); }
@Test public void readHierarchyAclWithIncorrectUri() throws Exception { final PrintStream originalErr = System.err; final ByteArrayOutputStream errContent = new ByteArrayOutputStream(); System.setErr(new PrintStream(errContent)); try { assertEquals(decodeAcl(org1Acl), decodeAcl(service.readAclById(org1FolderIncorectUri))); assertTrue(errContent.toString().startsWith("java.lang.Exception: Stack trace")); } finally { System.setErr(originalErr); } }
@Test public void readHierarchyAclWithoutProtocolInUri() throws Exception { assertEquals(decodeAcl(org1Acl), decodeAcl(service.readAclById(org1FolderWithoutProtocol))); }
@Test(expected = NotFoundException.class) public void readHierarchyAclWithMissingCacheEntry() throws Exception { assertEquals(decodeAcl(org2Acl), decodeAcl(service.readAclById(org2Folder))); }