You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/05/09 10:28:32 UTC

[james-project] 07/14: JAMES-2712 Extract ExportRequest object

This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 7d594be3524df454a0472c6bf9abb3b3db2042cc
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Fri Apr 26 16:21:55 2019 +0700

    JAMES-2712 Extract ExportRequest object
---
 .../java/org/apache/james/jmap/ExportRequest.java  | 62 ++++++++++++++++++++++
 .../integration/DeletedMessagesVaultTest.java      | 38 ++-----------
 2 files changed, 66 insertions(+), 34 deletions(-)

diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ExportRequest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ExportRequest.java
new file mode 100644
index 0000000..328701e
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ExportRequest.java
@@ -0,0 +1,62 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.jmap;
+
+public class ExportRequest {
+
+    public static class Builder {
+
+        @FunctionalInterface
+        public interface RequireSharee {
+            RequireMatchingQuery exportTo(String sharee);
+        }
+
+        @FunctionalInterface
+        public interface RequireMatchingQuery {
+            ExportRequest query(String query);
+        }
+    }
+
+    public static Builder.RequireSharee userExportFrom(String userExportFrom) {
+        return sharee -> query -> new ExportRequest(userExportFrom, sharee, query);
+    }
+
+    private final String userExportFrom;
+    private final String sharee;
+    private final String matchingQuery;
+
+    private ExportRequest(String userExportFrom, String sharee, String matchingQuery) {
+        this.userExportFrom = userExportFrom;
+        this.sharee = sharee;
+        this.matchingQuery = matchingQuery;
+    }
+
+    public String getUserExportFrom() {
+        return userExportFrom;
+    }
+
+    public String getSharee() {
+        return sharee;
+    }
+
+    public String getMatchingQuery() {
+        return matchingQuery;
+    }
+}
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/DeletedMessagesVaultTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/DeletedMessagesVaultTest.java
index 8bf523f..a979a5e 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/DeletedMessagesVaultTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/DeletedMessagesVaultTest.java
@@ -48,6 +48,7 @@ import java.util.stream.Collectors;
 
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.jmap.ExportRequest;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.jmap.categories.BasicFeature;
 import org.apache.james.mailbox.DefaultMailboxes;
@@ -83,37 +84,6 @@ import io.restassured.parsing.Parser;
 import io.restassured.specification.RequestSpecification;
 
 public abstract class DeletedMessagesVaultTest {
-
-    private static class ExportRequest {
-
-        private static class Builder {
-
-            @FunctionalInterface
-            interface RequireSharee {
-                RequireMatchingQuery exportTo(String sharee);
-            }
-
-            @FunctionalInterface
-            interface RequireMatchingQuery {
-                ExportRequest query(String query);
-            }
-        }
-
-        private static Builder.RequireSharee userExportFrom(String userExportFrom) {
-            return sharee -> query -> new ExportRequest(userExportFrom, sharee, query);
-        }
-
-        private final String userExportFrom;
-        private final String sharee;
-        private final String matchingQuery;
-
-        private ExportRequest(String userExportFrom, String sharee, String matchingQuery) {
-            this.userExportFrom = userExportFrom;
-            this.sharee = sharee;
-            this.matchingQuery = matchingQuery;
-        }
-    }
-
     private static final Instant NOW = Instant.now();
     private static final Instant ONE_DAY_AFTER_ONE_YEAR_EXPIRATION = NOW.plus(366, ChronoUnit.DAYS);
     private static final String FIRST_SUBJECT = "first subject";
@@ -895,9 +865,9 @@ public abstract class DeletedMessagesVaultTest {
         String taskId =
             webAdminApi.with()
                 .queryParam("action", "export")
-                .queryParam("exportTo", exportRequest.sharee)
-                .body(exportRequest.matchingQuery)
-                .post("/deletedMessages/users/" + exportRequest.userExportFrom)
+                .queryParam("exportTo", exportRequest.getSharee())
+                .body(exportRequest.getMatchingQuery())
+                .post("/deletedMessages/users/" + exportRequest.getUserExportFrom())
             .jsonPath()
                 .get("taskId");
 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org