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("[email protected]")
+ .build());
+ mailRepository.store(FakeMail.builder()
+ .name("name2")
+ .sender("[email protected]")
+ .build());
+ mailRepository.store(FakeMail.builder()
+ .name("name3")
+ .sender("[email protected]")
+ .build());
+
+ given()
+ .param("sender", "[email protected]")
+ .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("[email protected]")
+ .build());
+ mailRepository.store(FakeMail.builder()
+ .name("name2")
+ .sender("[email protected]")
+ .build());
+ mailRepository.store(FakeMail.builder()
+ .name("name3")
+ .sender("[email protected]")
+ .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"));
```
(Here and below)
--
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]