chibenwa commented on code in PR #2600:
URL: https://github.com/apache/james-project/pull/2600#discussion_r1917933652


##########
server/protocols/webadmin/webadmin-mailrepository/src/test/java/org/apache/james/webadmin/routes/MailRepositoriesRoutesTest.java:
##########
@@ -511,6 +512,290 @@ void zeroLimitShouldNotBeValid() {
             .body("message", is("limit can not be equal to zero"));
     }
 
+    @Test
+    void listingKeysShouldReturnContainedKeysThatMeetUpdatedBeforeCondition() 
throws Exception {
+        MailRepository mailRepository = 
mailRepositoryStore.create(URL_MY_REPO);
+
+        mailRepository.store(FakeMail.builder()
+            .name("name1")
+            .lastUpdated(getDateBeforeCurrentTime(3))
+            .build());
+        mailRepository.store(FakeMail.builder()
+            .name("name2")
+            .lastUpdated(getDateBeforeCurrentTime(2))
+            .build());
+        mailRepository.store(FakeMail.builder()
+            .name("name3")
+            .lastUpdated(getDateBeforeCurrentTime(1))
+            .build());
+
+        given()
+            .param("updatedBefore", "2d")
+        .when()
+            .get(MY_REPO_MAILS)
+            .then()
+            .statusCode(HttpStatus.OK_200)
+            .body("", hasSize(2))
+            .body("", containsInAnyOrder("name1", "name2"));
+    }
+
+    @Test
+    void listingKeysShouldReturnContainedKeysThatMeetUpdatedAfterCondition() 
throws Exception {
+        MailRepository mailRepository = 
mailRepositoryStore.create(URL_MY_REPO);
+
+        mailRepository.store(FakeMail.builder()
+            .name("name1")
+            .lastUpdated(getDateBeforeCurrentTime(3))
+            .build());
+        mailRepository.store(FakeMail.builder()
+            .name("name2")
+            .lastUpdated(getDateBeforeCurrentTime(2))
+            .build());
+        mailRepository.store(FakeMail.builder()
+            .name("name3")
+            .lastUpdated(getDateBeforeCurrentTime(1))
+            .build());
+
+        given()
+            .param("updatedAfter", "2d")
+            .when()
+            .get(MY_REPO_MAILS)
+            .then()
+            .statusCode(HttpStatus.OK_200)
+            .body("", hasSize(1))
+            .body("", containsInAnyOrder("name3"));
+    }
+
+    @Test
+    void listingKeysShouldReturnContainedKeysThatMeetExactSenderCondition() 
throws Exception {
+        MailRepository mailRepository = 
mailRepositoryStore.create(URL_MY_REPO);
+
+        mailRepository.store(FakeMail.builder()
+            .name("name1")
+            .sender("sen...@domain.com")
+            .build());
+        mailRepository.store(FakeMail.builder()
+            .name("name2")
+            .sender("sen...@domain.com")
+            .build());
+        mailRepository.store(FakeMail.builder()
+            .name("name3")
+            .sender("send...@domain.com")
+            .build());
+
+        given()
+            .param("sender", "sen...@domain.com")
+            .when()
+            .get(MY_REPO_MAILS)
+            .then()
+            .statusCode(HttpStatus.OK_200)
+            .body("", hasSize(2))
+            .body("", containsInAnyOrder("name1", "name2"));
+    }
+
+    @Test
+    void listingKeysShouldReturnContainedKeysThatMeetPrefixSenderCondition() 
throws Exception {
+        MailRepository mailRepository = 
mailRepositoryStore.create(URL_MY_REPO);
+
+        mailRepository.store(FakeMail.builder()
+            .name("name1")
+            .sender("sen...@domain.com")
+            .build());
+        mailRepository.store(FakeMail.builder()
+            .name("name2")
+            .sender("send...@domain.com")
+            .build());
+        mailRepository.store(FakeMail.builder()
+            .name("name3")
+            .sender("sen...@domain2.com")
+            .build());
+
+        given()
+            .param("sender", "*@domain.com")
+            .when()
+            .get(MY_REPO_MAILS)
+            .then()
+            .statusCode(HttpStatus.OK_200)
+            .body("", hasSize(2))
+            .body("", containsInAnyOrder("name1", "name2"));

Review Comment:
   ```suggestion
           given()
               .param("sender", "*@domain.com")
           .when()
               .get(MY_REPO_MAILS)
           .then()
               .statusCode(HttpStatus.OK_200)
               .body("", hasSize(2))
               .body("", containsInAnyOrder("name1", "name2"));
   ```



-- 
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: notifications-unsubscr...@james.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to