Rights { public static Rights fromACL(MailboxACL acl) { return acl.getEntries() .entrySet() .stream() .filter(entry -> isSupported(entry.getKey())) .map(Rights::toRightsBuilder) .reduce(builder(), Builder::combine) .build(); } @JsonCreator  Rights(Map<Username, List<Right>> rights); private  Rights(Multimap<Username, Right> rights); static Builder builder(); static Rights fromACL(MailboxACL acl); @JsonAnyGetter Map<Username, Collection<Right>> getRights(); Rights removeEntriesFor(Username username); MailboxACL toMailboxAcl(); Optional<Boolean> mayReadItems(Username username); Optional<Boolean> mayAddItems(Username username); Optional<Boolean> mayCreateChild(Username username); Optional<Boolean> mayRemoveItems(Username username); Optional<Boolean> mayRename(Username username); Optional<Boolean> mayDelete(Username username); @Override final boolean equals(Object o); @Override final int hashCode(); static final Rights EMPTY; }
@Test public void fromACLShouldFilterOutGroups() throws Exception { MailboxACL acl = new MailboxACL(ImmutableMap.of( EntryKey.createGroupEntryKey("group"), Rfc4314Rights.fromSerializedRfc4314Rights("aet"))); assertThat(Rights.fromACL(acl)) .isEqualTo(Rights.EMPTY); }
@Test public void fromACLShouldFilterNegatedUsers() throws Exception { MailboxACL acl = new MailboxACL(ImmutableMap.of( EntryKey.createUserEntryKey(USERNAME, NEGATIVE), Rfc4314Rights.fromSerializedRfc4314Rights("aet"))); assertThat(Rights.fromACL(acl)) .isEqualTo(Rights.EMPTY); }