james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [6/6] james-project git commit: JAMES-2195 rename HttpStepDef to HttpClient
Date Thu, 26 Oct 2017 22:59:13 GMT
JAMES-2195 rename HttpStepDef to HttpClient


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

Branch: refs/heads/master
Commit: 9ed94118890545a96bf1e99309f0a6e966fc1f90
Parents: 4c07214
Author: Matthieu Baechler <matthieu@apache.org>
Authored: Tue Oct 24 16:22:00 2017 +0200
Committer: Antoine Duprat <aduprat@linagora.com>
Committed: Fri Oct 27 00:56:22 2017 +0200

----------------------------------------------------------------------
 .../cucumber/GetMessageListMethodStepdefs.java  | 24 +++---
 .../cucumber/GetMessagesMethodStepdefs.java     | 90 ++++++++++----------
 .../integration/cucumber/HttpClient.java        | 56 ++++++++++++
 .../integration/cucumber/HttpStepDefs.java      | 56 ------------
 .../cucumber/SetMailboxesMethodStepdefs.java    | 16 ++--
 .../cucumber/SetMessagesMethodStepdefs.java     | 18 ++--
 6 files changed, 130 insertions(+), 130 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/9ed94118/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessageListMethodStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessageListMethodStepdefs.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessageListMethodStepdefs.java
