@Test public void serializeShouldReturnStringWhenLprs() throws UnsupportedRightException { assertThat(lprs.serialize()).isEqualTo("lprs"); }
@Test public void serializeShouldReturnStringWhenAeiklprstwx() throws UnsupportedRightException { assertThat(full.serialize()).isEqualTo("aeiklprstwx"); }
@Test public void serializeShouldReturnStringWhenTwx() throws UnsupportedRightException { assertThat(twx.serialize()).isEqualTo("twx"); }
@Override protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException { final ListRightsResponse listRightsResponse = (ListRightsResponse) acceptableMessage; composer.untagged(); composer.commandName(ImapConstants.LISTRIGHTS_RESPONSE_NAME); String mailboxName = listRightsResponse.getMailboxName(); composer.mailbox(mailboxName == null ? "" : mailboxName); String identifier = listRightsResponse.getIdentifier(); composer.quote(identifier); Rfc4314Rights[] rights = listRightsResponse.getRights(); for (Rfc4314Rights entry : rights) { composer.quote(entry.serialize()); } composer.end(); }
@Override protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException { final ACLResponse aclResponse = (ACLResponse) acceptableMessage; final Map<EntryKey, Rfc4314Rights> entries = aclResponse.getAcl().getEntries(); composer.untagged(); composer.commandName(ImapConstants.ACL_RESPONSE_NAME); String mailboxName = aclResponse.getMailboxName(); composer.mailbox(mailboxName == null ? "" : mailboxName); if (entries != null) { for (Entry<EntryKey, Rfc4314Rights> entry : entries.entrySet()) { String identifier = entry.getKey().serialize(); composer.quote(identifier); String rights = entry.getValue().serialize(); composer.quote(rights == null ? "" : rights); } } composer.end(); }
@Test public void serializeShouldReturnStringWhenAeik() throws UnsupportedRightException { assertThat(aeik.serialize()).isEqualTo("aeik"); }
public String toString() { return serialize(); }
private CompletableFuture<Stream<Void>> addAll(CassandraId cassandraId, Stream<MailboxACL.Entry> addedEntries) { return FluentFutureStream.of(addedEntries .map(entry -> cassandraAsyncExecutor.executeVoid( insert.bind() .setString(USER_NAME, entry.getKey().getName()) .setUUID(MAILBOX_ID, cassandraId.asUuid()) .setString(RIGHTS, entry.getValue().serialize())))) .completableFuture(); }
@Test public void serializeShouldReturnEmptyStringWhenEmpty() throws UnsupportedRightException { assertThat(none.serialize()).isEmpty(); }
@Override protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException { final MyRightsResponse aclResponse = (MyRightsResponse) acceptableMessage; final Rfc4314Rights myRights = aclResponse.getMyRights(); composer.untagged(); composer.commandName(ImapConstants.MYRIGHTS_RESPONSE_NAME); String mailboxName = aclResponse.getMailboxName(); composer.mailbox(mailboxName == null ? "" : mailboxName); composer.quote(myRights == null ? "" : myRights.serialize()); composer.end(); }
@Test public void testExceptACLFull() throws UnsupportedRightException { Map<EntryKey, Rfc4314Rights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); expectedEntries.remove(EntryKey.deserialize(USER_1)); MailboxACL toRemove = new MailboxACL(new Entry(USER_1, MailboxACL.FULL_RIGHTS.serialize())); MailboxACL result = u1u2g1g2ACL.except(toRemove); Map<EntryKey, Rfc4314Rights> foundEntries = result.getEntries(); assertThat(foundEntries).isEqualTo(expectedEntries); }