PentahoCompiledPermissionsImpl extends AbstractCompiledPermissions implements AccessControlListener { @Override public Result getResult( Path absPath ) throws RepositoryException { Result result; synchronized ( monitor ) { if ( absPath == null ) { result = buildRepositoryResult(); } else { result = buildResult( absPath ); } } return result; } PentahoCompiledPermissionsImpl( Set<Principal> principals, SessionImpl session, EntryCollector entryCollector,
                                  AccessControlUtils util, boolean listenToEvents ); @Override void close(); boolean canRead( Path path, ItemId itemId ); void acModified( AccessControlModifications modifications ); @Override Result getResult( Path absPath );  }
@Test public void getResult() throws Exception { AbstractCompiledPermissions.Result res1 = mock( AbstractCompiledPermissions.Result.class ); AbstractCompiledPermissions.Result res2 = mock( AbstractCompiledPermissions.Result.class ); PentahoCompiledPermissionsImpl cp = new PentahoCompiledPermissionsImpl( Collections.emptySet(), mock( SessionImpl.class ), mock( EntryCollector.class ), mock( AccessControlUtils.class ), false ) { int numBuildResultCalls = 0; @Override protected Result buildResult( Path absPath ) throws RepositoryException { return ( ++numBuildResultCalls == 1 ) ? res1 : res2; } int numBuildRepoResultCalls = 0; @Override protected Result buildRepositoryResult() throws RepositoryException { return ( ++numBuildRepoResultCalls == 1 ) ? res1 : res2; } }; AbstractCompiledPermissions.Result result1 = cp.getResult( mock( Path.class ) ); AbstractCompiledPermissions.Result result2 = cp.getResult( mock( Path.class ) ); assertSame( result1, res1 ); assertSame( result2, res2 ); result1 = cp.getResult( null ); result2 = cp.getResult( null ); assertSame( result1, res1 ); assertSame( result2, res2 ); }