@Test void getMailboxByRoleShouldReturnMailboxByRole() throws Exception { when(mailboxManager.createSystemSession(MailboxFixture.ALICE)).thenReturn(mailboxSession); when(mailboxManager.getMailbox(eq(MailboxFixture.INBOX_ALICE), eq(mailboxSession))).thenReturn(inboxMessageManager); assertThat(Flux.from(systemMailboxProvider.getMailboxByRole(Role.INBOX, mailboxSession.getUser())).toStream()) .hasSize(1) .containsOnly(inboxMessageManager); }
@Override public Flux<MessageManager> getMailboxByRole(Role aRole, Username username) { MailboxSession session = mailboxManager.createSystemSession(username); MailboxPath mailboxPath = MailboxPath.forUser(username, aRole.getDefaultMailbox()); return Mono.fromCallable(() -> mailboxManager.getMailbox(mailboxPath, session)) .flux() .onErrorResume(MailboxNotFoundException.class, e -> searchMessageManagerByMailboxRole(aRole, username)); }
SystemMailboxesProviderImpl implements SystemMailboxesProvider { @Override public Flux<MessageManager> getMailboxByRole(Role aRole, Username username) { MailboxSession session = mailboxManager.createSystemSession(username); MailboxPath mailboxPath = MailboxPath.forUser(username, aRole.getDefaultMailbox()); return Mono.fromCallable(() -> mailboxManager.getMailbox(mailboxPath, session)) .flux() .onErrorResume(MailboxNotFoundException.class, e -> searchMessageManagerByMailboxRole(aRole, username)); } }
SystemMailboxesProviderImpl implements SystemMailboxesProvider { @Override public Flux<MessageManager> getMailboxByRole(Role aRole, Username username) { MailboxSession session = mailboxManager.createSystemSession(username); MailboxPath mailboxPath = MailboxPath.forUser(username, aRole.getDefaultMailbox()); return Mono.fromCallable(() -> mailboxManager.getMailbox(mailboxPath, session)) .flux() .onErrorResume(MailboxNotFoundException.class, e -> searchMessageManagerByMailboxRole(aRole, username)); } @Inject @VisibleForTesting  SystemMailboxesProviderImpl(MailboxManager mailboxManager); }
SystemMailboxesProviderImpl implements SystemMailboxesProvider { @Override public Flux<MessageManager> getMailboxByRole(Role aRole, Username username) { MailboxSession session = mailboxManager.createSystemSession(username); MailboxPath mailboxPath = MailboxPath.forUser(username, aRole.getDefaultMailbox()); return Mono.fromCallable(() -> mailboxManager.getMailbox(mailboxPath, session)) .flux() .onErrorResume(MailboxNotFoundException.class, e -> searchMessageManagerByMailboxRole(aRole, username)); } @Inject @VisibleForTesting  SystemMailboxesProviderImpl(MailboxManager mailboxManager); @Override Flux<MessageManager> getMailboxByRole(Role aRole, Username username); }
SystemMailboxesProviderImpl implements SystemMailboxesProvider { @Override public Flux<MessageManager> getMailboxByRole(Role aRole, Username username) { MailboxSession session = mailboxManager.createSystemSession(username); MailboxPath mailboxPath = MailboxPath.forUser(username, aRole.getDefaultMailbox()); return Mono.fromCallable(() -> mailboxManager.getMailbox(mailboxPath, session)) .flux() .onErrorResume(MailboxNotFoundException.class, e -> searchMessageManagerByMailboxRole(aRole, username)); } @Inject @VisibleForTesting  SystemMailboxesProviderImpl(MailboxManager mailboxManager); @Override Flux<MessageManager> getMailboxByRole(Role aRole, Username username);  }