@Test void hasChildrenShouldReturnChildWhenExistsInV1Table() { mailboxDAO.save(MAILBOX) .block(); mailboxPathDAO.save(MAILBOX_PATH, MAILBOX_ID) .block(); CassandraId childMailboxId = CassandraId.timeBased(); MailboxPath childMailboxPath = MailboxPath.forUser(USER, "name.child"); Mailbox childMailbox = new Mailbox(childMailboxPath, UID_VALIDITY, childMailboxId); mailboxDAO.save(childMailbox) .block(); mailboxPathDAO.save(childMailboxPath, childMailboxId) .block(); boolean hasChildren = testee.hasChildren(MAILBOX, '.').block(); assertThat(hasChildren).isTrue(); }
@Override public Mono<Boolean> hasChildren(Mailbox mailbox, char delimiter) { return Flux.merge( mailboxPathDAO.listUserMailboxes(mailbox.getNamespace(), mailbox.getUser()), mailboxPathV2DAO.listUserMailboxes(mailbox.getNamespace(), mailbox.getUser())) .filter(idAndPath -> isPathChildOfMailbox(idAndPath, mailbox, delimiter)) .hasElements(); }
CassandraMailboxMapper implements MailboxMapper { @Override public Mono<Boolean> hasChildren(Mailbox mailbox, char delimiter) { return Flux.merge( mailboxPathDAO.listUserMailboxes(mailbox.getNamespace(), mailbox.getUser()), mailboxPathV2DAO.listUserMailboxes(mailbox.getNamespace(), mailbox.getUser())) .filter(idAndPath -> isPathChildOfMailbox(idAndPath, mailbox, delimiter)) .hasElements(); } }
CassandraMailboxMapper implements MailboxMapper { @Override public Mono<Boolean> hasChildren(Mailbox mailbox, char delimiter) { return Flux.merge( mailboxPathDAO.listUserMailboxes(mailbox.getNamespace(), mailbox.getUser()), mailboxPathV2DAO.listUserMailboxes(mailbox.getNamespace(), mailbox.getUser())) .filter(idAndPath -> isPathChildOfMailbox(idAndPath, mailbox, delimiter)) .hasElements(); } @Inject  CassandraMailboxMapper(CassandraMailboxDAO mailboxDAO,
                                  CassandraMailboxPathDAOImpl mailboxPathDAO,
                                  CassandraMailboxPathV2DAO mailboxPathV2DAO,
                                  CassandraUserMailboxRightsDAO userMailboxRightsDAO,
                                  CassandraACLMapper aclMapper,
                                  CassandraSchemaVersionManager versionManager); }
CassandraMailboxMapper implements MailboxMapper { @Override public Mono<Boolean> hasChildren(Mailbox mailbox, char delimiter) { return Flux.merge( mailboxPathDAO.listUserMailboxes(mailbox.getNamespace(), mailbox.getUser()), mailboxPathV2DAO.listUserMailboxes(mailbox.getNamespace(), mailbox.getUser())) .filter(idAndPath -> isPathChildOfMailbox(idAndPath, mailbox, delimiter)) .hasElements(); } @Inject  CassandraMailboxMapper(CassandraMailboxDAO mailboxDAO,
                                  CassandraMailboxPathDAOImpl mailboxPathDAO,
                                  CassandraMailboxPathV2DAO mailboxPathV2DAO,
                                  CassandraUserMailboxRightsDAO userMailboxRightsDAO,
                                  CassandraACLMapper aclMapper,
                                  CassandraSchemaVersionManager versionManager); @Override Mono<Void> delete(Mailbox mailbox); @Override Mono<Mailbox> findMailboxByPath(MailboxPath path); @Override Mono<Boolean> pathExists(MailboxPath mailboxName); @Override Mono<Mailbox> findMailboxById(MailboxId id); @Override Flux<Mailbox> findMailboxWithPathLike(MailboxQuery.UserBound query); @Override Mono<Mailbox> create(MailboxPath mailboxPath, UidValidity uidValidity); @Override Mono<MailboxId> rename(Mailbox mailbox); @Override Mono<Boolean> hasChildren(Mailbox mailbox, char delimiter); @Override Flux<Mailbox> list(); @Override T execute(Transaction<T> transaction); @Override Mono<ACLDiff> updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand); @Override Mono<ACLDiff> setACL(Mailbox mailbox, MailboxACL mailboxACL); @Override void endRequest(); @Override Flux<Mailbox> findNonPersonalMailboxes(Username userName, Right right); }
CassandraMailboxMapper implements MailboxMapper { @Override public Mono<Boolean> hasChildren(Mailbox mailbox, char delimiter) { return Flux.merge( mailboxPathDAO.listUserMailboxes(mailbox.getNamespace(), mailbox.getUser()), mailboxPathV2DAO.listUserMailboxes(mailbox.getNamespace(), mailbox.getUser())) .filter(idAndPath -> isPathChildOfMailbox(idAndPath, mailbox, delimiter)) .hasElements(); } @Inject  CassandraMailboxMapper(CassandraMailboxDAO mailboxDAO,
                                  CassandraMailboxPathDAOImpl mailboxPathDAO,
                                  CassandraMailboxPathV2DAO mailboxPathV2DAO,
                                  CassandraUserMailboxRightsDAO userMailboxRightsDAO,
                                  CassandraACLMapper aclMapper,
                                  CassandraSchemaVersionManager versionManager); @Override Mono<Void> delete(Mailbox mailbox); @Override Mono<Mailbox> findMailboxByPath(MailboxPath path); @Override Mono<Boolean> pathExists(MailboxPath mailboxName); @Override Mono<Mailbox> findMailboxById(MailboxId id); @Override Flux<Mailbox> findMailboxWithPathLike(MailboxQuery.UserBound query); @Override Mono<Mailbox> create(MailboxPath mailboxPath, UidValidity uidValidity); @Override Mono<MailboxId> rename(Mailbox mailbox); @Override Mono<Boolean> hasChildren(Mailbox mailbox, char delimiter); @Override Flux<Mailbox> list(); @Override T execute(Transaction<T> transaction); @Override Mono<ACLDiff> updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand); @Override Mono<ACLDiff> setACL(Mailbox mailbox, MailboxACL mailboxACL); @Override void endRequest(); @Override Flux<Mailbox> findNonPersonalMailboxes(Username userName, Right right);  }