private static Rfc4314Rights[] toListRightsArray(Rfc4314Rights implicitRights) throws UnsupportedRightException { List<Rfc4314Rights> result = new ArrayList<>(); result.add(implicitRights); for (Right right : MailboxACL.FULL_RIGHTS.list()) { if (!implicitRights.contains(right)) { result.add(new Rfc4314Rights(right)); } } return result.toArray(new Rfc4314Rights[result.size()]); }
private static List<Right> fromACL(MailboxACL.Rfc4314Rights rights) { return rights.list() .stream() .flatMap(right -> OptionalUtils.toStream(Right.forRight(right))) .collect(Guavate.toImmutableList()); }
private String rightsAsString(String rights) throws UnsupportedRightException { return MailboxACL.Rfc4314Rights .fromSerializedRfc4314Rights(rights) .list() .stream() .map(MailboxACL.Right::asCharacter) .map(String::valueOf) .map(this::surroundWithDoubleQuotes) .collect(Collectors.joining(", ", "[ ", " ]")); }
@Test public void fullRightsShouldContainsAllRights() { assertThat(full.list()).containsOnly( Administer, PerformExpunge, Insert, CreateMailbox, Lookup, Post, Read, WriteSeenFlag, DeleteMessages, Write, DeleteMailbox); }
@Test public void getValueShouldReturnEmptyWhenNone() throws UnsupportedRightException { assertThat(Rfc4314Rights.fromSerializedRfc4314Rights("").list()).isEmpty(); }
@Test public void getValueShouldReturnSigmaWhenLprs() throws UnsupportedRightException { assertThat(lprs.list()).containsExactly(Lookup, Post, Read, WriteSeenFlag); }
@Test public void noneRightsShouldContainsNoRights() { assertThat(none.list()).isEmpty(); }
@Test public void newInstanceShouldHaveNoRightsWhenEmptyString() throws UnsupportedRightException { Rfc4314Rights rights = Rfc4314Rights.fromSerializedRfc4314Rights(""); assertThat(rights.list()).isEmpty(); }
@Test public void rightsShouldContainsSpecificRightsWhenTWX() { assertThat(twx.list()).containsOnly( DeleteMessages, Write, DeleteMailbox); }
@Test public void rightsShouldContainsSpecificRightsWhenLPRS() { assertThat(lprs.list()).containsOnly( Lookup, Post, Read, WriteSeenFlag); }
@Test public void rightsShouldContainsSpecificRightsWhenAEIK() { assertThat(aeik.list()).containsOnly( Administer, PerformExpunge, Insert, CreateMailbox); }
@Test public void getValueShouldReturnSigmaWhenAeik() throws UnsupportedRightException { assertThat(aeik.list()).containsExactly(Administer, PerformExpunge, Insert, CreateMailbox); }
@Test public void getValueShouldReturnSigmaWhenTwx() throws UnsupportedRightException { assertThat(twx.list()).containsExactly(DeleteMessages, Write, DeleteMailbox); }