JAMES-2169 rely on createMailbox return, don't call getMailbox

Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/94b2fa54
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/94b2fa54
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/94b2fa54

Branch: refs/heads/master
Commit: 94b2fa54c65501f6bf2b5d8e166cfc9266c41a5b
Parents: f5f12d2
Author: Matthieu Baechler <[email protected]>
Authored: Wed Sep 27 12:12:54 2017 +0200
Committer: benwa <[email protected]>
Committed: Tue Oct 3 09:23:48 2017 +0700

----------------------------------------------------------------------
 .../integration/GetMailboxesMethodTest.java     | 51 +++++++-------------
 1 file changed, 17 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/94b2fa54/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
index 478e4b7..aea2d61 100644
--- 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
@@ -139,8 +139,7 @@ public abstract class GetMailboxesMethodTest {
     @Test
     public void getMailboxesShouldReturnEmptyWhenIdsDoesntMatch() throws 
Exception {
         mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
"name");
-        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
"quicklyRemoved");
-        String removedId = 
mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, alice, 
"quicklyRemoved").getMailboxId().serialize();
+        String removedId = 
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
"quicklyRemoved").serialize();
         mailboxProbe.deleteMailbox(MailboxConstants.USER_NAMESPACE, alice, 
"quicklyRemoved");
 
         given()
@@ -169,14 +168,8 @@ public abstract class GetMailboxesMethodTest {
 
     @Test
     public void getMailboxesShouldReturnMailboxesWhenIdsMatch() throws 
Exception {
-        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
DefaultMailboxes.INBOX);
-        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
"myMailbox");
-
-        Mailbox mailbox = 
mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, alice, 
DefaultMailboxes.INBOX);
-        Mailbox mailbox2 = 
mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, alice, "myMailbox");
-
-        String mailboxId = mailbox.getMailboxId().serialize();
-        String mailboxId2 = mailbox2.getMailboxId().serialize();
+        String mailboxId = 
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
DefaultMailboxes.INBOX).serialize();
+        String mailboxId2 = 
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
"myMailbox").serialize();
 
         given()
             .header("Authorization", accessToken.serialize())
@@ -193,13 +186,9 @@ public abstract class GetMailboxesMethodTest {
 
     @Test
     public void getMailboxesShouldReturnOnlyMatchingMailboxesWhenIdsGiven() 
throws Exception {
-        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
DefaultMailboxes.INBOX);
+        String mailboxId = 
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
DefaultMailboxes.INBOX).serialize();
         mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
"myMailbox");
 
-        Mailbox mailbox = 
mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, alice, 
DefaultMailboxes.INBOX);
-
-        String mailboxId = mailbox.getMailboxId().serialize();
-
         given()
             .header("Authorization", accessToken.serialize())
             .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId + "\"]}, 
\"#0\"]]")
@@ -253,7 +242,7 @@ public abstract class GetMailboxesMethodTest {
     @Test
     public void getMailboxesShouldReturnSharedWithProperty() throws Exception {
         String mailboxName = "myMailbox";
-        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
mailboxName);
+        String myMailboxId = 
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
mailboxName).serialize();
         String targetUser1 = "[email protected]";
         String targetUser2 = "[email protected]";
         Mailbox myMailbox = 
mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, alice, mailboxName);
@@ -262,7 +251,7 @@ public abstract class GetMailboxesMethodTest {
 
         given()
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMailboxes\", {\"ids\": [\"" + 
myMailbox.getMailboxId().serialize() + "\"]}, \"#0\"]]")
+            .body("[[\"getMailboxes\", {\"ids\": [\"" + myMailboxId + "\"]}, 
\"#0\"]]")
         .when()
             .post("/jmap")
         .then()
@@ -276,12 +265,11 @@ public abstract class GetMailboxesMethodTest {
     @Test
     public void getMailboxShouldReturnEmptySharedWithWhenNoDelegation() throws 
Exception {
         String mailboxName = "myMailbox";
-        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
mailboxName);
-        Mailbox myMailbox = 
mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, alice, mailboxName);
+        String myMailboxId = 
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
mailboxName).serialize();
 
         given()
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMailboxes\", {\"ids\": [\"" + 
myMailbox.getMailboxId().serialize() + "\"]}, \"#0\"]]")
+            .body("[[\"getMailboxes\", {\"ids\": [\"" + myMailboxId + "\"]}, 
\"#0\"]]")
         .when()
             .post("/jmap")
         .then()
