public Builder rights(Right... rights) throws UnsupportedRightException { this.rights = Optional.ofNullable(this.rights) .orElse(new Rfc4314Rights()) .union(new Rfc4314Rights(rights)); return this; }
/** * What needs to be done for both global ACL and the given mailboxe's ACL. * * @param requestUser * @param groupMembershipResolver * @param entries * @param resourceOwner * @param resourceOwnerIsGroup * @param positiveNegativePair * @throws UnsupportedRightException */ private void resolveRights(EntryKey queryKey, GroupMembershipResolver groupMembershipResolver, Map<EntryKey, Rfc4314Rights> entries, String resourceOwner, boolean resourceOwnerIsGroup, Rfc4314Rights[] positiveNegativePair) throws UnsupportedRightException { if (entries != null) { for (Entry<EntryKey, Rfc4314Rights> entry : entries.entrySet()) { final EntryKey key = entry.getKey(); if (applies(key, queryKey, groupMembershipResolver, resourceOwner, resourceOwnerIsGroup)) { if (key.isNegative()) { positiveNegativePair[NEGATIVE_INDEX] = positiveNegativePair[NEGATIVE_INDEX].union(entry.getValue()); } else { positiveNegativePair[POSITIVE_INDEX] = positiveNegativePair[POSITIVE_INDEX].union(entry.getValue()); } } } } }
@Test public void unionShouldReturnOriginWhenAppliedWithEmpty() throws UnsupportedRightException { assertThat(lprs.union(none)).isEqualTo(lprs); }
@Test public void unionShouldThrowWhenAppliedWithNull() throws UnsupportedRightException { assertThatThrownBy(() -> lprs.union(null)).isInstanceOf(NullPointerException.class); }