JAMES-2143 Add an integration test getting a message then getting it has a eml 
file


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

Branch: refs/heads/master
Commit: acaf6c2d26b9ae76ee415243de992e060f2e53b4
Parents: 0024a0c
Author: Antoine Duprat <[email protected]>
Authored: Tue Sep 12 12:15:48 2017 +0200
Committer: Antoine Duprat <[email protected]>
Committed: Wed Sep 13 10:19:54 2017 +0200

----------------------------------------------------------------------
 .../integration/cucumber/DownloadStepdefs.java    | 18 +++++++++++++++---
 .../cucumber/GetMessagesMethodStepdefs.java       |  4 ++++
 .../test/resources/cucumber/DownloadGet.feature   |  9 ++++++++-
 3 files changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/acaf6c2d/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/DownloadStepdefs.java
----------------------------------------------------------------------
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 e34c45c..f3a0c4c 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
@@ -35,6 +35,7 @@ import javax.mail.Flags;
 import org.apache.commons.io.IOUtils;
 import org.apache.http.Header;
 import org.apache.http.HttpResponse;
+import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.fluent.Request;
 import org.apache.http.client.fluent.Response;
 import org.apache.http.client.utils.URIBuilder;
@@ -73,6 +74,7 @@ public class DownloadStepdefs {
 
     private final UserStepdefs userStepdefs;
     private final MainStepdefs mainStepdefs;
+    private final GetMessagesMethodStepdefs getMessagesMethodStepdefs;
     private HttpResponse response;
     private Multimap<String, String> attachmentsByMessageId;
     private Map<String, String> blobIdByAttachmentId;
@@ -80,9 +82,10 @@ public class DownloadStepdefs {
     private Map<AttachmentAccessTokenKey, AttachmentAccessToken> 
attachmentAccessTokens;
 
     @Inject
-    private DownloadStepdefs(MainStepdefs mainStepdefs, UserStepdefs 
userStepdefs) {
+    private DownloadStepdefs(MainStepdefs mainStepdefs, UserStepdefs 
userStepdefs, GetMessagesMethodStepdefs getMessagesMethodStepdefs) {
         this.mainStepdefs = mainStepdefs;
         this.userStepdefs = userStepdefs;
+        this.getMessagesMethodStepdefs = getMessagesMethodStepdefs;
         this.attachmentsByMessageId = ArrayListMultimap.create();
         this.blobIdByAttachmentId = new HashMap<>();
         this.attachmentAccessTokens = new HashMap<>();
@@ -150,8 +153,17 @@ public class DownloadStepdefs {
                 .map(MessageId::serialize)
                 .orElse(null));
 
-        URIBuilder uriBuilder = mainStepdefs.baseUri().setPath("/download/" + 
attachmentIdOrMessageId);
-        response = authenticatedDownloadRequest(uriBuilder, 
attachmentIdOrMessageId, username).execute().returnResponse();
+        downLoad(username, attachmentIdOrMessageId);
+    }
+
+    @When("^\"([^\"]*)\" downloads the message by its blobId$")
+    public void downloads(String username) throws Throwable {
+        downLoad(username, getMessagesMethodStepdefs.getBlobId());
+    }
+
+    private void downLoad(String username, String blobId) throws IOException, 
ClientProtocolException, URISyntaxException {
+        URIBuilder uriBuilder = mainStepdefs.baseUri().setPath("/download/" + 
blobId);
+        response = authenticatedDownloadRequest(uriBuilder, blobId, 
username).execute().returnResponse();
     }
 
     private Request authenticatedDownloadRequest(URIBuilder uriBuilder, String 
blobId, String username) throws URISyntaxException {

http://git-wip-us.apache.org/repos/asf/james-project/blob/acaf6c2d/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
----------------------------------------------------------------------
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 f42a071..f7adb27 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
@@ -533,4 +533,8 @@ public class GetMessagesMethodStepdefs {
         attachmentProperties.asList(TableRow.class)
             .forEach(entry -> assertThat(jsonPath.<Object>read(attachment + 
"." + entry.getKey())).isEqualTo(entry.getValue()));
     }
+
+    public String getBlobId() {
+        return jsonPath.<String>read(FIRST_MESSAGE + ".blobId");
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/acaf6c2d/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
index 3021f03..b450533 100644
--- 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
@@ -34,4 +34,11 @@ Feature: Download GET
     Given "[email protected]" mailbox "INBOX" contains a message "1"
     When "[email protected]" downloads "1"
     Then the user should receive that blob
-    And the blob size is 4963
\ No newline at end of file
+    And the blob size is 4963
+
+  Scenario: Getting a message then getting its blob
+    Given the user has a message "m1" in "INBOX" mailbox with subject "my test 
subject", content "testmail"
+    And the user ask for messages "m1"
+    When "[email protected]" downloads the message by its blobId
+    Then the user should receive that blob
+    And the blob size is 36
\ No newline at end of file


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

Reply via email to