@@ -294,14 +282,14 @@ public abstract class GetMailboxesMethodTest {
     @Test
     public void nonHandledRightsShouldBeFilteredOut() throws Exception {
         String mailboxName = "myMailbox";
-        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
mailboxName);
+        String myMailboxId = 
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
mailboxName).serialize();
         String targetUser1 = "[email protected]";
         Mailbox myMailbox = 
mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, alice, mailboxName);
         aclProbe.replaceRights(myMailbox.generateAssociatedPath(), 
targetUser1, new Rfc4314Rights(Right.Read, Right.Post));
 
         given()
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMailboxes\", {\"ids\": [\"" + 
myMailbox.getMailboxId().serialize() + "\"]}, \"#0\"]]")
+            .body("[[\"getMailboxes\", {\"ids\": [\"" + myMailboxId + "\"]}, 
\"#0\"]]")
         .when()
             .post("/jmap")
         .then()
@@ -385,15 +373,14 @@ public abstract class GetMailboxesMethodTest {
 
     @Test
     public void getMailboxesShouldReturnMailboxPropertiesWhenAvailable() 
throws Exception {
-        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
"name");
+        String myMailboxId = 
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
"name").serialize();
 
         mailboxProbe.appendMessage(alice, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, alice, "name"),
                 new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
 
-        MailboxId mailboxId = 
mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, alice, 
"name").getMailboxId();
         given()
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() 
+ "\"]}, \"#0\"]]")
+            .body("[[\"getMailboxes\", {\"ids\": [\"" + myMailboxId + "\"]}, 
\"#0\"]]")
         .when()
             .post("/jmap")
         .then()
@@ -417,12 +404,11 @@ public abstract class GetMailboxesMethodTest {
 
     @Test
     public void 
getMailboxesShouldReturnFilteredMailboxesPropertiesWhenRequestContainsFilterProperties()
 throws Exception {
-        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
"name");
+        String myMailboxId = 
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
"name").serialize();
 
-        MailboxId mailboxId = 
mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, alice, 
"name").getMailboxId();
         given()
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() 
+ "\"], \"properties\" : [\"unreadMessages\", \"sortOrder\"]}, \"#0\"]]")
+            .body("[[\"getMailboxes\", {\"ids\": [\"" + myMailboxId + "\"], 
\"properties\" : [\"unreadMessages\", \"sortOrder\"]}, \"#0\"]]")
         .when()
             .post("/jmap")
         .then()
@@ -479,11 +465,9 @@ public abstract class GetMailboxesMethodTest {
 
     @Test
     public void getMailboxesShouldReturnMailboxesWithSortOrder() throws 
Exception {
-        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
DefaultMailboxes.INBOX);
-        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
DefaultMailboxes.TRASH);
+        MailboxId inboxId = 
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
DefaultMailboxes.INBOX);
+        MailboxId trashId = 
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
DefaultMailboxes.TRASH);
 
-        MailboxId inboxId = 
mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, alice, 
DefaultMailboxes.INBOX).getMailboxId();
-        MailboxId trashId = 
mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, alice, 
DefaultMailboxes.TRASH).getMailboxId();
         given()
             .header("Authorization", accessToken.serialize())
             .body("[[\"getMailboxes\", {\"ids\": [\"" + inboxId.serialize() + 
"\", \"" + trashId.serialize() + "\"]}, \"#0\"]]")
@@ -501,9 +485,8 @@ public abstract class GetMailboxesMethodTest {
 
     @Test
     public void getMailboxesShouldReturnMailboxesWithRolesInLowerCase() throws 
Exception {
-        mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
DefaultMailboxes.OUTBOX);
+        MailboxId mailboxId = 
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, alice, 
DefaultMailboxes.OUTBOX);
 
-        MailboxId mailboxId = 
mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, alice, 
DefaultMailboxes.OUTBOX).getMailboxId();
         given()
             .header("Authorization", accessToken.serialize())
             .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() 
+ "\"]}, \"#0\"]]")


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

Reply via email to