You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2021/05/18 05:04:54 UTC

[james-project] 04/07: [REFACTORING] SystemMailboxesProviderImpl::getMailboxByRole should be reactive

This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit f3c9dd12d957c5aebe63958871b6108cff53e180
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat May 15 10:54:25 2021 +0700

    [REFACTORING] SystemMailboxesProviderImpl::getMailboxByRole should be reactive
---
 .../james/mailbox/store/SystemMailboxesProviderImpl.java       |  2 +-
 .../james/mailbox/store/SystemMailboxesProviderImplTest.java   | 10 ++++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/SystemMailboxesProviderImpl.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/SystemMailboxesProviderImpl.java
index 8b81a4b..e97e969 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/SystemMailboxesProviderImpl.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/SystemMailboxesProviderImpl.java
@@ -57,7 +57,7 @@ public class SystemMailboxesProviderImpl implements SystemMailboxesProvider {
         MailboxSession session = mailboxManager.createSystemSession(username);
         MailboxPath mailboxPath = MailboxPath.forUser(username, aRole.getDefaultMailbox());
 
-        return Mono.fromCallable(() -> mailboxManager.getMailbox(mailboxPath, session))
+        return Mono.from(mailboxManager.getMailboxReactive(mailboxPath, session))
             .flux()
             .onErrorResume(MailboxNotFoundException.class, e -> searchMessageManagerByMailboxRole(aRole, username));
 
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/SystemMailboxesProviderImplTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/SystemMailboxesProviderImplTest.java
index 35b7870..8d38d96 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/SystemMailboxesProviderImplTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/SystemMailboxesProviderImplTest.java
@@ -36,6 +36,7 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
 
 class SystemMailboxesProviderImplTest {
 
@@ -55,9 +56,10 @@ class SystemMailboxesProviderImplTest {
     }
 
     @Test
-    void getMailboxByRoleShouldReturnEmptyWhenNoMailbox() throws Exception {
+    void getMailboxByRoleShouldReturnEmptyWhenNoMailbox() {
         when(mailboxManager.createSystemSession(MailboxFixture.ALICE)).thenReturn(mailboxSession);
-        when(mailboxManager.getMailbox(eq(MailboxFixture.INBOX_ALICE), eq(mailboxSession))).thenThrow(MailboxNotFoundException.class);
+        when(mailboxManager.getMailboxReactive(eq(MailboxFixture.INBOX_ALICE), eq(mailboxSession)))
+            .thenReturn(Mono.error(new MailboxNotFoundException("Not found")));
         when(mailboxManager.search(any(), any(), any())).thenReturn(Flux.empty());
 
         assertThat(Flux.from(systemMailboxProvider.getMailboxByRole(Role.INBOX, mailboxSession.getUser())).toStream())
@@ -65,9 +67,9 @@ class SystemMailboxesProviderImplTest {
     }
 
     @Test
-    void getMailboxByRoleShouldReturnMailboxByRole() throws Exception {
+    void getMailboxByRoleShouldReturnMailboxByRole() {
         when(mailboxManager.createSystemSession(MailboxFixture.ALICE)).thenReturn(mailboxSession);
-        when(mailboxManager.getMailbox(eq(MailboxFixture.INBOX_ALICE), eq(mailboxSession))).thenReturn(inboxMessageManager);
+        when(mailboxManager.getMailboxReactive(eq(MailboxFixture.INBOX_ALICE), eq(mailboxSession))).thenReturn(Mono.just(inboxMessageManager));
 
         assertThat(Flux.from(systemMailboxProvider.getMailboxByRole(Role.INBOX, mailboxSession.getUser())).toStream())
             .hasSize(1)

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org