GrantRevokeIndex { boolean hasPermissions(final Collection<String> subjectIds, final Collection<String> permissions) { final Optional<Integer> grantWeight = grantMap.getMaxNonemptyWeightForAllPermissions(subjectIds, permissions); final Optional<Integer> revokeWeight = revokeMap.getMaxWeightForAllPermissions(subjectIds, permissions); return grantWeight.isPresent() && (!revokeWeight.isPresent() || revokeWeight.get() < grantWeight.get()); } GrantRevokeIndex();   GrantRevokeIndex(final PermissionSubjectsMap grantMap, final PermissionSubjectsMap revokeMap); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void subjectIdHasReadAndWritePermissions() { final boolean hasPermissions = underTest.hasPermissions(Collections.singleton(subjectId), permissions); assertThat(hasPermissions).isTrue(); }
@Test public void anotherSubjectIdHasNoWritePermission() { final boolean hasPermissions = underTest.hasPermissions(Collections.singleton(anotherSubjectId), Collections.singleton("WRITE")); assertThat(hasPermissions).isFalse(); }
@Test public void anotherSubjectIdHasNoReadPermissionBecauseRevokedWithSameWeight() { final boolean hasPermissions = underTest.hasPermissions(Collections.singleton(anotherSubjectId), Collections.singleton("READ")); assertThat(hasPermissions).isFalse(); }