You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2020/06/11 15:25:47 UTC
[james-project] 10/17: JAMES-3201 Add missign tests for ReIndexing
tasks mailboxFailures
This is an automated email from the ASF dual-hosted git repository.
rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 24e68333b4e4d90648ea184bc8aff79b1a2a8e33
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed Jun 10 13:37:46 2020 +0700
JAMES-3201 Add missign tests for ReIndexing tasks mailboxFailures
---
.../james/webadmin/routes/MailboxesRoutesTest.java | 81 ++++++++++++++++++++++
.../webadmin/routes/UserMailboxesRoutesTest.java | 25 +++++++
2 files changed, 106 insertions(+)
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/MailboxesRoutesTest.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/MailboxesRoutesTest.java
index dfb5867..e9ce823 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/MailboxesRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/MailboxesRoutesTest.java
@@ -63,6 +63,7 @@ import org.apache.mailbox.tools.indexer.SingleMailboxReindexingTask;
import org.apache.mailbox.tools.indexer.SingleMessageReindexingTask;
import org.apache.mailbox.tools.indexer.SingleMessageReindexingTaskAdditionalInformationDTO;
import org.eclipse.jetty.http.HttpStatus;
+import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
@@ -246,6 +247,30 @@ class MailboxesRoutesTest {
.body("startedDate", is(notNullValue()))
.body("submitDate", is(notNullValue()));
}
+
+ @Test
+ void userReprocessingShouldReturnTaskDetailsWhenFailingAtTheMailboxLevel() throws Exception {
+ MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME);
+ MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
+
+ doReturn(Mono.error(new RuntimeException()))
+ .when(searchIndex)
+ .deleteAll(any(MailboxSession.class), any(MailboxId.class));
+
+ String taskId = with()
+ .post("/mailboxes?task=reIndex")
+ .jsonPath()
+ .get("taskId");
+
+ given()
+ .basePath(TasksRoutes.BASE)
+ .when()
+ .get(taskId + "/await")
+ .then()
+ .body("status", Matchers.is("failed"))
+ .body("taskId", Matchers.is(notNullValue()))
+ .body("additionalInformation.mailboxFailures", Matchers.containsInAnyOrder(mailboxId.serialize()));
+ }
}
@Nested
@@ -435,6 +460,31 @@ class MailboxesRoutesTest {
.body("startedDate", is(notNullValue()))
.body("submitDate", is(notNullValue()));
}
+
+ @Test
+ void userReprocessingShouldReturnTaskDetailsWhenFailingAtTheMailboxLevel() throws Exception {
+ MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME);
+ MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
+
+ doReturn(Mono.error(new RuntimeException()))
+ .when(searchIndex)
+ .deleteAll(any(MailboxSession.class), any(MailboxId.class));
+
+ String taskId = with()
+ .queryParam("task", "reIndex")
+ .post("/mailboxes/" + mailboxId.serialize())
+ .jsonPath()
+ .get("taskId");
+
+ given()
+ .basePath(TasksRoutes.BASE)
+ .when()
+ .get(taskId + "/await")
+ .then()
+ .body("status", Matchers.is("failed"))
+ .body("taskId", Matchers.is(notNullValue()))
+ .body("additionalInformation.mailboxFailures", Matchers.containsInAnyOrder(mailboxId.serialize()));
+ }
}
@Nested
@@ -831,6 +881,37 @@ class MailboxesRoutesTest {
.body("startedDate", is(notNullValue()))
.body("submitDate", is(notNullValue()));
}
+
+ @Test
+ void userReprocessingShouldReturnTaskDetailsWhenFailingAtTheMailboxLevel() throws Exception {
+ MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME);
+ MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
+
+ doReturn(Mono.error(new RuntimeException()))
+ .when(searchIndex)
+ .deleteAll(any(MailboxSession.class), any(MailboxId.class));
+
+ String taskId = with()
+ .post("/mailboxes?task=reIndex")
+ .jsonPath()
+ .get("taskId");
+
+ String fixingTaskId = with()
+ .queryParam("reIndexFailedMessagesOf", taskId)
+ .queryParam("task", "reIndex")
+ .post("/mailboxes")
+ .jsonPath()
+ .get("taskId");
+
+ given()
+ .basePath(TasksRoutes.BASE)
+ .when()
+ .get(fixingTaskId + "/await")
+ .then()
+ .body("status", Matchers.is("failed"))
+ .body("taskId", Matchers.is(notNullValue()))
+ .body("additionalInformation.mailboxFailures", Matchers.containsInAnyOrder(mailboxId.serialize()));
+ }
}
@Nested
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java
index 2818968..2e8068d 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserMailboxesRoutesTest.java
@@ -1259,6 +1259,31 @@ class UserMailboxesRoutesTest {
.body("startedDate", Matchers.is(notNullValue()))
.body("submitDate", Matchers.is(notNullValue()));
}
+
+ @Test
+ void userReprocessingShouldReturnTaskDetailsWhenFailingAtTheMailboxLevel() throws Exception {
+ MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME);
+ MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
+
+ doReturn(Mono.error(new RuntimeException()))
+ .when(searchIndex)
+ .deleteAll(any(MailboxSession.class), any(MailboxId.class));
+
+ String taskId = with()
+ .queryParam("task", "reIndex")
+ .post()
+ .jsonPath()
+ .get("taskId");
+
+ given()
+ .basePath(TasksRoutes.BASE)
+ .when()
+ .get(taskId + "/await")
+ .then()
+ .body("status", Matchers.is("failed"))
+ .body("taskId", Matchers.is(notNullValue()))
+ .body("additionalInformation.mailboxFailures", Matchers.containsInAnyOrder(mailboxId.serialize()));
+ }
}
@Nested
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org