@Test void findMailboxByPathShouldReturnMailboxWhenExistsInBothTables() { mailboxDAO.save(MAILBOX) .block(); mailboxPathDAO.save(MAILBOX_PATH, MAILBOX_ID) .block(); mailboxPathV2DAO.save(MAILBOX_PATH, MAILBOX_ID) .block(); Mailbox mailbox = testee.findMailboxByPath(MAILBOX_PATH).block(); assertThat(mailbox.generateAssociatedPath()).isEqualTo(MAILBOX_PATH); }
@Override public Mono<Mailbox> findMailboxByPath(MailboxPath path) { return mailboxPathV2DAO.retrieveId(path) .map(CassandraIdAndPath::getCassandraId) .flatMap(this::retrieveMailbox) .switchIfEmpty(fromPreviousTable(path)); }
CassandraMailboxMapper implements MailboxMapper { @Override public Mono<Mailbox> findMailboxByPath(MailboxPath path) { return mailboxPathV2DAO.retrieveId(path) .map(CassandraIdAndPath::getCassandraId) .flatMap(this::retrieveMailbox) .switchIfEmpty(fromPreviousTable(path)); } }
CassandraMailboxMapper implements MailboxMapper { @Override public Mono<Mailbox> findMailboxByPath(MailboxPath path) { return mailboxPathV2DAO.retrieveId(path) .map(CassandraIdAndPath::getCassandraId) .flatMap(this::retrieveMailbox) .switchIfEmpty(fromPreviousTable(path)); } @Inject  CassandraMailboxMapper(CassandraMailboxDAO mailboxDAO,
                                  CassandraMailboxPathDAOImpl mailboxPathDAO,
                                  CassandraMailboxPathV2DAO mailboxPathV2DAO,
                                  CassandraUserMailboxRightsDAO userMailboxRightsDAO,
                                  CassandraACLMapper aclMapper,
                                  CassandraSchemaVersionManager versionManager); }
CassandraMailboxMapper implements MailboxMapper { @Override public Mono<Mailbox> findMailboxByPath(MailboxPath path) { return mailboxPathV2DAO.retrieveId(path) .map(CassandraIdAndPath::getCassandraId) .flatMap(this::retrieveMailbox) .switchIfEmpty(fromPreviousTable(path)); } @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<Mailbox> findMailboxByPath(MailboxPath path) { return mailboxPathV2DAO.retrieveId(path) .map(CassandraIdAndPath::getCassandraId) .flatMap(this::retrieveMailbox) .switchIfEmpty(fromPreviousTable(path)); } @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);  }