chibenwa commented on a change in pull request #831:
URL: https://github.com/apache/james-project/pull/831#discussion_r782740126



##########
File path: 
server/queue/queue-api/src/test/java/org/apache/james/queue/api/DelayedManageableMailQueueContract.java
##########
@@ -70,6 +72,61 @@ default void delayedMessagesShouldBeCleared() throws 
Exception {
         assertThat(getManageableMailQueue().getSize()).isEqualTo(0L);
     }
 
+    @Test
+    default void delayedEmailsShouldBeDeleted() throws Exception {
+        getManageableMailQueue().enQueue(defaultMail()
+                .name("abc")
+                .build(),
+            5L,
+            TimeUnit.SECONDS);
+        // The queue being FIFO a second email can serve as a wait condition
+        getManageableMailQueue().enQueue(defaultMail()
+                .name("def")
+                .build(),
+            5L,
+            TimeUnit.SECONDS);
+
+        getManageableMailQueue().remove(ManageableMailQueue.Type.Name, "abc");
+
+        ArrayList<String> names = new ArrayList<>();
+        Flux.from(getManageableMailQueue().deQueue())
+            .subscribeOn(Schedulers.elastic())
+            .subscribe(item -> names.add(item.getMail().getName()));
+
+       Awaitility.await().untilAsserted(() -> 
assertThat(names).contains("def"));
+        assertThat(names).containsExactly("def");
+    }
+
+    @Test
+    default void delayedEmailsShouldBeDeletedWhenMixedWithOtherEmails() throws 
Exception {
+        getManageableMailQueue().enQueue(defaultMail()
+                .name("abc")
+                .build(),
+            5L,
+            TimeUnit.SECONDS);
+
+        getManageableMailQueue().remove(ManageableMailQueue.Type.Name, "abc");
+
+        // The newer email
+        getManageableMailQueue().enQueue(defaultMail()
+                .name("def")
+                .build());
+        // The queue being FIFO a third email can serve as a wait condition
+        getManageableMailQueue().enQueue(defaultMail()
+                .name("ghi")
+                .build(),
+            5L,
+            TimeUnit.SECONDS);
+
+        ArrayList<String> names = new ArrayList<>();
+        Flux.from(getManageableMailQueue().deQueue())
+            .subscribeOn(Schedulers.elastic())
+            .subscribe(item -> names.add(item.getMail().getName()));
+
+       Awaitility.await().untilAsserted(() -> 
assertThat(names).contains("ghi"));

Review comment:
       ```suggestion
          Awaitility.await()
              .untilAsserted(() -> assertThat(names).contains("ghi"));
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to