ReadStatus { static ReadStatus create(PermissionEntry pe, long permission, boolean skipped) { if (skipped || permission == Permissions.READ_ACCESS_CONTROL || pe.restriction != RestrictionPattern.EMPTY) { return (pe.isAllow) ? ALLOW_THIS : DENY_THIS; } else { if (pe.privilegeBits.includes(READ_BITS)) { return (pe.isAllow) ? ALLOW_ALL : DENY_ALL; } else if (pe.privilegeBits.includes(READ_PROPERTIES_BITS)) { return (pe.isAllow) ? ALLOW_THIS_PROPERTIES : DENY_THIS_PROPERTIES; } else { return (pe.isAllow) ? ALLOW_THIS : DENY_THIS; } } } private  ReadStatus(int status, boolean isAllow);   }
@Test public void testSkippedAllowed() { ReadStatus rs = ReadStatus.create(grantAll, Permissions.ALL, true); assertAllowed(rs, false); assertSame(rs, ReadStatus.create(grantAll, Permissions.READ, true)); }
@Test public void testSkippedDenied() { ReadStatus rs = ReadStatus.create(denyAll, Permissions.ALL, true); assertDenied(rs); assertSame(rs, ReadStatus.create(denyAll, Permissions.READ, true)); }
@Test public void testReadAcTargetPermissionAllow() { ReadStatus rs = ReadStatus.create(grantAll, Permissions.READ_ACCESS_CONTROL, false); assertAllowed(rs, false); assertSame(rs, ReadStatus.create(grantAll, Permissions.READ_ACCESS_CONTROL, true)); }
@Test public void testReadAcTargetPermissionDeny() { ReadStatus rs = ReadStatus.create(denyAll, Permissions.READ_ACCESS_CONTROL, false); assertDenied(rs); assertSame(rs, ReadStatus.create(denyAll, Permissions.READ_ACCESS_CONTROL, true)); }
@Test public void testNonEmptyPatternAllow() { PermissionEntry entry = createPermissionEntry(true, mock(RestrictionPattern.class), JCR_ALL); ReadStatus rs = ReadStatus.create(entry, Permissions.ALL, false); assertAllowed(rs, false); }
@Test public void testNonEmptyPatternDeny() { PermissionEntry entry = createPermissionEntry(false, mock(RestrictionPattern.class), JCR_ALL); ReadStatus rs = ReadStatus.create(entry, Permissions.ALL, false); assertDenied(rs); }
@Test public void testOnlyReadNodesGranted() { PermissionEntry entry = createPermissionEntry(true, REP_READ_NODES); ReadStatus rs = ReadStatus.create(entry, Permissions.ALL, false); assertAllowed(rs, false); }
@Test public void testOnlyReadNodesDenied() { PermissionEntry entry = createPermissionEntry(false, REP_READ_NODES); ReadStatus rs = ReadStatus.create(entry, Permissions.ALL, false); assertDenied(rs); assertSame(DENY_THIS, rs); }
@Test public void testOnlyReadPropertiesGranted() { PermissionEntry entry = createPermissionEntry(true, REP_READ_PROPERTIES); ReadStatus rs = ReadStatus.create(entry, Permissions.ALL, false); assertAllowed(rs, true); }
@Test public void testOnlyReadPropertiesDenied() { PermissionEntry entry = createPermissionEntry(false, REP_READ_PROPERTIES); ReadStatus rs = ReadStatus.create(entry, Permissions.ALL, false); assertDenied(rs); }
@Test public void testReadGranted() { PermissionEntry entry = createPermissionEntry(true, JCR_READ); ReadStatus rs = ReadStatus.create(entry, Permissions.ALL, false); assertAllowed(rs, true); assertSame(ALLOW_ALL, rs); }
@Test public void testReadDenied() { PermissionEntry entry = createPermissionEntry(false, JCR_READ); ReadStatus rs = ReadStatus.create(entry, Permissions.ALL, false); assertDenied(rs); assertSame(DENY_ALL, rs); }