You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2024/01/23 03:06:59 UTC

(james-project) 01/04: JAMES-2586 - Delete Message Listener - add test case when delete mailbox has a lot of messages

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

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

commit 68f65ab2c57ed7f8aec1fb1081bec85088f5914c
Author: Tung Tran <vt...@linagora.com>
AuthorDate: Mon Jan 22 16:59:55 2024 +0700

    JAMES-2586 - Delete Message Listener - add test case when delete mailbox has a lot of messages
---
 .../postgres/DeleteMessageListenerContract.java       | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/DeleteMessageListenerContract.java b/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/DeleteMessageListenerContract.java
index 36a10cb33f..af85869d52 100644
--- a/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/DeleteMessageListenerContract.java
+++ b/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/DeleteMessageListenerContract.java
@@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.SoftAssertions.assertSoftly;
 import static org.junit.jupiter.api.Assumptions.assumeTrue;
 
+import java.util.List;
 import java.util.UUID;
 
 import org.apache.james.blob.api.BlobId;
@@ -43,8 +44,10 @@ import org.apache.james.util.ClassLoaderUtils;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import com.github.fge.lambdas.Throwing;
 import com.google.common.collect.ImmutableList;
 
+import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
 public abstract class DeleteMessageListenerContract {
@@ -224,4 +227,20 @@ public abstract class DeleteMessageListenerContract {
                 .isNotEmpty();
         });
     }
+
+    @Test
+    void deleteMessageListenerShouldSucceedWhenDeleteMailboxHasALotOfMessages() throws Exception {
+        List<PostgresMessageId> messageIdList = Flux.range(0, 50)
+            .map(i -> Throwing.supplier(() -> inboxManager.appendMessage(MessageManager.AppendCommand.builder()
+                .build(ClassLoaderUtils.getSystemResourceAsByteArray("eml/emailWithOnlyAttachment.eml")), session)).get())
+            .map(appendResult -> (PostgresMessageId) appendResult.getId().getMessageId())
+            .collectList()
+            .block();
+
+        mailboxManager.deleteMailbox(inbox, session);
+
+        assertThat(Flux.fromIterable(messageIdList)
+            .flatMap(msgId -> postgresMessageDAO.getBodyBlobId(msgId))
+            .collectList().block()).isEmpty();
+    }
 }


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