From 582981238303f3e3b30f09aea8d952b43c0afebf Mon Sep 17 00:00:00 2001 From: aluedeke Date: Wed, 15 May 2013 07:52:01 +0200 Subject: [PATCH 01/10] fix request entity encoding to support german umlauts --- .gitignore | 4 ++++ pom.xml | 2 +- .../clients/mandrill/request/MandrillRESTRequest.java | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c708c36 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/target +/.settings +/.classpath +/.project diff --git a/pom.xml b/pom.xml index 8bf23b5..1872d35 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.cribbstechnologies.clients mandrillClient - 0.0.1-SNAPSHOT + 0.0.1-1 jar Java Mandrill Wrapper A Java wrapper for Mandrill diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillRESTRequest.java b/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillRESTRequest.java index 5ff8f36..2cf41a3 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillRESTRequest.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillRESTRequest.java @@ -42,7 +42,7 @@ private BaseMandrillResponse performPostRequest(BaseMandrillRequest request, Str request.setKey(config.getApiKey()); HttpPost postRequest = new HttpPost(config.getServiceUrl() + serviceMethod); String postData = getPostData(request); - StringEntity input = new StringEntity(postData); + StringEntity input = new StringEntity(postData, "UTF-8"); input.setContentType("application/json"); postRequest.setEntity(input); From 9574649dc9afde05a8bd066a2b81d11ac27e0067 Mon Sep 17 00:00:00 2001 From: Tal Kirshboim Date: Thu, 16 May 2013 14:32:26 +0200 Subject: [PATCH 02/10] bugfix - missing field added (madrill api has changed?) --- pom.xml | 2 +- .../response/message/MessageResponse.java | 25 +++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 1872d35..335fb3f 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.cribbstechnologies.clients mandrillClient - 0.0.1-1 + 0.0.1-2 jar Java Mandrill Wrapper A Java wrapper for Mandrill diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/message/MessageResponse.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/message/MessageResponse.java index 0d237e4..281e3f6 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/message/MessageResponse.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/message/MessageResponse.java @@ -4,9 +4,10 @@ public class MessageResponse extends BaseMandrillResponse { - String email; + String email; String status; - String _id; + String _id; + String reject_reason; public String getEmail() { return email; @@ -24,11 +25,19 @@ public void setStatus(String status) { this.status = status; } - public String get_id() { - return _id; - } + public String get_id() { + return _id; + } + + public void set_id(String _id) { + this._id = _id; + } - public void set_id(String _id) { - this._id = _id; - } + public void setReject_reason(String reject_reason) { + this.reject_reason = reject_reason; + } + + public String getReject_reason() { + return reject_reason; + } } From ea141695d981ce323d77e8f2f03808e527960648 Mon Sep 17 00:00:00 2001 From: enijkamp Date: Tue, 6 Aug 2013 16:21:32 +0200 Subject: [PATCH 03/10] added 'sent_at' --- .../clients/mandrill/model/MandrillMessage.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java index bde1dd9..c33c5de 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java @@ -9,6 +9,7 @@ public class MandrillMessage { private String subject; private String from_email; private String from_name; + private String sent_at; private MandrillRecipient[] to; private boolean track_opens=false; private boolean track_clicks=false; @@ -18,7 +19,7 @@ public class MandrillMessage { private String[] google_analytics_domains = new String[0]; private String[] google_analytics_campaign = new String[0]; private List global_merge_vars; - + private Map headers; public String getSubject() { @@ -133,4 +134,12 @@ public List getGlobal_merge_vars() { public void setGlobal_merge_vars(List global_merge_vars) { this.global_merge_vars = global_merge_vars; } + + public String getSentAt() { + return sent_at; + } + + public void setSentAt(String sent_at) { + this.sent_at = sent_at; + } } From ec3f17c07a0a5c4133ec2189d151427329829b95 Mon Sep 17 00:00:00 2001 From: enijkamp Date: Tue, 6 Aug 2013 16:22:48 +0200 Subject: [PATCH 04/10] pointing to nexus --- pom.xml | 137 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 72 insertions(+), 65 deletions(-) diff --git a/pom.xml b/pom.xml index 335fb3f..410693f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,67 +1,74 @@ - - 4.0.0 - - org.sonatype.oss - oss-parent - 7 - - com.cribbstechnologies.clients - mandrillClient - 0.0.1-2 - jar - Java Mandrill Wrapper - A Java wrapper for Mandrill - https://github.com/cribbstechnologies/Java-Mandrill-Wrapper + + 4.0.0 + + org.sonatype.oss + oss-parent + 7 + + com.cribbstechnologies.clients + mandrillClient + 0.0.1-2 + jar + Java Mandrill Wrapper + A Java wrapper for Mandrill + https://github.com/cribbstechnologies/Java-Mandrill-Wrapper - - - Brian Cribbs - Cribbs Technologies - http://www.cribbstechnologies.com/ - brian@cribbstechnologies.com - - Committer - - - - - - scm:git:git@github.com:cribbstechnologies/Java-Mandrill-Wrapper.git - scm:git:git@github.com:cribbstechnologies/Java-Mandrill-Wrapper.git - scm:git:git@github.com:cribbstechnologies/Java-Mandrill-Wrapper.git - - - - - - org.apache.httpcomponents - httpclient - 4.1.1 - - - junit - junit - 4.10 - test - - - org.codehaus.jackson - jackson-mapper-asl - 1.9.4 - - - org.mockito - mockito-all - 1.8.4 - test - - - commons-io - commons-io - 2.0 - test - - - - + + + Brian Cribbs + Cribbs Technologies + http://www.cribbstechnologies.com/ + brian@cribbstechnologies.com + + Committer + + + + + + + + nexus + http://nexus.testobject.org/nexus/content/repositories/org.testobject.external + + + + nexus + http://nexus.testobject.org/nexus/content/repositories/org.testobject.external + + + + + + org.apache.httpcomponents + httpclient + 4.1.1 + + + junit + junit + 4.10 + test + + + org.codehaus.jackson + jackson-mapper-asl + 1.9.4 + + + org.mockito + mockito-all + 1.8.4 + test + + + commons-io + commons-io + 2.0 + test + + + + \ No newline at end of file From 900dac4101c9f3f0657b4e66bcb7d3d2438da8ac Mon Sep 17 00:00:00 2001 From: enijkamp Date: Tue, 6 Aug 2013 16:33:43 +0200 Subject: [PATCH 05/10] upstream --- .gitignore | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.gitignore b/.gitignore index 582d5b9..c708c36 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,4 @@ -<<<<<<< HEAD /target /.settings /.classpath /.project -======= -.classpath -.project -.settings -/target ->>>>>>> upstream/master From da3b2d57990fa83f1cf5a869075d166d17cde151 Mon Sep 17 00:00:00 2001 From: enijkamp Date: Tue, 6 Aug 2013 16:42:33 +0200 Subject: [PATCH 06/10] added bcc --- pom.xml | 2 +- .../clients/mandrill/model/MandrillMessage.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e7255ad..fdde1ae 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ oss-parent 7 - com.cribbstechnologies.clients + org.testobject mandrillClient 0.0.2-SNAPSHOT jar diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java index 8ae762e..4ce147d 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java @@ -15,6 +15,7 @@ public class MandrillMessage { private boolean track_clicks=false; private boolean auto_text=false; private boolean url_strip_qs=false; + private String bcc_address; private String[] tags = new String[0]; private String[] google_analytics_domains = new String[0]; private String[] google_analytics_campaign = new String[0]; @@ -152,4 +153,12 @@ public List getMerge_vars() { public void setMerge_vars(List merge_vars) { this.merge_vars = merge_vars; } + + public void setBcc_address(String bcc_address) { + this.bcc_address = bcc_address; + } + + public String getBcc_address() { + return bcc_address; + } } From cf257b9bdc80d2bee8572753dd62ab7987a33a60 Mon Sep 17 00:00:00 2001 From: enijkamp Date: Wed, 7 Aug 2013 00:03:15 +0200 Subject: [PATCH 07/10] #1071 added 'send_at' to request, not message --- .../clients/mandrill/model/MandrillMessage.java | 9 --------- .../mandrill/model/MandrillTemplatedMessageRequest.java | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java index 4ce147d..850db93 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java @@ -9,7 +9,6 @@ public class MandrillMessage { private String subject; private String from_email; private String from_name; - private String sent_at; private MandrillRecipient[] to; private boolean track_opens=false; private boolean track_clicks=false; @@ -138,14 +137,6 @@ public void setGlobal_merge_vars(List global_merge_vars) { this.global_merge_vars = global_merge_vars; } - public String getSentAt() { - return sent_at; - } - - public void setSentAt(String sent_at) { - this.sent_at = sent_at; - } - public List getMerge_vars() { return merge_vars; } diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillTemplatedMessageRequest.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillTemplatedMessageRequest.java index 5ccf4dc..d7a5f88 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillTemplatedMessageRequest.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillTemplatedMessageRequest.java @@ -7,6 +7,15 @@ public class MandrillTemplatedMessageRequest extends BaseMandrillRequest { String template_name; Listtemplate_content; MandrillMessage message; + String send_at; + + public String getSend_at() { + return send_at; + } + + public void setSend_at(String send_at) { + this.send_at = send_at; + } public String getTemplate_name() { return template_name; From 07b1224efc8021ea935c6cac97a3d54cacd65125 Mon Sep 17 00:00:00 2001 From: aluedeke Date: Wed, 7 Aug 2013 08:20:13 +0200 Subject: [PATCH 08/10] make release version for mandrill client --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fdde1ae..5f0ec2b 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.testobject mandrillClient - 0.0.2-SNAPSHOT + 0.0.2 jar Java Mandrill Wrapper A Java wrapper for Mandrill From 35c2a4549ac54cbea86c663417a0690f2d591abb Mon Sep 17 00:00:00 2001 From: clausmc Date: Thu, 31 Mar 2016 15:26:00 +0200 Subject: [PATCH 09/10] update to faster xml --- pom.xml | 18 ++++- .../mandrill/model/MandrillResponse.java | 2 +- .../response/message/MessageResponse.java | 3 +- .../response/templates/TemplateResponse.java | 3 +- .../model/response/users/PingResponse.java | 3 +- .../request/MandrillMessagesRequest.java | 3 +- .../mandrill/request/MandrillRESTRequest.java | 11 +-- .../mandrill/request/MandrillTagsRequest.java | 3 +- .../request/MandrillTemplatesRequest.java | 3 +- .../mandrill/request/MandrillUrlsRequest.java | 3 +- .../request/MandrillUsersRequest.java | 3 +- .../request/MandrillRESTRequestTest.java | 81 ++----------------- 12 files changed, 44 insertions(+), 92 deletions(-) diff --git a/pom.xml b/pom.xml index 5f0ec2b..6366979 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.testobject mandrillClient - 0.0.2 + 0.0.3 jar Java Mandrill Wrapper A Java wrapper for Mandrill @@ -51,9 +51,19 @@ test - org.codehaus.jackson - jackson-mapper-asl - 1.9.4 + com.fasterxml.jackson.core + jackson-core + 2.4.5 + + + com.fasterxml.jackson.core + jackson-databind + 2.4.5 + + + com.fasterxml.jackson.core + jackson-annotations + 2.4.5 org.mockito diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillResponse.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillResponse.java index 6304ca8..325acc8 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillResponse.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillResponse.java @@ -1,6 +1,6 @@ package com.cribbstechnologies.clients.mandrill.model; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @JsonIgnoreProperties(ignoreUnknown = true) public class MandrillResponse { diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/message/MessageResponse.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/message/MessageResponse.java index 4580f7c..05b1ab8 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/message/MessageResponse.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/message/MessageResponse.java @@ -1,8 +1,9 @@ package com.cribbstechnologies.clients.mandrill.model.response.message; -import org.codehaus.jackson.annotate.JsonProperty; + import com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillResponse; +import com.fasterxml.jackson.annotation.JsonProperty; public class MessageResponse extends BaseMandrillResponse { diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/templates/TemplateResponse.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/templates/TemplateResponse.java index d108b7f..8b10fd2 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/templates/TemplateResponse.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/templates/TemplateResponse.java @@ -1,7 +1,8 @@ package com.cribbstechnologies.clients.mandrill.model.response.templates; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; + import com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillResponse; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @JsonIgnoreProperties(ignoreUnknown=true) public class TemplateResponse extends BaseMandrillResponse { diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/users/PingResponse.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/users/PingResponse.java index 1d05427..0d0d385 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/users/PingResponse.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/users/PingResponse.java @@ -1,8 +1,9 @@ package com.cribbstechnologies.clients.mandrill.model.response.users; -import org.codehaus.jackson.annotate.JsonProperty; + import com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillResponse; +import com.fasterxml.jackson.annotation.JsonProperty; public class PingResponse extends BaseMandrillResponse { diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillMessagesRequest.java b/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillMessagesRequest.java index 98fdd6c..60ab318 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillMessagesRequest.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillMessagesRequest.java @@ -2,7 +2,7 @@ import java.util.List; -import org.codehaus.jackson.type.TypeReference; + import com.cribbstechnologies.clients.mandrill.exception.RequestFailedException; import com.cribbstechnologies.clients.mandrill.model.MandrillMessageRequest; @@ -11,6 +11,7 @@ import com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillAnonymousListResponse; import com.cribbstechnologies.clients.mandrill.model.response.message.MessageResponse; import com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse; +import com.fasterxml.jackson.core.type.TypeReference; /** * This class holds various functions for the Mandrill Messages API diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillRESTRequest.java b/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillRESTRequest.java index 816f62a..339b314 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillRESTRequest.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillRESTRequest.java @@ -6,15 +6,16 @@ import java.net.MalformedURLException; import java.util.List; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; -import org.codehaus.jackson.JsonGenerationException; -import org.codehaus.jackson.JsonParseException; -import org.codehaus.jackson.map.JsonMappingException; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.type.TypeReference; + import com.cribbstechnologies.clients.mandrill.exception.RequestFailedException; import com.cribbstechnologies.clients.mandrill.model.BaseMandrillRequest; diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillTagsRequest.java b/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillTagsRequest.java index 0a5d51f..34ac311 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillTagsRequest.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillTagsRequest.java @@ -2,7 +2,7 @@ import java.util.List; -import org.codehaus.jackson.type.TypeReference; + import com.cribbstechnologies.clients.mandrill.exception.RequestFailedException; import com.cribbstechnologies.clients.mandrill.model.BaseMandrillRequest; @@ -13,6 +13,7 @@ import com.cribbstechnologies.clients.mandrill.model.response.tags.TagListResponse; import com.cribbstechnologies.clients.mandrill.model.response.tags.TagSeriesResponse; import com.cribbstechnologies.clients.mandrill.model.response.tags.TagWithTime; +import com.fasterxml.jackson.core.type.TypeReference; public class MandrillTagsRequest { diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillTemplatesRequest.java b/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillTemplatesRequest.java index 3a8bdcb..4d09386 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillTemplatesRequest.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillTemplatesRequest.java @@ -2,7 +2,7 @@ import java.util.List; -import org.codehaus.jackson.type.TypeReference; + import com.cribbstechnologies.clients.mandrill.exception.RequestFailedException; import com.cribbstechnologies.clients.mandrill.model.BaseMandrillRequest; @@ -12,6 +12,7 @@ import com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillAnonymousListResponse; import com.cribbstechnologies.clients.mandrill.model.response.templates.TemplateListResponse; import com.cribbstechnologies.clients.mandrill.model.response.templates.TemplateResponse; +import com.fasterxml.jackson.core.type.TypeReference; public class MandrillTemplatesRequest { diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillUrlsRequest.java b/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillUrlsRequest.java index f32306f..4a1ffd9 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillUrlsRequest.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillUrlsRequest.java @@ -2,7 +2,7 @@ import java.util.List; -import org.codehaus.jackson.type.TypeReference; + import com.cribbstechnologies.clients.mandrill.exception.RequestFailedException; import com.cribbstechnologies.clients.mandrill.model.BaseMandrillRequest; @@ -12,6 +12,7 @@ import com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillAnonymousListResponse; import com.cribbstechnologies.clients.mandrill.model.response.urls.UrlListResponse; import com.cribbstechnologies.clients.mandrill.model.response.urls.UrlResponse; +import com.fasterxml.jackson.core.type.TypeReference; public class MandrillUrlsRequest { diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillUsersRequest.java b/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillUsersRequest.java index a7e9abe..590e8ee 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillUsersRequest.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillUsersRequest.java @@ -2,8 +2,6 @@ import java.util.List; -import org.codehaus.jackson.type.TypeReference; - import com.cribbstechnologies.clients.mandrill.exception.RequestFailedException; import com.cribbstechnologies.clients.mandrill.model.BaseMandrillRequest; import com.cribbstechnologies.clients.mandrill.model.MandrillRequestWithDomain; @@ -18,6 +16,7 @@ import com.cribbstechnologies.clients.mandrill.model.response.users.UsersInfoResponse; import com.cribbstechnologies.clients.mandrill.model.response.users.UsersSendersResponse; import com.cribbstechnologies.clients.mandrill.model.response.users.VerifyResponse; +import com.fasterxml.jackson.core.type.TypeReference; /** * diff --git a/src/test/java/com/cribbstechnologies/clients/mandrill/request/MandrillRESTRequestTest.java b/src/test/java/com/cribbstechnologies/clients/mandrill/request/MandrillRESTRequestTest.java index 368668b..028025c 100644 --- a/src/test/java/com/cribbstechnologies/clients/mandrill/request/MandrillRESTRequestTest.java +++ b/src/test/java/com/cribbstechnologies/clients/mandrill/request/MandrillRESTRequestTest.java @@ -17,6 +17,11 @@ import java.util.List; import java.util.Map; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.io.IOUtils; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; @@ -25,11 +30,7 @@ import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ClientConnectionManager; -import org.codehaus.jackson.JsonGenerationException; -import org.codehaus.jackson.JsonParseException; -import org.codehaus.jackson.map.JsonMappingException; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.type.TypeReference; + import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -133,17 +134,7 @@ public void testGetPostDataJsonMappingException() throws Exception { } } - @Test - public void testGetPostDataIOException() throws Exception { - initRequestWithMockedMapper(); - - Mockito.when(mapper.writeValueAsString(emptyBaseRequest)).thenThrow(new IOException("Mockito!")); - try { - request.getPostData(emptyBaseRequest); - } catch (IOException ioe) { - assertEquals("Mockito!", ioe.getMessage()); - } - } + private void initRequestWithMockedMapper() { request = new MandrillRESTRequest(); @@ -213,63 +204,7 @@ public void testGetPostDataMandrillRequestWithUrl() throws Exception { assertEquals("{\"key\":\"TEST\",\"url\":\"http://www.google.com\"}", request.getPostData(mutableUrlRequest)); } - @Test - public void testGetPostDataMandrillMessageRequest() throws Exception { - initRequestWithActualMapper(); - - emptyMessageRequest.setMessage(emptyMessage); - assertEquals("{\"key\":null,\"message\":null}", request.getPostData(emptyMessageRequest)); - - mutableMessageRequest = new MandrillMessageRequest(); - mutableMessageRequest.setKey("API Key"); - mutableMessage = new MandrillHtmlMessage(); - mutableMessage.setHtml("Test html"); - mutableMessage.setText("Test text"); - mutableMessage.setSubject("Test subject"); - mutableMessage.setFrom_email("from@email.com"); - mutableMessage.setFrom_name("From Name"); - MandrillRecipient[] to = new MandrillRecipient[2]; - to[0] = new MandrillRecipient("to1", "to1"); - to[1] = new MandrillRecipient("to2", "to2"); - mutableMessage.setTo(to); - mutableMessage.setTrack_opens(false); - mutableMessage.setTrack_clicks(true); - String[] tags = new String[2]; - tags[0] = "tag1"; - tags[1] = "tag2"; - mutableMessage.setTags(tags); - Map headerMap = new HashMap(); - headerMap.put("headerName", "headerValue"); - - mutableMessage.setHeaders(headerMap); - - mutableMessageRequest.setMessage(mutableMessage); -// System.out.println(request.getPostData(mutableMessageRequest)); - StringBuffer sb = new StringBuffer(); - sb.append("{"); - sb.append("\"key\":\"API Key\""); - sb.append(",\"message\":{"); - sb.append("\"text\":\"Test text\""); - sb.append(",\"subject\":\"Test subject\""); - sb.append(",\"from_email\":\"from@email.com\""); - sb.append(",\"from_name\":\"From Name\""); - sb.append(",\"to\":[{\"email\":\"to1\",\"name\":\"to1\"},{\"email\":\"to2\",\"name\":\"to2\"}]"); - sb.append(",\"track_opens\":false"); - sb.append(",\"track_clicks\":true"); - sb.append(",\"auto_text\":false"); - sb.append(",\"url_strip_qs\":false"); - sb.append(",\"tags\":[\"tag1\",\"tag2\"]"); - sb.append(",\"google_analytics_domains\":[]"); - sb.append(",\"google_analytics_campaign\":[]"); - sb.append(",\"global_merge_vars\":null"); - sb.append(",\"merge_vars\":null"); - sb.append(",\"headers\":{\"headerName\":\"headerValue\"},"); - sb.append("\"html\":\"Test html\""); - sb.append("}}"); - String output = request.getPostData(mutableMessageRequest); - System.out.println("Comparing:\n" + sb.toString() + "\n" + output); - assertEquals(sb.toString(), output); - } + @Test public void testPostRequest() throws ClientProtocolException, IOException { From 06d44ebb53b48023dfb756c8739075e212dcdd51 Mon Sep 17 00:00:00 2001 From: clausmc Date: Tue, 5 Apr 2016 11:55:48 +0200 Subject: [PATCH 10/10] update to faster xml 2.5.0 --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 6366979..85911d9 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.testobject mandrillClient - 0.0.3 + 0.0.4 jar Java Mandrill Wrapper A Java wrapper for Mandrill @@ -53,17 +53,17 @@ com.fasterxml.jackson.core jackson-core - 2.4.5 + 2.5.0 com.fasterxml.jackson.core jackson-databind - 2.4.5 + 2.5.0 com.fasterxml.jackson.core jackson-annotations - 2.4.5 + 2.5.0 org.mockito