From 0f5a0f2640fe309046045874c719afd7d840fea6 Mon Sep 17 00:00:00 2001 From: benwa Date: Mon, 2 Oct 2017 09:49:58 +0700 Subject: [PATCH] JAMES-2169 Various JMAP integration testing improvements --- .../integration/GetMessageListMethodTest.java | 41 +- .../integration/SetMailboxesMethodTest.java | 468 +++++++----------- .../integration/SetMessagesMethodTest.java | 31 +- .../cucumber/DownloadStepdefs.java | 11 +- .../cucumber/GetMessagesMethodStepdefs.java | 12 +- .../integration/cucumber/MainStepdefs.java | 8 + .../cucumber/SetMailboxesMethodStepdefs.java | 13 +- .../integration/cucumber/UserStepdefs.java | 8 +- 8 files changed, 239 insertions(+), 353 deletions(-) diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java index 65e734ca545..dea3316131e 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java @@ -48,7 +48,6 @@ import org.apache.james.mailbox.model.MailboxConstants; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.probe.MailboxProbe; import org.apache.james.mime4j.dom.Message; import org.apache.james.mime4j.dom.MessageWriter; @@ -126,17 +125,15 @@ public void teardown() { @Test public void getMessageListShouldNotDuplicateMessagesInSeveralMailboxes() throws Exception { - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2"); - Mailbox mailbox = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); - Mailbox mailbox2 = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2"); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); + MailboxId mailboxId2 = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2"); ComposedMessageId message = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags()); await(); - jmapServer.getProbe(JmapGuiceProbe.class).setInMailboxes(message.getMessageId(), username, mailbox.getMailboxId(), mailbox2.getMailboxId()); + jmapServer.getProbe(JmapGuiceProbe.class).setInMailboxes(message.getMessageId(), username, mailboxId, mailboxId2); given() .header("Authorization", accessToken.serialize()) @@ -624,13 +621,11 @@ public void getMessageListShouldReturnAllMessagesOfCurrentUserOnlyWhenMultipleMa @Test public void getMessageListShouldFilterMessagesWhenInMailboxesFilterMatches() throws Exception { - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); ComposedMessageId message = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags()); await(); - MailboxId mailboxId = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox").getMailboxId(); - given() .header("Authorization", accessToken.serialize()) .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" + mailboxId.serialize() + "\"]}}, \"#0\"]]") @@ -644,16 +639,13 @@ public void getMessageListShouldFilterMessagesWhenInMailboxesFilterMatches() thr @Test public void getMessageListShouldFilterMessagesWhenMultipleInMailboxesFilterMatches() throws Exception { - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); ComposedMessageId message = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags()); - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2"); + MailboxId mailboxId2 = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2"); await(); - MailboxId mailboxId = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox").getMailboxId(); - MailboxId mailboxId2 = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2").getMailboxId(); - given() .header("Authorization", accessToken.serialize()) .body(String.format("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"%s\", \"%s\"]}}, \"#0\"]]", mailboxId.serialize(), mailboxId2.serialize())) @@ -667,12 +659,10 @@ public void getMessageListShouldFilterMessagesWhenMultipleInMailboxesFilterMatch @Test public void getMessageListShouldFilterMessagesWhenNotInMailboxesFilterMatches() throws Exception { - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags()); - MailboxId mailboxId = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox").getMailboxId(); - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2"); await(); given() @@ -688,15 +678,13 @@ public void getMessageListShouldFilterMessagesWhenNotInMailboxesFilterMatches() @Test public void getMessageListShouldFilterMessagesWhenNotInMailboxesFilterMatchesTwice() throws Exception { - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags()); - MailboxId mailboxId = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox").getMailboxId(); - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2"); + MailboxId mailbox2Id = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2"); mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox2"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags()); - MailboxId mailbox2Id = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2").getMailboxId(); await(); given() @@ -712,10 +700,9 @@ public void getMessageListShouldFilterMessagesWhenNotInMailboxesFilterMatchesTwi @Test public void getMessageListShouldFilterMessagesWhenIdenticalNotInMailboxesAndInmailboxesFilterMatch() throws Exception { - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags()); - MailboxId mailboxId = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox").getMailboxId(); await(); given() @@ -735,8 +722,7 @@ public void getMessageListShouldNotFilterMessagesWhenNotInMailboxesFilterDoesNot ComposedMessageId message = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags()); - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2"); - MailboxId mailbox2Id = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2").getMailboxId(); + MailboxId mailbox2Id = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2"); await(); given() @@ -772,9 +758,8 @@ public void getMessageListShouldNotFilterMessagesWhenEmptyNotInMailboxesFilter() @Test public void getMessageListShouldFilterMessagesWhenInMailboxesFilterDoesntMatches() throws Exception { - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "emptyMailbox"); - MailboxId emptyMailboxId = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "emptyMailbox").getMailboxId(); - + MailboxId emptyMailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "emptyMailbox"); + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags()); diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java index cc48707766f..56fae73a57f 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java @@ -86,14 +86,13 @@ public abstract class SetMailboxesMethodTest { private String username; private GuiceJamesServer jmapServer; private MailboxProbe mailboxProbe; - private DataProbe dataProbe; - + @Before public void setup() throws Throwable { jmapServer = createJmapServer(); jmapServer.start(); mailboxProbe = jmapServer.getProbe(MailboxProbeImpl.class); - dataProbe = jmapServer.getProbe(DataProbeImpl.class); + DataProbe dataProbe = jmapServer.getProbe(DataProbeImpl.class); RestAssured.requestSpecification = new RequestSpecBuilder() .setContentType(ContentType.JSON) @@ -155,22 +154,19 @@ public void setMailboxesShouldNotCreateWhenOverLimitName() { .body(ARGUMENTS + ".notCreated", aMapWithSize(1)) .body(ARGUMENTS + ".notCreated", hasEntry(equalTo("create-id01"), Matchers.allOf( hasEntry(equalTo("type"), equalTo("invalidArguments")), - hasEntry(equalTo("description"), equalTo("The mailbox name length is too long"))) - )); + hasEntry(equalTo("description"), equalTo("The mailbox name length is too long"))))); } @Test public void setMailboxesShouldNotUpdateMailboxWhenOverLimitName() { String overLimitName = StringUtils.repeat("a", MAILBOX_NAME_LENGTH_64K); - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"name\" : \"" + overLimitName + "\"" + " }" + " }" + @@ -178,19 +174,19 @@ public void setMailboxesShouldNotUpdateMailboxWhenOverLimitName() { " \"#0\"" + " ]" + "]"; + given() .header("Authorization", accessToken.serialize()) .body(requestBody) - .when() + .when() .post("/jmap") - .then() + .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) .body(ARGUMENTS + ".notUpdated", aMapWithSize(1)) - .body(ARGUMENTS + ".notUpdated", hasEntry(equalTo(mailboxId), Matchers.allOf( + .body(ARGUMENTS + ".notUpdated", hasEntry(equalTo(mailboxId.serialize()), Matchers.allOf( hasEntry(equalTo("type"), equalTo("invalidArguments")), - hasEntry(equalTo("description"), equalTo("The mailbox name length is too long"))) - )); + hasEntry(equalTo("description"), equalTo("The mailbox name length is too long"))))); } @Test @@ -213,9 +209,9 @@ public void setMailboxesShouldCreateWhenOverLimitName() throws Exception { given() .header("Authorization", accessToken.serialize()) .body(requestBody) - .when() + .when() .post("/jmap") - .then() + .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) .body(ARGUMENTS + ".created", hasKey("create-id01")); @@ -224,15 +220,13 @@ public void setMailboxesShouldCreateWhenOverLimitName() throws Exception { @Test public void setMailboxesShouldUpdateMailboxWhenOverLimitName() throws Exception { String overLimitName = StringUtils.repeat("a", MAILBOX_NAME_LENGTH_64K); - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"name\" : \"" + overLimitName + "\"" + " }" + " }" + @@ -243,14 +237,14 @@ public void setMailboxesShouldUpdateMailboxWhenOverLimitName() throws Exception given() .header("Authorization", accessToken.serialize()) .body(requestBody) - .when() + .when() .post("/jmap") - .then() + .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".updated", contains(mailboxId)); + .body(ARGUMENTS + ".updated", contains(mailboxId.serialize())); - assertThat(jmapServer.getProbe(MailboxProbeImpl.class).listSubscriptions(username)).containsOnly(overLimitName); + assertThat(mailboxProbe.listSubscriptions(username)).containsOnly(overLimitName); } @Test @@ -279,12 +273,12 @@ public void userShouldBeSubscribedOnCreatedMailboxWhenCreateMailbox() throws Exc .body(NAME, equalTo("mailboxesSet")) .body(ARGUMENTS + ".created", hasKey("create-id01")); - assertThat(jmapServer.getProbe(MailboxProbeImpl.class).listSubscriptions(username)).containsOnly("foo"); + assertThat(mailboxProbe.listSubscriptions(username)).containsOnly("foo"); } @Test public void userShouldBeSubscribedOnCreatedMailboxWhenCreateChildOfInboxMailbox() throws Exception { - MailboxId inboxId = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX).getMailboxId(); + MailboxId inboxId = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX).getMailboxId(); String requestBody = "[" + @@ -307,23 +301,21 @@ public void userShouldBeSubscribedOnCreatedMailboxWhenCreateChildOfInboxMailbox( .when() .post("/jmap"); - assertThat(jmapServer.getProbe(MailboxProbeImpl.class).listSubscriptions(username)).containsOnly(DefaultMailboxes.INBOX + ".foo"); + assertThat(mailboxProbe.listSubscriptions(username)).containsOnly(DefaultMailboxes.INBOX + ".foo"); } @Test public void subscriptionUserShouldBeChangedWhenUpdateMailbox() throws Exception { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "root"); + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "root"); - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"name\" : \"mySecondBox\"" + " }" + " }" + @@ -336,7 +328,7 @@ public void subscriptionUserShouldBeChangedWhenUpdateMailbox() throws Exception .body(requestBody) .post("/jmap"); - assertThat(jmapServer.getProbe(MailboxProbeImpl.class).listSubscriptions(username)).containsOnly("mySecondBox"); + assertThat(mailboxProbe.listSubscriptions(username)).containsOnly("mySecondBox"); } @Test @@ -365,7 +357,7 @@ public void subscriptionUserShouldBeChangedWhenCreateThenUpdateMailboxNameWithJM .body(NAME, equalTo("mailboxesSet")) .body(ARGUMENTS + ".created", hasKey("create-id01")); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "foo"); + Mailbox mailbox = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "foo"); String mailboxId = mailbox.getMailboxId().serialize(); requestBody = @@ -387,18 +379,17 @@ public void subscriptionUserShouldBeChangedWhenCreateThenUpdateMailboxNameWithJM .body(requestBody) .post("/jmap"); - assertThat(jmapServer.getProbe(MailboxProbeImpl.class).listSubscriptions(username)).containsOnly("mySecondBox"); + assertThat(mailboxProbe.listSubscriptions(username)).containsOnly("mySecondBox"); } @Test public void subscriptionUserShouldBeDeletedWhenDestroyMailbox() throws Exception { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + - " \"destroy\": [\"" + mailbox.getMailboxId().serialize() + "\"]" + + " \"destroy\": [\"" + mailboxId.serialize() + "\"]" + " }," + " \"#0\"" + " ]" + @@ -412,7 +403,7 @@ public void subscriptionUserShouldBeDeletedWhenDestroyMailbox() throws Exception .then() .statusCode(200); - assertThat(jmapServer.getProbe(MailboxProbeImpl.class).listSubscriptions(username)).isEmpty(); + assertThat(mailboxProbe.listSubscriptions(username)).isEmpty(); } @Test @@ -441,7 +432,7 @@ public void subscriptionUserShouldBeDeletedWhenCreateThenDestroyMailboxWithJMAP( .body(NAME, equalTo("mailboxesSet")) .body(ARGUMENTS + ".created", hasKey("create-id01")); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "foo"); + Mailbox mailbox = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "foo"); requestBody = "[" + @@ -461,7 +452,7 @@ public void subscriptionUserShouldBeDeletedWhenCreateThenDestroyMailboxWithJMAP( .then() .statusCode(200); - assertThat(jmapServer.getProbe(MailboxProbeImpl.class).listSubscriptions(username)).isEmpty(); + assertThat(mailboxProbe.listSubscriptions(username)).isEmpty(); } @Test @@ -624,7 +615,7 @@ public void setMailboxesShouldReturnCreatedMailboxWhenChildOfInboxMailbox() { @Test public void setMailboxesShouldCreateMailboxWhenChildOfInboxMailbox() { - MailboxId inboxId = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX).getMailboxId(); + MailboxId inboxId = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX).getMailboxId(); String requestBody = "[" + @@ -765,7 +756,7 @@ public void setMailboxesShouldReturnCreatedMailboxWhenCreatingChildThenParentMai @Test public void setMailboxesShouldReturnNotCreatedWhenMailboxAlreadyExists() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + @@ -867,14 +858,12 @@ public void setMailboxesShouldReturnNotCreatedWhenMailboxNameContainsPathDelimit @Test public void setMailboxesShouldReturnDestroyedMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + - " \"destroy\": [\"" + mailboxId + "\"]" + + " \"destroy\": [\"" + mailboxId.serialize() + "\"]" + " }," + " \"#0\"" + " ]" + @@ -888,18 +877,17 @@ public void setMailboxesShouldReturnDestroyedMailbox() { .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".destroyed", contains(mailboxId)); + .body(ARGUMENTS + ".destroyed", contains(mailboxId.serialize())); } @Test public void setMailboxesShouldDestroyMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + - " \"destroy\": [\"" + mailbox.getMailboxId().serialize() + "\"]" + + " \"destroy\": [\"" + mailboxId.serialize() + "\"]" + " }," + " \"#0\"" + " ]" + @@ -953,15 +941,13 @@ public void setMailboxesShouldReturnNotDestroyedWhenMailboxDoesntExist() { @Test public void setMailboxesShouldReturnNotDestroyedWhenMailboxHasChild() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox.child"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox.child"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + - " \"destroy\": [\"" + mailboxId + "\"]" + + " \"destroy\": [\"" + mailboxId.serialize() + "\"]" + " }," + " \"#0\"" + " ]" + @@ -976,14 +962,14 @@ public void setMailboxesShouldReturnNotDestroyedWhenMailboxHasChild() { .statusCode(200) .body(NAME, equalTo("mailboxesSet")) .body(ARGUMENTS + ".notDestroyed", aMapWithSize(1)) - .body(ARGUMENTS + ".notDestroyed", hasEntry(equalTo(mailboxId), Matchers.allOf( + .body(ARGUMENTS + ".notDestroyed", hasEntry(equalTo(mailboxId.serialize()), Matchers.allOf( hasEntry(equalTo("type"), equalTo("mailboxHasChild")), - hasEntry(equalTo("description"), equalTo("The mailbox '" + mailboxId + "' has a child."))))); + hasEntry(equalTo("description"), equalTo("The mailbox '" + mailboxId.serialize() + "' has a child."))))); } @Test public void setMailboxesShouldReturnNotDestroyedWhenSystemMailbox() { - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX); + Mailbox mailbox = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = "[" + @@ -1011,17 +997,13 @@ public void setMailboxesShouldReturnNotDestroyedWhenSystemMailbox() { @Test public void setMailboxesShouldReturnDestroyedWhenParentThenChildMailboxes() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "parent"); - Mailbox parentMailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "parent"); - String parentMailboxId = parentMailbox.getMailboxId().serialize(); - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "parent.child"); - Mailbox childMailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "parent.child"); - String childMailboxId = childMailbox.getMailboxId().serialize(); + MailboxId parentMailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "parent"); + MailboxId childMailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "parent.child"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + - " \"destroy\": [\"" + parentMailboxId + "\",\"" + childMailboxId + "\"]" + + " \"destroy\": [\"" + parentMailboxId.serialize() + "\",\"" + childMailboxId.serialize() + "\"]" + " }," + " \"#0\"" + " ]" + @@ -1035,22 +1017,18 @@ public void setMailboxesShouldReturnDestroyedWhenParentThenChildMailboxes() { .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".destroyed", containsInAnyOrder(parentMailboxId, childMailboxId)); + .body(ARGUMENTS + ".destroyed", containsInAnyOrder(parentMailboxId.serialize(), childMailboxId.serialize())); } @Test public void setMailboxesShouldReturnDestroyedWhenChildThenParentMailboxes() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "parent"); - Mailbox parentMailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "parent"); - String parentMailboxId = parentMailbox.getMailboxId().serialize(); - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "parent.child"); - Mailbox childMailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "parent.child"); - String childMailboxId = childMailbox.getMailboxId().serialize(); + MailboxId parentMailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "parent"); + MailboxId childMailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "parent.child"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + - " \"destroy\": [\"" + childMailboxId + "\",\"" + parentMailboxId + "\"]" + + " \"destroy\": [\"" + childMailboxId.serialize() + "\",\"" + parentMailboxId.serialize() + "\"]" + " }," + " \"#0\"" + " ]" + @@ -1064,12 +1042,11 @@ public void setMailboxesShouldReturnDestroyedWhenChildThenParentMailboxes() { .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".destroyed", containsInAnyOrder(parentMailboxId, childMailboxId)); + .body(ARGUMENTS + ".destroyed", containsInAnyOrder(parentMailboxId.serialize(), childMailboxId.serialize())); } private MailboxId getRemovedMailboxId() { - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "quicklyRemoved"); - MailboxId removedId = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "quicklyRemoved").getMailboxId(); + MailboxId removedId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "quicklyRemoved"); mailboxProbe.deleteMailbox(MailboxConstants.USER_NAMESPACE, username, "quicklyRemoved"); return removedId; } @@ -1106,15 +1083,13 @@ public void setMailboxesShouldReturnNotUpdatedWhenUnknownMailbox() { @Test public void setMailboxesShouldReturnUpdatedMailboxIdWhenNoUpdateAskedOnExistingMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " }" + " }" + " }," + @@ -1130,20 +1105,18 @@ public void setMailboxesShouldReturnUpdatedMailboxIdWhenNoUpdateAskedOnExistingM .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".updated", contains(mailboxId)); + .body(ARGUMENTS + ".updated", contains(mailboxId.serialize())); } @Test public void setMailboxesShouldReturnUpdatedWhenNameUpdateAskedOnExistingMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"name\" : \"myRenamedBox\"" + " }" + " }" + @@ -1160,20 +1133,18 @@ public void setMailboxesShouldReturnUpdatedWhenNameUpdateAskedOnExistingMailbox( .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".updated", contains(mailboxId)); + .body(ARGUMENTS + ".updated", contains(mailboxId.serialize())); } @Test public void updateShouldReturnOkWhenClearingSharedWith() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"sharedWith\" : {}" + " }" + " }" + @@ -1190,35 +1161,35 @@ public void updateShouldReturnOkWhenClearingSharedWith() { .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".updated", contains(mailboxId)); + .body(ARGUMENTS + ".updated", contains(mailboxId.serialize())); } @Test public void updateShouldReturnOkWhenSettingNewACL() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); - - given() - .header("Authorization", accessToken.serialize()) - .body("[" + + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + String requestBody = + "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"sharedWith\" : {\"user\": [\"a\", \"w\"]}" + " }" + " }" + " }," + " \"#0\"" + " ]" + - "]") + "]"; + + given() + .header("Authorization", accessToken.serialize()) + .body(requestBody) .when() .post("/jmap") .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".updated", contains(mailboxId)); + .body(ARGUMENTS + ".updated", contains(mailboxId.serialize())); } @Test @@ -1312,29 +1283,29 @@ public void updateShouldRejectNonExistingRights() { public void updateShouldApplyWhenSettingNewACL() { String myBox = "myBox"; String user = "user"; - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, myBox); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); - - with() - .header("Authorization", accessToken.serialize()) - .body("[" + + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, myBox); + String requestBody = + "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"sharedWith\" : {\"" + user + "\": [\"a\", \"w\"]}" + " }" + " }" + " }," + " \"#0\"" + " ]" + - "]") + "]"; + + with() + .header("Authorization", accessToken.serialize()) + .body(requestBody) .post("/jmap"); given() .header("Authorization", accessToken.serialize()) - .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId + "\"]}, \"#0\"]]") + .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() + "\"]}, \"#0\"]]") .when() .post("/jmap") .then() @@ -1348,9 +1319,7 @@ public void updateShouldApplyWhenSettingNewACL() { public void updateShouldModifyStoredDataWhenUpdatingACL() { String myBox = "myBox"; String user = "user"; - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, myBox); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, myBox); with() .header("Authorization", accessToken.serialize()) @@ -1358,7 +1327,7 @@ public void updateShouldModifyStoredDataWhenUpdatingACL() { " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"sharedWith\" : {\"" + user + "\": [\"a\", \"w\"]}" + " }" + " }" + @@ -1374,7 +1343,7 @@ public void updateShouldModifyStoredDataWhenUpdatingACL() { " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"sharedWith\" : {\"" + user + "\": [\"a\", \"t\"]}" + " }" + " }" + @@ -1386,7 +1355,7 @@ public void updateShouldModifyStoredDataWhenUpdatingACL() { given() .header("Authorization", accessToken.serialize()) - .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId + "\"]}, \"#0\"]]") + .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() + "\"]}, \"#0\"]]") .when() .post("/jmap") .then() @@ -1400,9 +1369,7 @@ public void updateShouldModifyStoredDataWhenUpdatingACL() { public void updateShouldClearStoredDataWhenDeleteACL() { String myBox = "myBox"; String user = "user"; - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, myBox); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, myBox); with() .header("Authorization", accessToken.serialize()) @@ -1410,7 +1377,7 @@ public void updateShouldClearStoredDataWhenDeleteACL() { " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"sharedWith\" : {\"" + user + "\": [\"a\", \"w\"]}" + " }" + " }" + @@ -1426,7 +1393,7 @@ public void updateShouldClearStoredDataWhenDeleteACL() { " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"sharedWith\" : {}" + " }" + " }" + @@ -1438,7 +1405,7 @@ public void updateShouldClearStoredDataWhenDeleteACL() { given() .header("Authorization", accessToken.serialize()) - .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId + "\"]}, \"#0\"]]") + .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() + "\"]}, \"#0\"]]") .when() .post("/jmap") .then() @@ -1453,9 +1420,7 @@ public void updateShouldModifyStoredDataWhenSwitchingACLUser() { String myBox = "myBox"; String user1 = "user1"; String user2 = "user2"; - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, myBox); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, myBox); with() .header("Authorization", accessToken.serialize()) @@ -1463,7 +1428,7 @@ public void updateShouldModifyStoredDataWhenSwitchingACLUser() { " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"sharedWith\" : {\"" + user1 + "\": [\"a\", \"w\"]}" + " }" + " }" + @@ -1479,7 +1444,7 @@ public void updateShouldModifyStoredDataWhenSwitchingACLUser() { " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"sharedWith\" : {\"" + user2 + "\": [\"a\", \"w\"]}" + " }" + " }" + @@ -1491,7 +1456,7 @@ public void updateShouldModifyStoredDataWhenSwitchingACLUser() { given() .header("Authorization", accessToken.serialize()) - .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId + "\"]}, \"#0\"]]") + .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() + "\"]}, \"#0\"]]") .when() .post("/jmap") .then() @@ -1503,15 +1468,13 @@ public void updateShouldModifyStoredDataWhenSwitchingACLUser() { @Test public void setMailboxesShouldUpdateMailboxNameWhenNameUpdateAskedOnExistingMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"name\" : \"myRenamedBox\"" + " }" + " }" + @@ -1527,7 +1490,7 @@ public void setMailboxesShouldUpdateMailboxNameWhenNameUpdateAskedOnExistingMail given() .header("Authorization", accessToken.serialize()) - .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId + "\"]}, \"#0\"]]") + .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() + "\"]}, \"#0\"]]") .when() .post("/jmap") .then() @@ -1539,21 +1502,19 @@ public void setMailboxesShouldUpdateMailboxNameWhenNameUpdateAskedOnExistingMail @Test public void setMailboxesShouldReturnMailboxIdWhenMovingToAnotherParentMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe + .createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myChosenParentBox"); - Mailbox chosenMailboxParent = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myChosenParentBox"); - String chosenMailboxParentId = chosenMailboxParent.getMailboxId().serialize(); + MailboxId chosenMailboxParentId = mailboxProbe + .createMailbox(MailboxConstants.USER_NAMESPACE, username, "myChosenParentBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + - " \"parentId\" : \"" + chosenMailboxParentId + "\"" + + " \"" + mailboxId.serialize() + "\" : {" + + " \"parentId\" : \"" + chosenMailboxParentId.serialize() + "\"" + " }" + " }" + " }," + @@ -1569,26 +1530,24 @@ public void setMailboxesShouldReturnMailboxIdWhenMovingToAnotherParentMailbox() .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".updated", contains(mailboxId)); + .body(ARGUMENTS + ".updated", contains(mailboxId.serialize())); } @Test public void setMailboxesShouldUpdateMailboxParentIdWhenMovingToAnotherParentMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); - - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); - Mailbox newParentMailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); - String newParentMailboxId = newParentMailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe + .createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); + + MailboxId newParentMailboxId = mailboxProbe + .createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + - " \"parentId\" : \"" + newParentMailboxId + "\"" + + " \"" + mailboxId.serialize() + "\" : {" + + " \"parentId\" : \"" + newParentMailboxId.serialize() + "\"" + " }" + " }" + " }," + @@ -1603,35 +1562,34 @@ public void setMailboxesShouldUpdateMailboxParentIdWhenMovingToAnotherParentMail given() .header("Authorization", accessToken.serialize()) - .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId + "\"]}, \"#0\"]]") + .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() + "\"]}, \"#0\"]]") .when() .post("/jmap") .then() .statusCode(200) .body(NAME, equalTo("mailboxes")) .body(ARGUMENTS + ".list", hasSize(1)) - .body(ARGUMENTS + ".list[0].parentId", equalTo(newParentMailboxId)); + .body(ARGUMENTS + ".list[0].parentId", equalTo(newParentMailboxId.serialize())); } @Test public void setMailboxesShouldReturnMailboxIdWhenParentIdUpdateAskedOnExistingMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); + mailboxProbe + .createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); - - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); - Mailbox newParentMailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); - String newParentMailboxId = newParentMailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe + .createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); + + MailboxId newParentMailboxId = mailboxProbe + .createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + - " \"parentId\" : \"" + newParentMailboxId + "\"" + + " \"" + mailboxId.serialize() + "\" : {" + + " \"parentId\" : \"" + newParentMailboxId.serialize() + "\"" + " }" + " }" + " }," + @@ -1647,28 +1605,24 @@ public void setMailboxesShouldReturnMailboxIdWhenParentIdUpdateAskedOnExistingMa .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".updated", contains(mailboxId)); + .body(ARGUMENTS + ".updated", contains(mailboxId.serialize())); } @Test public void setMailboxesShouldUpdateMailboxParentIdWhenParentIdUpdateAskedOnExistingMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); - - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); - Mailbox newParentMailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); - String newParentMailboxId = newParentMailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); + + MailboxId newParentMailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + - " \"parentId\" : \"" + newParentMailboxId + "\"" + + " \"" + mailboxId.serialize() + "\" : {" + + " \"parentId\" : \"" + newParentMailboxId.serialize() + "\"" + " }" + " }" + " }," + @@ -1683,30 +1637,28 @@ public void setMailboxesShouldUpdateMailboxParentIdWhenParentIdUpdateAskedOnExis given() .header("Authorization", accessToken.serialize()) - .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId + "\"]}, \"#0\"]]") + .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() + "\"]}, \"#0\"]]") .when() .post("/jmap") .then() .statusCode(200) .body(NAME, equalTo("mailboxes")) .body(ARGUMENTS + ".list", hasSize(1)) - .body(ARGUMENTS + ".list[0].parentId", equalTo(newParentMailboxId)); + .body(ARGUMENTS + ".list[0].parentId", equalTo(newParentMailboxId.serialize())); } @Test public void setMailboxesShouldReturnMailboxIdWhenParentIdUpdateAskedAsOrphanForExistingMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"parentId\" : null" + " }" + " }" + @@ -1723,23 +1675,21 @@ public void setMailboxesShouldReturnMailboxIdWhenParentIdUpdateAskedAsOrphanForE .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".updated", contains(mailboxId)); + .body(ARGUMENTS + ".updated", contains(mailboxId.serialize())); } @Test public void setMailboxesShouldUpdateParentIdWhenAskedAsOrphanForExistingMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"parentId\" : null" + " }" + " }" + @@ -1755,7 +1705,7 @@ public void setMailboxesShouldUpdateParentIdWhenAskedAsOrphanForExistingMailbox( given() .header("Authorization", accessToken.serialize()) - .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId + "\"]}, \"#0\"]]") + .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() + "\"]}, \"#0\"]]") .when() .post("/jmap") .then() @@ -1767,24 +1717,18 @@ public void setMailboxesShouldUpdateParentIdWhenAskedAsOrphanForExistingMailbox( @Test public void setMailboxesShouldReturnMailboxIdWhenNameAndParentIdUpdateForExistingMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); - - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); - - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); - Mailbox newParentMailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); - String newParentMailboxId = newParentMailbox.getMailboxId().serialize(); + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); + MailboxId newParentMailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"name\" : \"myRenamedBox\", " + - " \"parentId\" : \"" + newParentMailboxId + "\"" + + " \"parentId\" : \"" + newParentMailboxId.serialize() + "\"" + " }" + " }" + " }," + @@ -1800,29 +1744,23 @@ public void setMailboxesShouldReturnMailboxIdWhenNameAndParentIdUpdateForExistin .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".updated", contains(mailboxId)); + .body(ARGUMENTS + ".updated", contains(mailboxId.serialize())); } @Test public void setMailboxesShoulUpdateMailboxIAndParentIddWhenBothUpdatedForExistingMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); - - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); - - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); - Mailbox newParentMailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); - String newParentMailboxId = newParentMailbox.getMailboxId().serialize(); + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); + MailboxId newParentMailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"name\" : \"myRenamedBox\", " + - " \"parentId\" : \"" + newParentMailboxId + "\"" + + " \"parentId\" : \"" + newParentMailboxId.serialize() + "\"" + " }" + " }" + " }," + @@ -1837,28 +1775,26 @@ public void setMailboxesShoulUpdateMailboxIAndParentIddWhenBothUpdatedForExistin given() .header("Authorization", accessToken.serialize()) - .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId + "\"]}, \"#0\"]]") + .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() + "\"]}, \"#0\"]]") .when() .post("/jmap") .then() .statusCode(200) .body(NAME, equalTo("mailboxes")) .body(ARGUMENTS + ".list", hasSize(1)) - .body(ARGUMENTS + ".list[0].parentId",equalTo(newParentMailboxId)) + .body(ARGUMENTS + ".list[0].parentId",equalTo(newParentMailboxId.serialize())) .body(ARGUMENTS + ".list[0].name",equalTo("myRenamedBox")); } @Test public void setMailboxesShouldReturnNotUpdatedWhenNameContainsPathDelimiter() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"name\" : \"my.Box\"" + " }" + " }" + @@ -1875,23 +1811,21 @@ public void setMailboxesShouldReturnNotUpdatedWhenNameContainsPathDelimiter() { .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".notUpdated", hasEntry(equalTo(mailboxId), Matchers.allOf( + .body(ARGUMENTS + ".notUpdated", hasEntry(equalTo(mailboxId.serialize()), Matchers.allOf( hasEntry(equalTo("type"), equalTo("invalidArguments")), hasEntry(equalTo("description"), equalTo("The mailbox 'my.Box' contains an illegal character: '.'"))))); } @Test public void setMailboxesShouldReturnNotUpdatedWhenNewParentDoesntExist() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String badParentId = getRemovedMailboxId().serialize(); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"parentId\" : \"" + badParentId + "\"" + " }" + " }" + @@ -1908,24 +1842,19 @@ public void setMailboxesShouldReturnNotUpdatedWhenNewParentDoesntExist() { .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".notUpdated", hasEntry(equalTo(mailboxId), Matchers.allOf( + .body(ARGUMENTS + ".notUpdated", hasEntry(equalTo(mailboxId.serialize()), Matchers.allOf( hasEntry(equalTo("type"), equalTo("notFound")), hasEntry(equalTo("description"), containsString(badParentId))))); } @Test public void setMailboxesShouldReturnNotUpdatedWhenUpdatingParentIdOfAParentMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "root"); - - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "root"); - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox.child"); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox.child"); + MailboxId newParentMailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); - Mailbox newParentMailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); - String newParentMailboxId = newParentMailbox.getMailboxId().serialize(); String requestBody = @@ -1933,8 +1862,8 @@ public void setMailboxesShouldReturnNotUpdatedWhenUpdatingParentIdOfAParentMailb " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + - " \"parentId\" : \"" + newParentMailboxId + "\"" + + " \"" + mailboxId.serialize() + "\" : {" + + " \"parentId\" : \"" + newParentMailboxId.serialize() + "\"" + " }" + " }" + " }," + @@ -1950,25 +1879,23 @@ public void setMailboxesShouldReturnNotUpdatedWhenUpdatingParentIdOfAParentMailb .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".notUpdated", hasEntry(equalTo(mailboxId), Matchers.allOf( + .body(ARGUMENTS + ".notUpdated", hasEntry(equalTo(mailboxId.serialize()), Matchers.allOf( hasEntry(equalTo("type"), equalTo("invalidArguments")), hasEntry(equalTo("description"), equalTo("Cannot update a parent mailbox."))))); } @Test public void setMailboxesShouldReturnNotUpdatedWhenRenamingAMailboxToAnAlreadyExistingMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "mySecondBox"); + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mySecondBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"name\" : \"mySecondBox\"" + " }" + " }" + @@ -1985,25 +1912,22 @@ public void setMailboxesShouldReturnNotUpdatedWhenRenamingAMailboxToAnAlreadyExi .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".notUpdated", hasEntry(equalTo(mailboxId), Matchers.allOf( + .body(ARGUMENTS + ".notUpdated", hasEntry(equalTo(mailboxId.serialize()), Matchers.allOf( hasEntry(equalTo("type"), equalTo("invalidArguments")), hasEntry(equalTo("description"), equalTo("Cannot rename a mailbox to an already existing mailbox."))))); } @Test public void setMailboxesShouldReturnUpdatedWhenRenamingAChildMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "root"); - - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "root"); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"name\" : \"mySecondBox\"" + " }" + " }" + @@ -2020,23 +1944,20 @@ public void setMailboxesShouldReturnUpdatedWhenRenamingAChildMailbox() { .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".updated", contains(mailboxId)); + .body(ARGUMENTS + ".updated", contains(mailboxId.serialize())); } @Test public void setMailboxesShouldUpdateMailboxNameWhenRenamingAChildMailbox() { - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "root"); - - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); - String mailboxId = mailbox.getMailboxId().serialize(); + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "root"); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxId + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"name\" : \"mySecondBox\"" + " }" + " }" + @@ -2052,7 +1973,7 @@ public void setMailboxesShouldUpdateMailboxNameWhenRenamingAChildMailbox() { given() .header("Authorization", accessToken.serialize()) - .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId + "\"]}, \"#0\"]]") + .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() + "\"]}, \"#0\"]]") .when() .post("/jmap") .then() @@ -2064,8 +1985,7 @@ public void setMailboxesShouldUpdateMailboxNameWhenRenamingAChildMailbox() { @Test public void setMailboxesShouldReturnNotUpdatedWhenRenamingSystemMailbox() { - - Mailbox mailbox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX); + Mailbox mailbox = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = @@ -2097,17 +2017,14 @@ public void setMailboxesShouldReturnNotUpdatedWhenRenamingSystemMailbox() { @Test public void setMailboxesShouldReturnNotUpdatedWhenRenameToSystemMailboxName() { - - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - Mailbox mailboxMyBox = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); - String mailboxIdMyBox = mailboxMyBox.getMailboxId().serialize(); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxIdMyBox + "\" : {" + + " \"" + mailboxId.serialize() + "\" : {" + " \"name\" : \"outbox\"" + " }" + " }" + @@ -2124,32 +2041,25 @@ public void setMailboxesShouldReturnNotUpdatedWhenRenameToSystemMailboxName() { .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".notUpdated", hasEntry(equalTo(mailboxIdMyBox), Matchers.allOf( + .body(ARGUMENTS + ".notUpdated", hasEntry(equalTo(mailboxId.serialize()), Matchers.allOf( hasEntry(equalTo("type"), equalTo("invalidArguments")), hasEntry(equalTo("description"), equalTo("The mailbox 'outbox' is a system mailbox."))))); } @Test public void setMailboxesShouldReturnNotUpdatedErrorWhenMovingMailboxTriggersNameConflict() { - - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "A"); - Mailbox mailboxRootA = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "A"); - String mailboxRootAId = mailboxRootA.getMailboxId().serialize(); - - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "A.B"); - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "A.C"); - - jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "A.B.C"); - Mailbox mailboxChildToMoveC = jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, username, "A.B.C"); - String mailboxChildToMoveCId = mailboxChildToMoveC.getMailboxId().serialize(); + MailboxId mailboxRootAId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "A"); + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "A.B"); + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "A.C"); + MailboxId mailboxChildToMoveCId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "A.B.C"); String requestBody = "[" + " [ \"setMailboxes\"," + " {" + " \"update\": {" + - " \"" + mailboxChildToMoveCId + "\" : {" + - " \"parentId\" : \"" + mailboxRootAId + "\"" + + " \"" + mailboxChildToMoveCId.serialize() + "\" : {" + + " \"parentId\" : \"" + mailboxRootAId.serialize() + "\"" + " }" + " }" + " }," + @@ -2165,7 +2075,7 @@ public void setMailboxesShouldReturnNotUpdatedErrorWhenMovingMailboxTriggersName .then() .statusCode(200) .body(NAME, equalTo("mailboxesSet")) - .body(ARGUMENTS + ".notUpdated", hasEntry(equalTo(mailboxChildToMoveCId), Matchers.allOf( + .body(ARGUMENTS + ".notUpdated", hasEntry(equalTo(mailboxChildToMoveCId.serialize()), Matchers.allOf( hasEntry(equalTo("type"), equalTo("invalidArguments")), hasEntry(equalTo("description"), equalTo("Cannot rename a mailbox to an already existing mailbox."))))); } diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java index 06e2ceccda9..ebed0a412c4 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java @@ -67,11 +67,11 @@ import org.apache.james.mailbox.model.Attachment; import org.apache.james.mailbox.model.ComposedMessageId; import org.apache.james.mailbox.model.MailboxConstants; +import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.MessageId; import org.apache.james.mailbox.model.MessageResult; import org.apache.james.mailbox.store.event.EventFactory; -import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.probe.MailboxProbe; import org.apache.james.modules.MailboxProbeImpl; import org.apache.james.probe.DataProbe; @@ -1956,8 +1956,7 @@ public void setMessagesWhenSavingToDraftsShouldNotSendMessage() throws Exception @Test public void setMessagesWhenSavingToRegularMailboxShouldNotSendMessage() throws Exception { String sender = USERNAME; - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, sender, "regular"); - Mailbox regularMailbox = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, sender, "regular"); + MailboxId mailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, sender, "regular"); String recipientAddress = "recipient" + "@" + USERS_DOMAIN; String recipientPassword = "password"; dataProbe.addUser(recipientAddress, recipientPassword); @@ -1975,7 +1974,7 @@ public void setMessagesWhenSavingToRegularMailboxShouldNotSendMessage() throws E " \"cc\": [{ \"name\": \"ALICE\"}]," + " \"subject\": \"Thank you for joining example.com!\"," + " \"textBody\": \"Hello someone, and thank you for joining example.com!\"," + - " \"mailboxIds\": [\"" + regularMailbox.getMailboxId().serialize() + "\"]" + + " \"mailboxIds\": [\"" + mailboxId.serialize() + "\"]" + " }}" + " }," + " \"#0\"" + @@ -2108,9 +2107,7 @@ public void mailboxIdsShouldReturnUpdatedWhenNoChange() throws Exception { @Test public void mailboxIdsShouldBeInDestinationWhenUsingForMove() throws Exception { String newMailboxName = "heartFolder"; - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); - Mailbox heartFolder = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); - String heartFolderId = heartFolder.getMailboxId().serialize(); + String heartFolderId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName).serialize(); ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); ComposedMessageId message = mailboxProbe.appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), @@ -2154,9 +2151,7 @@ public void mailboxIdsShouldBeInDestinationWhenUsingForMove() throws Exception { public void mailboxIdsShouldBeInDestinationWhenUsingForMoveWithoutTrashFolder() throws Exception { mailboxProbe.deleteMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, DefaultMailboxes.TRASH); String newMailboxName = "heartFolder"; - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); - Mailbox heartFolder = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); - String heartFolderId = heartFolder.getMailboxId().serialize(); + String heartFolderId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName).serialize(); ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); ComposedMessageId message = mailboxProbe.appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), @@ -2198,9 +2193,7 @@ public void mailboxIdsShouldBeInDestinationWhenUsingForMoveWithoutTrashFolder() @Test public void mailboxIdsShouldNotBeAnymoreInSourceWhenUsingForMove() throws Exception { String newMailboxName = "heartFolder"; - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); - Mailbox heartFolder = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); - String heartFolderId = heartFolder.getMailboxId().serialize(); + String heartFolderId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName).serialize(); ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); ComposedMessageId message = mailboxProbe.appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), @@ -2243,9 +2236,7 @@ public void mailboxIdsShouldNotBeAnymoreInSourceWhenUsingForMove() throws Except @Test public void mailboxIdsShouldBeInBothMailboxWhenUsingForCopy() throws Exception { String newMailboxName = "heartFolder"; - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); - Mailbox heartFolder = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); - String heartFolderId = heartFolder.getMailboxId().serialize(); + String heartFolderId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName).serialize(); ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); ComposedMessageId message = mailboxProbe.appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), @@ -2402,9 +2393,7 @@ public void mailboxIdsShouldReturnErrorWhenSetToEmpty() throws Exception { @Test public void updateShouldNotReturnErrorWithFlagsAndMailboxUpdate() throws Exception { String newMailboxName = "heartFolder"; - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); - Mailbox heartFolder = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); - String heartFolderId = heartFolder.getMailboxId().serialize(); + String heartFolderId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName).serialize(); ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); ComposedMessageId message = mailboxProbe.appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), @@ -2437,9 +2426,7 @@ public void updateShouldNotReturnErrorWithFlagsAndMailboxUpdate() throws Excepti @Test public void updateShouldWorkWithFlagsAndMailboxUpdate() throws Exception { String newMailboxName = "heartFolder"; - mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); - Mailbox heartFolder = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); - String heartFolderId = heartFolder.getMailboxId().serialize(); + String heartFolderId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName).serialize(); ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); ComposedMessageId message = mailboxProbe.appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/DownloadStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/DownloadStepdefs.java index c872e53aa0a..d619806b274 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/DownloadStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/DownloadStepdefs.java @@ -46,7 +46,6 @@ import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.MessageId; import org.apache.james.mime4j.codec.DecoderUtil; -import org.apache.james.modules.MailboxProbeImpl; import com.google.common.base.CharMatcher; import com.google.common.base.Charsets; @@ -96,7 +95,7 @@ private DownloadStepdefs(MainStepdefs mainStepdefs, UserStepdefs userStepdefs, G public void appendMessageToMailbox(String user, String mailbox, String messageId) throws Throwable { MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, user, mailbox); - ComposedMessageId composedMessageId = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(user, mailboxPath, + ComposedMessageId composedMessageId = mainStepdefs.mailboxProbe.appendMessage(user, mailboxPath, ClassLoader.getSystemResourceAsStream("eml/oneAttachment.eml"), new Date(), false, new Flags()); inputToMessageId.put(messageId, composedMessageId.getMessageId()); @@ -106,7 +105,7 @@ public void appendMessageToMailbox(String user, String mailbox, String messageId public void appendMessageWithAttachmentToMailbox(String user, String mailbox, String messageId, String attachmentId) throws Throwable { MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, user, mailbox); - mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(user, mailboxPath, + mainStepdefs.mailboxProbe.appendMessage(user, mailboxPath, ClassLoader.getSystemResourceAsStream("eml/oneAttachment.eml"), new Date(), false, new Flags()); attachmentsByMessageId.put(messageId, attachmentId); @@ -117,7 +116,7 @@ public void appendMessageWithAttachmentToMailbox(String user, String mailbox, St public void appendMessageWithInlinedAttachmentToMailbox(String user, String mailbox, String messageId, String attachmentId) throws Throwable { MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, user, mailbox); - mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(user, mailboxPath, + mainStepdefs.mailboxProbe.appendMessage(user, mailboxPath, ClassLoader.getSystemResourceAsStream("eml/oneInlinedImage.eml"), new Date(), false, new Flags()); attachmentsByMessageId.put(messageId, attachmentId); @@ -127,7 +126,7 @@ public void appendMessageWithInlinedAttachmentToMailbox(String user, String mail public void appendMessageWithSameInlinedAttachmentsToMailbox(String user, String mailbox, String messageName, String attachmentId) throws Throwable { MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, user, mailbox); - mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(user, mailboxPath, + mainStepdefs.mailboxProbe.appendMessage(user, mailboxPath, ClassLoader.getSystemResourceAsStream("eml/sameInlinedImages.eml"), new Date(), false, new Flags()); attachmentsByMessageId.put(messageName, attachmentId); @@ -342,7 +341,7 @@ public void getDownloadWithExpiredToken(String username, String attachmentId) th @When("^\"([^\"]*)\" delete mailbox \"([^\"]*)\"$") public void deleteMailboxButNotAttachment(String username, String mailboxName) throws Exception { - mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).deleteMailbox(MailboxConstants.USER_NAMESPACE, username, mailboxName); + mainStepdefs.mailboxProbe.deleteMailbox(MailboxConstants.USER_NAMESPACE, username, mailboxName); } @Then("^the user should be authorized$") diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java index f7adb27fccd..1c3da936278 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java @@ -104,8 +104,8 @@ public MessageId getMessageId(String name) { @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" and \"([^\"]*)\" mailboxes with subject \"([^\"]*)\", content \"([^\"]*)\"$") public void appendMessageInTwoMailboxes(String messageName, String mailbox1, String mailbox2, String subject, String content) throws Exception { MessageId id = appendMessage(mailbox1, ContentType.noContentType(), subject, content, NO_HEADERS); - MailboxId mailboxId1 = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox1).getMailboxId(); - MailboxId mailboxId2 = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox2).getMailboxId(); + MailboxId mailboxId1 = mainStepdefs.mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox1).getMailboxId(); + MailboxId mailboxId2 = mainStepdefs.mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox2).getMailboxId(); mainStepdefs.jmapServer.getProbe(JmapGuiceProbe.class).setInMailboxes(id, userStepdefs.lastConnectedUser, mailboxId1, mailboxId2); messageIdsByName.put(messageName, id); @@ -138,7 +138,7 @@ public void appendMessage(String messageName, String mailbox, String subject, St @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox, composed of a multipart with inlined text part and inlined html part$") public void appendMessageFromFileInlinedMultipart(String messageName, String mailbox) throws Exception { ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); - MessageId id = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(userStepdefs.lastConnectedUser, + MessageId id = mainStepdefs.mailboxProbe.appendMessage(userStepdefs.lastConnectedUser, new MailboxPath(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox), ClassLoader.getSystemResourceAsStream("eml/inlinedMultipart.eml"), Date.from(dateTime.toInstant()), false, new Flags()) @@ -148,7 +148,7 @@ public void appendMessageFromFileInlinedMultipart(String messageName, String mai private MessageId appendMessage(String mailbox, ContentType contentType, String subject, String content, Optional> headers) throws Exception { ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); - return mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(userStepdefs.lastConnectedUser, + return mainStepdefs.mailboxProbe.appendMessage(userStepdefs.lastConnectedUser, new MailboxPath(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox), new ByteArrayInputStream(message(contentType, subject, content, headers).getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags()).getMessageId(); @@ -258,7 +258,7 @@ public void appendMessageWithFlags(String messageName, String mailbox, List {}; public MessageId.Factory messageIdFactory; public void init() throws Exception { jmapServer.start(); + dataProbe = jmapServer.getProbe(DataProbeImpl.class); + mailboxProbe = jmapServer.getProbe(MailboxProbeImpl.class); } diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java index 39b7e3f977b..6e7ee4c2d99 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java @@ -36,7 +36,6 @@ import org.apache.james.mailbox.model.MailboxConstants; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.store.mail.model.Mailbox; -import org.apache.james.modules.MailboxProbeImpl; import com.github.fge.lambdas.Throwing; import com.jayway.awaitility.Awaitility; @@ -66,7 +65,7 @@ private SetMailboxesMethodStepdefs(MainStepdefs mainStepdefs, UserStepdefs userS @Given("^mailbox \"([^\"]*)\" with (\\d+) messages$") public void mailboxWithMessages(String mailboxName, int messageCount) throws Throwable { - mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).createMailbox("#private", userStepdefs.lastConnectedUser, mailboxName); + mainStepdefs.mailboxProbe.createMailbox("#private", userStepdefs.lastConnectedUser, mailboxName); MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailboxName); IntStream .range(0, messageCount) @@ -77,14 +76,14 @@ public void mailboxWithMessages(String mailboxName, int messageCount) throws Thr private void appendMessage(MailboxPath mailboxPath, int i) throws MailboxException { String content = "Subject: test" + i + "\r\n\r\n" + "testBody" + i; - mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(userStepdefs.lastConnectedUser, mailboxPath, + mainStepdefs.mailboxProbe.appendMessage(userStepdefs.lastConnectedUser, mailboxPath, new ByteArrayInputStream(content.getBytes()), new Date(), false, new Flags()); } @When("^renaming mailbox \"([^\"]*)\" to \"([^\"]*)\"") public void renamingMailbox(String actualMailboxName, String newMailboxName) throws Throwable { String username = userStepdefs.lastConnectedUser; - Mailbox mailbox = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).getMailbox("#private", userStepdefs.lastConnectedUser, actualMailboxName); + Mailbox mailbox = mainStepdefs.mailboxProbe.getMailbox("#private", userStepdefs.lastConnectedUser, actualMailboxName); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = "[" + @@ -109,9 +108,9 @@ public void renamingMailbox(String actualMailboxName, String newMailboxName) thr @When("^moving mailbox \"([^\"]*)\" to \"([^\"]*)\"$") public void movingMailbox(String actualMailboxPath, String newParentMailboxPath) throws Throwable { String username = userStepdefs.lastConnectedUser; - Mailbox mailbox = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).getMailbox("#private", username, actualMailboxPath); + Mailbox mailbox = mainStepdefs.mailboxProbe.getMailbox("#private", username, actualMailboxPath); String mailboxId = mailbox.getMailboxId().serialize(); - Mailbox parent = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).getMailbox("#private", username, newParentMailboxPath); + Mailbox parent = mainStepdefs.mailboxProbe.getMailbox("#private", username, newParentMailboxPath); String parentId = parent.getMailboxId().serialize(); String requestBody = @@ -139,7 +138,7 @@ public void movingMailbox(String actualMailboxPath, String newParentMailboxPath) public void mailboxContainsMessages(String mailboxName, int messageCount) throws Throwable { Duration slowPacedPollInterval = Duration.FIVE_HUNDRED_MILLISECONDS; String username = userStepdefs.lastConnectedUser; - Mailbox mailbox = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).getMailbox("#private", username, mailboxName); + Mailbox mailbox = mainStepdefs.mailboxProbe.getMailbox("#private", username, mailboxName); String mailboxId = mailbox.getMailboxId().serialize(); Awaitility.await().atMost(Duration.FIVE_SECONDS).pollDelay(slowPacedPollInterval).pollInterval(slowPacedPollInterval).until(() -> { diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java index fb0aff4745f..0316f80285b 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java @@ -30,8 +30,6 @@ import org.apache.james.jmap.HttpJmapAuthentication; import org.apache.james.jmap.api.access.AccessToken; import org.apache.james.mailbox.model.MailboxConstants; -import org.apache.james.modules.MailboxProbeImpl; -import org.apache.james.utils.DataProbeImpl; import com.github.fge.lambdas.Throwing; import com.google.common.base.Charsets; @@ -62,7 +60,7 @@ private UserStepdefs(MainStepdefs mainStepdefs) { @Given("^a domain named \"([^\"]*)\"$") public void createDomain(String domain) throws Exception { - mainStepdefs.jmapServer.getProbe(DataProbeImpl.class).addDomain(domain); + mainStepdefs.dataProbe.addDomain(domain); domains.add(domain); } @@ -80,7 +78,7 @@ private String unquote(String quotedString) { @Given("^a user \"([^\"]*)\"$") public void createUser(String username) throws Exception { String password = generatePassword(username); - mainStepdefs.jmapServer.getProbe(DataProbeImpl.class).addUser(username, password); + mainStepdefs.dataProbe.addUser(username, password); passwordByUser.put(username, password); } @@ -92,7 +90,7 @@ public void createConnectedUser(String username) throws Throwable { @Given("^\"([^\"]*)\" has a mailbox \"([^\"]*)\"$") public void createMailbox(String username, String mailbox) throws Throwable { - mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, mailbox); + mainStepdefs.mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, mailbox); }