index 930cc16..b5cbf9b 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessageListMethodStepdefs.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessageListMethodStepdefs.java
@@ -42,13 +42,13 @@ public class GetMessageListMethodStepdefs {
 
     private static final String ARGUMENTS = "[0][1]";
     private final MainStepdefs mainStepdefs;
-    private final HttpStepDefs httpStepDefs;
+    private final HttpClient httpClient;
     private final GetMessagesMethodStepdefs messagesMethodStepdefs;
 
     @Inject
-    private GetMessageListMethodStepdefs(MainStepdefs mainStepdefs, HttpStepDefs httpStepDefs,
GetMessagesMethodStepdefs messagesMethodStepdefs) {
+    private GetMessageListMethodStepdefs(MainStepdefs mainStepdefs, HttpClient httpClient,
GetMessagesMethodStepdefs messagesMethodStepdefs) {
         this.mainStepdefs = mainStepdefs;
-        this.httpStepDefs = httpStepDefs;
+        this.httpClient = httpClient;
         this.messagesMethodStepdefs = messagesMethodStepdefs;
     }
 
@@ -63,7 +63,7 @@ public class GetMessageListMethodStepdefs {
                     .serialize())
                 .collect(Guavate.toImmutableList()));
 
-        httpStepDefs.post(String.format(
+        httpClient.post(String.format(
                 "[[\"getMessageList\", {\"filter\":{" +
                 "    \"inMailboxes\":[\"%s\"]," +
                 "    \"hasKeyword\":\"%s\"" +
@@ -79,7 +79,7 @@ public class GetMessageListMethodStepdefs {
             .getMailbox(MailboxConstants.USER_NAMESPACE, username, mailbox)
             .getMailboxId();
 
-        httpStepDefs.post(String.format(
+        httpClient.post(String.format(
                 "[[\"getMessageList\", {\"filter\":{" +
                 "    \"inMailboxes\":[\"%s\"]," +
                 "    \"hasKeyword\":\"%s\"" +
@@ -90,7 +90,7 @@ public class GetMessageListMethodStepdefs {
 
     @When("^the user asks for message list with flag \"([^\"]*)\"$")
     public void getMessageList(String flag) throws Exception {
-        httpStepDefs.post(String.format(
+        httpClient.post(String.format(
             "[[\"getMessageList\", {\"filter\":{" +
                 "    \"hasKeyword\":\"%s\"" +
                 "}}, \"#0\"]]",
@@ -99,20 +99,20 @@ public class GetMessageListMethodStepdefs {
 
     @Then("^the message list is empty$")
     public void assertEmpty() throws Exception {
-        assertThat(httpStepDefs.response.getStatusLine().getStatusCode()).isEqualTo(200);
-        assertThat(httpStepDefs.jsonPath.<List<String>>read(ARGUMENTS + ".messageIds")).isEmpty();
+        assertThat(httpClient.response.getStatusLine().getStatusCode()).isEqualTo(200);
+        assertThat(httpClient.jsonPath.<List<String>>read(ARGUMENTS + ".messageIds")).isEmpty();
     }
 
     @Then("^the message list has size (\\d+)")
     public void assertSize(int size) throws Exception {
-        assertThat(httpStepDefs.response.getStatusLine().getStatusCode()).isEqualTo(200);
-        assertThat(httpStepDefs.jsonPath.<List<String>>read(ARGUMENTS + ".messageIds")).hasSize(size);
+        assertThat(httpClient.response.getStatusLine().getStatusCode()).isEqualTo(200);
+        assertThat(httpClient.jsonPath.<List<String>>read(ARGUMENTS + ".messageIds")).hasSize(size);
     }
 
     @Then("^the message list contains \"([^\"]*)\"")
     public void assertContains(String messsage) throws Exception {
         MessageId messageId = messagesMethodStepdefs.getMessageId(messsage);
-        assertThat(httpStepDefs.response.getStatusLine().getStatusCode()).isEqualTo(200);
-        assertThat(httpStepDefs.jsonPath.<List<String>>read(ARGUMENTS + ".messageIds")).contains(messageId.serialize());
+        assertThat(httpClient.response.getStatusLine().getStatusCode()).isEqualTo(200);
+        assertThat(httpClient.jsonPath.<List<String>>read(ARGUMENTS + ".messageIds")).contains(messageId.serialize());
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/9ed94118/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 8b62b85..5000ac4 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
@@ -77,17 +77,17 @@ public class GetMessagesMethodStepdefs {
 
     private final MainStepdefs mainStepdefs;
     private final UserStepdefs userStepdefs;
-    private final HttpStepDefs httpStepDefs;
+    private final HttpClient httpClient;
     private final Map<String, MessageId> messageIdsByName;
 
     private List<MessageId> requestedMessageIds;
 
     @Inject
     private GetMessagesMethodStepdefs(MainStepdefs mainStepdefs, UserStepdefs userStepdefs,
-                                      HttpStepDefs httpStepDefs) {
+                                      HttpClient httpClient) {
         this.mainStepdefs = mainStepdefs;
         this.userStepdefs = userStepdefs;
-        this.httpStepDefs = httpStepDefs;
+        this.httpClient = httpClient;
         this.messageIdsByName = new HashMap<>();
     }
 
@@ -393,7 +393,7 @@ public class GetMessagesMethodStepdefs {
 
     @When("^\the user ask for messages using its accountId$")
     public void postWithAccountId() throws Exception {
-        httpStepDefs.post("[[\"getMessages\", {\"accountId\": \"1\"}, \"#0\"]]");
+        httpClient.post("[[\"getMessages\", {\"accountId\": \"1\"}, \"#0\"]]");
     }
 
     @When("^\"([^\"]*)\" ask for messages using unknown arguments$")
@@ -403,12 +403,12 @@ public class GetMessagesMethodStepdefs {
 
     @When("^the user ask for messages using unknown arguments$")
     public void postWithUnknownArguments() throws Exception {
-        httpStepDefs.post("[[\"getMessages\", {\"WAT\": true}, \"#0\"]]");
+        httpClient.post("[[\"getMessages\", {\"WAT\": true}, \"#0\"]]");
     }
 
     @When("^the user ask for messages using invalid argument$")
     public void postWithInvalidArguments() throws Exception {
-        httpStepDefs.post("[[\"getMessages\", {\"ids\": null}, \"#0\"]]");
+        httpClient.post("[[\"getMessages\", {\"ids\": null}, \"#0\"]]");
     }
 
     @When("^\"([^\"]*)\" ask for messages using invalid argument$")
@@ -418,7 +418,7 @@ public class GetMessagesMethodStepdefs {
 
     @When("^the user ask for messages$")
     public void post() throws Exception {
-        httpStepDefs.post("[[\"getMessages\", {\"ids\": []}, \"#0\"]]");
+        httpClient.post("[[\"getMessages\", {\"ids\": []}, \"#0\"]]");
     }
 
     @When("^\"(.*?)\" ask for messages$")
@@ -455,7 +455,7 @@ public class GetMessagesMethodStepdefs {
             .map(MessageId::serialize)
             .map(toJsonString())
             .collect(Collectors.joining(",", "[", "]" ));
-        httpStepDefs.post("[[\"getMessages\", {\"ids\": " + serializedIds + "}, \"#0\"]]");
+        httpClient.post("[[\"getMessages\", {\"ids\": " + serializedIds + "}, \"#0\"]]");
     }
 
     private Function<? super String, ? extends String> toJsonString() {
@@ -482,7 +482,7 @@ public class GetMessagesMethodStepdefs {
             .map(toJsonString())
             .collect(Collectors.joining(",", "[", "]" ));
 
-        httpStepDefs.post("[[\"getMessages\", {\"ids\": " + serializedIds + ", \"properties\":
" + serializedProperties + "}, \"#0\"]]");
+        httpClient.post("[[\"getMessages\", {\"ids\": " + serializedIds + ", \"properties\":
" + serializedProperties + "}, \"#0\"]]");
     }
 
     private Pair<String, String> entryToPair(Map.Entry<String, String> entry)
{
@@ -495,53 +495,53 @@ public class GetMessagesMethodStepdefs {
 
     @Then("^an error \"([^\"]*)\" is returned$")
     public void error(String type) throws Exception {
-        assertThat(httpStepDefs.response.getStatusLine().getStatusCode()).isEqualTo(200);
-        assertThat(httpStepDefs.jsonPath.<String>read(NAME)).isEqualTo("error");
-        assertThat(httpStepDefs.jsonPath.<String>read(ARGUMENTS + ".type")).isEqualTo(type);
+        assertThat(httpClient.response.getStatusLine().getStatusCode()).isEqualTo(200);
+        assertThat(httpClient.jsonPath.<String>read(NAME)).isEqualTo("error");
+        assertThat(httpClient.jsonPath.<String>read(ARGUMENTS + ".type")).isEqualTo(type);
     }
 
     @Then("^no error is returned$")
     public void noError() throws Exception {
-        assertThat(httpStepDefs.response.getStatusLine().getStatusCode()).isEqualTo(200);
-        assertThat(httpStepDefs.jsonPath.<String>read(NAME)).isEqualTo("messages");
+        assertThat(httpClient.response.getStatusLine().getStatusCode()).isEqualTo(200);
+        assertThat(httpClient.jsonPath.<String>read(NAME)).isEqualTo("messages");
     }
 
     @Then("^the list of unknown messages is empty$")
     public void assertNotFoundIsEmpty() {
-        assertThat(httpStepDefs.jsonPath.<List<String>>read(ARGUMENTS + ".notFound")).isEmpty();
+        assertThat(httpClient.jsonPath.<List<String>>read(ARGUMENTS + ".notFound")).isEmpty();
     }
 
     @Then("^the list of messages is empty$")
     public void assertListIsEmpty() {
-        assertThat(httpStepDefs.jsonPath.<List<String>>read(ARGUMENTS + ".list")).isEmpty();
+        assertThat(httpClient.jsonPath.<List<String>>read(ARGUMENTS + ".list")).isEmpty();
     }
 
     @Then("^the description is \"(.*?)\"$")
     public void assertDescription(String description) throws Exception {
-        assertThat(httpStepDefs.jsonPath.<String>read(ARGUMENTS + ".description")).isEqualTo(description);
+        assertThat(httpClient.jsonPath.<String>read(ARGUMENTS + ".description")).isEqualTo(description);
     }
 
     @Then("^the notFound list should contain \"([^\"]*)\"$")
     public void assertNotFoundListContains(String ids) throws Exception {
-        assertThat(httpStepDefs.jsonPath.<List<String>>read(ARGUMENTS + ".notFound")).contains(ids);
+        assertThat(httpClient.jsonPath.<List<String>>read(ARGUMENTS + ".notFound")).contains(ids);
     }
 
     @Then("^the notFound list should contain the requested message id$")
     public void assertNotFoundListContainsRequestedMessages() throws Exception {
         ImmutableList<String> elements = requestedMessageIds.stream().map(MessageId::serialize).collect(Guavate.toImmutableList());
-        assertThat(httpStepDefs.jsonPath.<List<String>>read(ARGUMENTS + ".notFound")).containsExactlyElementsOf(elements);
+        assertThat(httpClient.jsonPath.<List<String>>read(ARGUMENTS + ".notFound")).containsExactlyElementsOf(elements);
     }
 
 
     @Then("^the list should contain (\\d+) message$")
     public void assertListContains(int numberOfMessages) throws Exception {
-        assertThat(httpStepDefs.jsonPath.<List<String>>read(ARGUMENTS + ".list")).hasSize(numberOfMessages);
+        assertThat(httpClient.jsonPath.<List<String>>read(ARGUMENTS + ".list")).hasSize(numberOfMessages);
     }
 
     @Then("^the id of the message is \"([^\"]*)\"$")
     public void assertIdOfTheFirstMessage(String messageName) throws Exception {
         MessageId id = messageIdsByName.get(messageName);
-        assertThat(httpStepDefs.jsonPath.<String>read(FIRST_MESSAGE + ".id")).isEqualTo(id.serialize());
+        assertThat(httpClient.jsonPath.<String>read(FIRST_MESSAGE + ".id")).isEqualTo(id.serialize());
     }
 
     @Then("^the message is in \"([^\"]*)\" mailboxes")
@@ -555,7 +555,7 @@ public class GetMessagesMethodStepdefs {
                 .serialize()))
             .distinct()
             .collect(Guavate.toImmutableList());
-        assertThat(httpStepDefs.jsonPath.<JSONArray>read(FIRST_MESSAGE + ".mailboxIds"))
+        assertThat(httpClient.jsonPath.<JSONArray>read(FIRST_MESSAGE + ".mailboxIds"))
             .hasSize(values.size())
             .containsOnlyElementsOf(values);
     }
@@ -572,7 +572,7 @@ public class GetMessagesMethodStepdefs {
                 .serialize()))
             .distinct()
             .collect(Guavate.toImmutableList());
-        assertThat(httpStepDefs.jsonPath.<JSONArray>read(FIRST_MESSAGE + ".mailboxIds"))
+        assertThat(httpClient.jsonPath.<JSONArray>read(FIRST_MESSAGE + ".mailboxIds"))
             .hasSize(values.size())
             .containsOnlyElementsOf(values);
     }
@@ -580,44 +580,44 @@ public class GetMessagesMethodStepdefs {
     @Then("^the threadId of the message is \"([^\"]*)\"$")
     public void assertThreadIdOfTheFirstMessage(String threadId) throws Exception {
         MessageId id = messageIdsByName.get(threadId);
-        assertThat(httpStepDefs.jsonPath.<String>read(FIRST_MESSAGE + ".threadId")).isEqualTo(id.serialize());
+        assertThat(httpClient.jsonPath.<String>read(FIRST_MESSAGE + ".threadId")).isEqualTo(id.serialize());
     }
 
     @Then("^the subject of the message is \"([^\"]*)\"$")
     public void assertSubjectOfTheFirstMessage(String subject) throws Exception {
-        assertThat(httpStepDefs.jsonPath.<String>read(FIRST_MESSAGE + ".subject")).isEqualTo(subject);
+        assertThat(httpClient.jsonPath.<String>read(FIRST_MESSAGE + ".subject")).isEqualTo(subject);
     }
 
     @Then("^the textBody of the message is \"([^\"]*)\"$")
     public void assertTextBodyOfTheFirstMessage(String textBody) throws Exception {
-        assertThat(httpStepDefs.jsonPath.<String>read(FIRST_MESSAGE + ".textBody")).isEqualTo(StringEscapeUtils.unescapeJava(textBody));
+        assertThat(httpClient.jsonPath.<String>read(FIRST_MESSAGE + ".textBody")).isEqualTo(StringEscapeUtils.unescapeJava(textBody));
     }
 
     @Then("^the htmlBody of the message is \"([^\"]*)\"$")
     public void assertHtmlBodyOfTheFirstMessage(String htmlBody) throws Exception {
-        assertThat(httpStepDefs.jsonPath.<String>read(FIRST_MESSAGE + ".htmlBody")).isEqualTo(StringEscapeUtils.unescapeJava(htmlBody));
+        assertThat(httpClient.jsonPath.<String>read(FIRST_MESSAGE + ".htmlBody")).isEqualTo(StringEscapeUtils.unescapeJava(htmlBody));
     }
 
     @Then("^the isUnread of the message is \"([^\"]*)\"$")
     public void assertIsUnreadOfTheFirstMessage(String isUnread) throws Exception {
-        assertThat(httpStepDefs.jsonPath.<Boolean>read(FIRST_MESSAGE + ".isUnread")).isEqualTo(Boolean.valueOf(isUnread));
+        assertThat(httpClient.jsonPath.<Boolean>read(FIRST_MESSAGE + ".isUnread")).isEqualTo(Boolean.valueOf(isUnread));
     }
 
     @Then("^the preview of the message is \"([^\"]*)\"$")
     public void assertPreviewOfTheFirstMessage(String preview) throws Exception {
-        String actual = httpStepDefs.jsonPath.<String>read(FIRST_MESSAGE + ".preview").replace("\n",
" ");
+        String actual = httpClient.jsonPath.<String>read(FIRST_MESSAGE + ".preview").replace("\n",
" ");
         assertThat(actual).isEqualToIgnoringWhitespace(StringEscapeUtils.unescapeJava(preview));
     }
 
     @Then("^the preview of the message is not empty$")
     public void assertPreviewOfTheFirstMessageIsNotEmpty() throws Exception {
-        String actual = httpStepDefs.jsonPath.<String>read(FIRST_MESSAGE + ".preview");
+        String actual = httpClient.jsonPath.<String>read(FIRST_MESSAGE + ".preview");
         assertThat(actual).isNotEmpty();
     }
 
     @Then("^the preview should not contain consecutive spaces or blank characters$")
     public void assertPreviewShouldBeNormalized() throws Exception {
-        String actual = httpStepDefs.jsonPath.<String>read(FIRST_MESSAGE + ".preview");
+        String actual = httpClient.jsonPath.<String>read(FIRST_MESSAGE + ".preview");
         assertThat(actual).hasSize(MessagePreviewGenerator.MAX_PREVIEW_LENGTH)
             .doesNotMatch("  ")
             .doesNotContain(StringUtils.CR)
@@ -626,37 +626,37 @@ public class GetMessagesMethodStepdefs {
 
     @Then("^the headers of the message contains:$")
     public void assertHeadersOfTheFirstMessage(DataTable headers) throws Exception {
-        assertThat(httpStepDefs.jsonPath.<Map<String, String>>read(FIRST_MESSAGE
+ ".headers")).containsAllEntriesOf(headers.asMap(String.class, String.class));
+        assertThat(httpClient.jsonPath.<Map<String, String>>read(FIRST_MESSAGE
+ ".headers")).containsAllEntriesOf(headers.asMap(String.class, String.class));
     }
 
     @Then("^the date of the message is \"([^\"]*)\"$")
     public void assertDateOfTheFirstMessage(String date) throws Exception {
-        assertThat(httpStepDefs.jsonPath.<String>read(FIRST_MESSAGE + ".date")).isEqualTo(date);
+        assertThat(httpClient.jsonPath.<String>read(FIRST_MESSAGE + ".date")).isEqualTo(date);
     }
 
     @Then("^the hasAttachment of the message is \"([^\"]*)\"$")
     public void assertHasAttachmentOfTheFirstMessage(String hasAttachment) throws Exception
{
-        assertThat(httpStepDefs.jsonPath.<Boolean>read(FIRST_MESSAGE + ".hasAttachment")).isEqualTo(Boolean.valueOf(hasAttachment));
+        assertThat(httpClient.jsonPath.<Boolean>read(FIRST_MESSAGE + ".hasAttachment")).isEqualTo(Boolean.valueOf(hasAttachment));
     }
 
     @Then("^the list of attachments of the message is empty$")
     public void assertAttachmentsOfTheFirstMessageIsEmpty() throws Exception {
-        assertThat(httpStepDefs.jsonPath.<List<Object>>read(ATTACHMENTS)).isEmpty();
+        assertThat(httpClient.jsonPath.<List<Object>>read(ATTACHMENTS)).isEmpty();
     }
 
     @Then("^the property \"([^\"]*)\" of the message is null$")
     public void assertPropertyIsNull(String property) throws Exception {
-        assertThat(httpStepDefs.jsonPath.<String>read(FIRST_MESSAGE + "." + property
+ ".date")).isNull();
+        assertThat(httpClient.jsonPath.<String>read(FIRST_MESSAGE + "." + property
+ ".date")).isNull();
     }
 
     @Then("^the list of attachments of the message contains (\\d+) attachments?$")
     public void assertAttachmentsHasSize(int numberOfAttachments) throws Exception {
-        assertThat(httpStepDefs.jsonPath.<List<Object>>read(ATTACHMENTS)).hasSize(numberOfAttachments);
+        assertThat(httpClient.jsonPath.<List<Object>>read(ATTACHMENTS)).hasSize(numberOfAttachments);
     }
 
     @Then("^the list of attachments of the message contains only one attachment with cid
\"([^\"]*)\"?$")
     public void assertAttachmentsAndItsCid(String cid) throws Exception {
-        assertThat(httpStepDefs.jsonPath.<String>read(FIRST_ATTACHMENT + ".cid")).isEqualTo(cid);
+        assertThat(httpClient.jsonPath.<String>read(FIRST_ATTACHMENT + ".cid")).isEqualTo(cid);
     }
 
     @Then("^the first attachment is:$")
@@ -671,19 +671,19 @@ public class GetMessagesMethodStepdefs {
 
     @Then("^the preview of the message contains: (.*)$")
     public void assertPreviewOfMessageShouldBePrintedWithEncoding(List<String> preview)
throws Exception {
-        String actual = httpStepDefs.jsonPath.<String>read(FIRST_MESSAGE + ".preview");
+        String actual = httpClient.jsonPath.<String>read(FIRST_MESSAGE + ".preview");
         assertThat(actual).contains(preview);
     }
 
     @Then("^the keywords of the message is (.*)$")
     public void assertKeywordsOfMessageShouldDisplay(List<String> keywords) throws
Exception {
-        assertThat(httpStepDefs.jsonPath.<Map<String, Boolean>>read(FIRST_MESSAGE
+ ".keywords").keySet())
+        assertThat(httpClient.jsonPath.<Map<String, Boolean>>read(FIRST_MESSAGE
+ ".keywords").keySet())
             .containsOnlyElementsOf(keywords);
     }
 
     @Then("^the message has no keyword$")
     public void assertMessageHasNoKeyword() throws Exception {
-        assertThat(httpStepDefs.jsonPath.<Map<String, Boolean>>read(FIRST_MESSAGE
+ ".keywords"))
+        assertThat(httpClient.jsonPath.<Map<String, Boolean>>read(FIRST_MESSAGE
+ ".keywords"))
             .isNullOrEmpty();
     }
 
@@ -691,7 +691,7 @@ public class GetMessagesMethodStepdefs {
     public void assertKeywordsOfMessage(String user, String messageId, List<String>
keywords) throws Exception {
         userStepdefs.execWithUser(user, () -> postWithAListOfIds(ImmutableList.of(messageId)));
 
-        assertThat(httpStepDefs.jsonPath.<Map<String, Boolean>>read(FIRST_MESSAGE
+ ".keywords").keySet())
+        assertThat(httpClient.jsonPath.<Map<String, Boolean>>read(FIRST_MESSAGE
+ ".keywords").keySet())
             .containsOnlyElementsOf(keywords);
     }
 
@@ -699,16 +699,16 @@ public class GetMessagesMethodStepdefs {
     public void assertKeywordsEmpty(String user, String messageId) throws Exception {
         userStepdefs.execWithUser(user, () -> postWithAListOfIds(ImmutableList.of(messageId)));
 
-        assertThat(httpStepDefs.jsonPath.<Map<String, Boolean>>read(FIRST_MESSAGE
+ ".keywords").keySet())
+        assertThat(httpClient.jsonPath.<Map<String, Boolean>>read(FIRST_MESSAGE
+ ".keywords").keySet())
             .isEmpty();
     }
 
     private void assertAttachment(String attachment, DataTable attachmentProperties) {
         attachmentProperties.asList(TableRow.class)
-            .forEach(entry -> assertThat(httpStepDefs.jsonPath.<Object>read(attachment
+ "." + entry.getKey())).isEqualTo(entry.getValue()));
+            .forEach(entry -> assertThat(httpClient.jsonPath.<Object>read(attachment
+ "." + entry.getKey())).isEqualTo(entry.getValue()));
     }
 
     public String getBlobId() {
-        return httpStepDefs.jsonPath.<String>read(FIRST_MESSAGE + ".blobId");
+        return httpClient.jsonPath.<String>read(FIRST_MESSAGE + ".blobId");
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/9ed94118/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/HttpClient.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/HttpClient.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/HttpClient.java
new file mode 100644
index 0000000..70b8449
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/HttpClient.java
@@ -0,0 +1,56 @@
+/****************************************************************
+ * 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.methods.integration.cucumber;
+
+import javax.inject.Inject;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.fluent.Request;
+
+import com.jayway.jsonpath.Configuration;
+import com.jayway.jsonpath.DocumentContext;
+import com.jayway.jsonpath.JsonPath;
+import com.jayway.jsonpath.Option;
+
+public class HttpClient {
+    private final MainStepdefs mainStepdefs;
+    private final UserStepdefs userStepdefs;
+
+    public HttpResponse response;
+    public DocumentContext jsonPath;
+
+    @Inject
+    public HttpClient(MainStepdefs mainStepdefs, UserStepdefs userStepdefs) {
+        this.mainStepdefs = mainStepdefs;
+        this.userStepdefs = userStepdefs;
+    }
+
+    public void post(String requestBody) throws Exception {
+        response = Request.Post(mainStepdefs.baseUri().setPath("/jmap").build())
+            .addHeader("Authorization", userStepdefs.authenticate(userStepdefs.getConnectedUser()).serialize())
+            .addHeader("Accept", org.apache.http.entity.ContentType.APPLICATION_JSON.getMimeType())
+            .bodyString(requestBody, org.apache.http.entity.ContentType.APPLICATION_JSON)
+            .execute()
+            .returnResponse();
+        jsonPath = JsonPath.using(Configuration.defaultConfiguration()
+            .addOptions(Option.SUPPRESS_EXCEPTIONS))
+            .parse(response.getEntity().getContent());
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/9ed94118/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/HttpStepDefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/HttpStepDefs.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/HttpStepDefs.java
deleted file mode 100644
index cbf57d5..0000000
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/HttpStepDefs.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************
- * 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.methods.integration.cucumber;
-
-import javax.inject.Inject;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.client.fluent.Request;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.DocumentContext;
-import com.jayway.jsonpath.JsonPath;
-import com.jayway.jsonpath.Option;
-
-public class HttpStepDefs {
-    private final MainStepdefs mainStepdefs;
-    private final UserStepdefs userStepdefs;
-
-    public HttpResponse response;
-    public DocumentContext jsonPath;
-
-    @Inject
-    public HttpStepDefs(MainStepdefs mainStepdefs, UserStepdefs userStepdefs) {
-        this.mainStepdefs = mainStepdefs;
-        this.userStepdefs = userStepdefs;
-    }
-
-    public void post(String requestBody) throws Exception {
-        response = Request.Post(mainStepdefs.baseUri().setPath("/jmap").build())
-            .addHeader("Authorization", userStepdefs.authenticate(userStepdefs.getConnectedUser()).serialize())
-            .addHeader("Accept", org.apache.http.entity.ContentType.APPLICATION_JSON.getMimeType())
-            .bodyString(requestBody, org.apache.http.entity.ContentType.APPLICATION_JSON)
-            .execute()
-            .returnResponse();
-        jsonPath = JsonPath.using(Configuration.defaultConfiguration()
-            .addOptions(Option.SUPPRESS_EXCEPTIONS))
-            .parse(response.getEntity().getContent());
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/9ed94118/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java
----------------------------------------------------------------------
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 b83afac..f01e325 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
@@ -52,13 +52,13 @@ public class SetMailboxesMethodStepdefs {
 
     private final MainStepdefs mainStepdefs;
     private final UserStepdefs userStepdefs;
-    private final HttpStepDefs httpStepDefs;
+    private final HttpClient httpClient;
 
     @Inject
-    private SetMailboxesMethodStepdefs(MainStepdefs mainStepdefs, UserStepdefs userStepdefs,
HttpStepDefs httpStepDefs) {
+    private SetMailboxesMethodStepdefs(MainStepdefs mainStepdefs, UserStepdefs userStepdefs,
HttpClient httpClient) {
         this.mainStepdefs = mainStepdefs;
         this.userStepdefs = userStepdefs;
-        this.httpStepDefs = httpStepDefs;
+        this.httpClient = httpClient;
     }
 
     @Given("^mailbox \"([^\"]*)\" with (\\d+) messages$")
@@ -95,7 +95,7 @@ public class SetMailboxesMethodStepdefs {
                     "    \"#0\"" +
                     "  ]" +
                     "]";
-        httpStepDefs.post(requestBody);
+        httpClient.post(requestBody);
     }
 
     @When("^moving mailbox \"([^\"]*)\" to \"([^\"]*)\"$")
@@ -119,7 +119,7 @@ public class SetMailboxesMethodStepdefs {
                     "    \"#0\"" +
                     "  ]" +
                     "]";
-        httpStepDefs.post(requestBody);
+        httpClient.post(requestBody);
     }
 
     @Then("^mailbox \"([^\"]*)\" contains (\\d+) messages$")
@@ -132,10 +132,10 @@ public class SetMailboxesMethodStepdefs {
         Awaitility.await().atMost(Duration.FIVE_SECONDS).pollDelay(slowPacedPollInterval).pollInterval(slowPacedPollInterval).until(()
-> {
             String requestBody = "[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\""
+ mailboxId + "\"]}}, \"#0\"]]";
 
-            httpStepDefs.post(requestBody);
+            httpClient.post(requestBody);
 
-            assertThat(httpStepDefs.response.getStatusLine().getStatusCode()).isEqualTo(200);
-            DocumentContext jsonPath = JsonPath.parse(httpStepDefs.response.getEntity().getContent());
+            assertThat(httpClient.response.getStatusLine().getStatusCode()).isEqualTo(200);
+            DocumentContext jsonPath = JsonPath.parse(httpClient.response.getEntity().getContent());
             assertThat(jsonPath.<String>read(NAME)).isEqualTo("messageList");
 
             return jsonPath.<List<String>>read(ARGUMENTS + ".messageIds").size()
== messageCount;

http://git-wip-us.apache.org/repos/asf/james-project/blob/9ed94118/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java
index e3cc8bd..045893f 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java
@@ -46,14 +46,14 @@ public class SetMessagesMethodStepdefs {
 
     private final MainStepdefs mainStepdefs;
     private final UserStepdefs userStepdefs;
-    private final HttpStepDefs httpStepDefs;
+    private final HttpClient httpClient;
     private final GetMessagesMethodStepdefs getMessagesMethodStepdefs;
 
     @Inject
-    private SetMessagesMethodStepdefs(MainStepdefs mainStepdefs, UserStepdefs userStepdefs,
HttpStepDefs httpStepDefs, GetMessagesMethodStepdefs getMessagesMethodStepdefs) {
+    private SetMessagesMethodStepdefs(MainStepdefs mainStepdefs, UserStepdefs userStepdefs,
HttpClient httpClient, GetMessagesMethodStepdefs getMessagesMethodStepdefs) {
         this.mainStepdefs = mainStepdefs;
         this.userStepdefs = userStepdefs;
-        this.httpStepDefs = httpStepDefs;
+        this.httpClient = httpClient;
         this.getMessagesMethodStepdefs = getMessagesMethodStepdefs;
     }
 
@@ -70,7 +70,7 @@ public class SetMessagesMethodStepdefs {
             .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.getConnectedUser(),
mailbox)
             .getMailboxId();
 
-        httpStepDefs.post("[" +
+        httpClient.post("[" +
             "  [" +
             "    \"setMessages\","+
             "    {" +
@@ -101,7 +101,7 @@ public class SetMessagesMethodStepdefs {
             .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.getConnectedUser(),
destinationMailbox)
             .getMailboxId();
 
-        httpStepDefs.post("[" +
+        httpClient.post("[" +
             "  [" +
             "    \"setMessages\","+
             "    {" +
@@ -131,7 +131,7 @@ public class SetMessagesMethodStepdefs {
             .getMailbox(MailboxConstants.USER_NAMESPACE, destinationUser, destinationMailbox)
             .getMailboxId();
 
-        httpStepDefs.post("[" +
+        httpClient.post("[" +
             "  [" +
             "    \"setMessages\","+
             "    {" +
@@ -157,7 +157,7 @@ public class SetMessagesMethodStepdefs {
             .getMailbox(MailboxConstants.USER_NAMESPACE, destinationUser, destinationMailbox)
             .getMailboxId();
 
-        httpStepDefs.post("[" +
+        httpClient.post("[" +
             "  [" +
             "    \"setMessages\","+
             "    {" +
@@ -184,7 +184,7 @@ public class SetMessagesMethodStepdefs {
             .map(value -> "\"" + value + "\" : true")
             .collect(Collectors.joining(","));
 
-        httpStepDefs.post("[" +
+        httpClient.post("[" +
             "  [" +
             "    \"setMessages\","+
             "    {" +
@@ -215,7 +215,7 @@ public class SetMessagesMethodStepdefs {
     @Then("^message \"([^\"]*)\" is not updated$")
     public void assertIdOfTheFirstMessage(String messageName) throws Exception {
         MessageId id = getMessagesMethodStepdefs.getMessageId(messageName);
-        assertThat(httpStepDefs.jsonPath.<Map<String, String>>read("[0][1].notUpdated"))
+        assertThat(httpClient.jsonPath.<Map<String, String>>read("[0][1].notUpdated"))
             .containsOnlyKeys(id.serialize());
     }
 


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


Mime
View raw message