diff --git a/.travis.yml b/.travis.yml index 54267b90..fadd2e5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,17 @@ language: java -sudo: false +sudo: required jdk: -- oraclejdk8 -- oraclejdk7 -- openjdk7 + - oraclejdk8 + - oraclejdk7 + - openjdk7 +before_script: + - mkdir prism/bin + - export PATH=$PATH:$PWD/prism/bin/ + - ./prism/prism.sh + - nohup prism run -s https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json & after_script: -- "./gradlew build" -- "./scripts/upload.sh" + - "./gradlew build" + - "./scripts/upload.sh" env: global: - S3_POLICY: ewogICJleHBpcmF0aW9uIjogIjIxMDAtMDEtMDFUMTI6MDA6MDAuMDAwWiIsCiAgImNvbmRpdGlvbnMiOiBbCiAgICB7ImFjbCI6ICJwdWJsaWMtcmVhZCIgfSwKICAgIHsiYnVja2V0IjogInNlbmRncmlkLW9wZW4tc291cmNlIiB9LAogICAgWyJzdGFydHMtd2l0aCIsICIka2V5IiwgInNlbmRncmlkLWphdmEvIl0sCiAgICBbImNvbnRlbnQtbGVuZ3RoLXJhbmdlIiwgMjA0OCwgMjY4NDM1NDU2XSwKICAgIFsiZXEiLCAiJENvbnRlbnQtVHlwZSIsICJhcHBsaWNhdGlvbi96aXAiXQogIF0KfQo= diff --git a/prism/prism.sh b/prism/prism.sh new file mode 100755 index 00000000..5d9d3002 --- /dev/null +++ b/prism/prism.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +install () { + +set -eu + +UNAME=$(uname) +ARCH=$(uname -m) +if [ "$UNAME" != "Linux" ] && [ "$UNAME" != "Darwin" ] && [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "i686" ]; then + echo "Sorry, OS/Architecture not supported: ${UNAME}/${ARCH}. Download binary from https://github.com/stoplightio/prism/releases" + exit 1 +fi + +if [ "$UNAME" = "Darwin" ] ; then + OSX_ARCH=$(uname -m) + if [ "${OSX_ARCH}" = "x86_64" ] ; then + PLATFORM="darwin_amd64" + fi +elif [ "$UNAME" = "Linux" ] ; then + LINUX_ARCH=$(uname -m) + if [ "${LINUX_ARCH}" = "i686" ] ; then + PLATFORM="linux_386" + elif [ "${LINUX_ARCH}" = "x86_64" ] ; then + PLATFORM="linux_amd64" + fi +fi + +#LATEST=$(curl -s https://api.github.com/repos/stoplightio/prism/tags | grep -Eo '"name":.*?[^\\]",' | head -n 1 | sed 's/[," ]//g' | cut -d ':' -f 2) +LATEST="v0.1.5" +URL="https://github.com/stoplightio/prism/releases/download/$LATEST/prism_$PLATFORM" +DEST=./prism/bin/prism + +if [ -z $LATEST ] ; then + echo "Error requesting. Download binary from ${URL}" + exit 1 +else + curl -L $URL -o $DEST + chmod +x $DEST +fi +} + +install \ No newline at end of file diff --git a/src/main/java/com/sendgrid/SendGrid.java b/src/main/java/com/sendgrid/SendGrid.java index 421b11a9..96b2e209 100644 --- a/src/main/java/com/sendgrid/SendGrid.java +++ b/src/main/java/com/sendgrid/SendGrid.java @@ -11,7 +11,6 @@ public class SendGrid { private static final String VERSION = "3.0.0"; private static final String USER_AGENT = "sendgrid/" + VERSION + ";java"; - private String apiKey; private String host; private String version; private Client client; @@ -44,17 +43,16 @@ public SendGrid(String apiKey, Client client) { } public void initializeSendGrid(String apiKey) { - this.apiKey = apiKey; this.host = "api.sendgrid.com"; this.version = "v3"; - this.requestHeaders = new HashMap(); + this.requestHeaders = new HashMap<>(); this.requestHeaders.put("Authorization", "Bearer " + apiKey); this.requestHeaders.put("User-agent", USER_AGENT); this.requestHeaders.put("Accept", "application/json"); } public String getLibraryVersion() { - return this.VERSION; + return VERSION; } public String getVersion() { diff --git a/src/main/java/com/sendgrid/helpers/mail/Mail.java b/src/main/java/com/sendgrid/helpers/mail/Mail.java index beba5a53..e02f5aa6 100644 --- a/src/main/java/com/sendgrid/helpers/mail/Mail.java +++ b/src/main/java/com/sendgrid/helpers/mail/Mail.java @@ -1,16 +1,11 @@ -package com.sendgrid; +package com.sendgrid.helpers.mail; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; - import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.databind.SerializationFeature; +import com.sendgrid.helpers.mail.objects.*; import java.io.IOException; import java.util.ArrayList; @@ -23,32 +18,30 @@ */ @JsonInclude(Include.NON_DEFAULT) public class Mail { - @JsonProperty("from") public Email from; - @JsonProperty("subject") public String subject; - @JsonProperty("personalizations") public List personalization; - @JsonProperty("content") public List content; - @JsonProperty("attachments") public List attachments; - @JsonProperty("template_id") public String templateId; - @JsonProperty("sections") public Map sections; - @JsonProperty("headers") public Map headers; - @JsonProperty("categories") public List categories; - @JsonProperty("custom_args") public Map customArgs; - @JsonProperty("send_at") public long sendAt; - @JsonProperty("batch_id") public String batchId; - @JsonProperty("asm") public ASM asm; - @JsonProperty("ip_pool_name") public String ipPoolId; - @JsonProperty("mail_settings") public MailSettings mailSettings; - @JsonProperty("tracking_settings") public TrackingSettings trackingSettings; - @JsonProperty("reply_to") public Email replyTo; + @JsonProperty("from") private Email from; + @JsonProperty("subject") private String subject; + @JsonProperty("personalizations") private List personalization; + @JsonProperty("content") private List content; + @JsonProperty("attachments") private List attachments; + @JsonProperty("template_id") private String templateId; + @JsonProperty("sections") private Map sections; + @JsonProperty("headers") private Map headers; + @JsonProperty("categories") private List categories; + @JsonProperty("custom_args") private Map customArgs; + @JsonProperty("send_at") private long sendAt; + @JsonProperty("batch_id") private String batchId; + @JsonProperty("asm") private ASM asm; + @JsonProperty("ip_pool_name") private String ipPoolId; + @JsonProperty("mail_settings") private MailSettings mailSettings; + @JsonProperty("tracking_settings") private TrackingSettings trackingSettings; + @JsonProperty("reply_to") private Email replyTo; private static final ObjectMapper SORTED_MAPPER = new ObjectMapper(); static { SORTED_MAPPER.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true); } - public Mail() { - return; - } + public Mail() {} public Mail(Email from, String subject, Email to, Content content) { @@ -94,7 +87,7 @@ public List getPersonalization() { public void addPersonalization(Personalization personalization) { if (this.personalization == null) { - this.personalization = new ArrayList(); + this.personalization = new ArrayList<>(); this.personalization.add(personalization); } else { this.personalization.add(personalization); @@ -111,7 +104,7 @@ public void addContent(Content content) { newContent.setType(content.getType()); newContent.setValue(content.getValue()); if (this.content == null) { - this.content = new ArrayList(); + this.content = new ArrayList<>(); this.content.add(newContent); } else { this.content.add(newContent); @@ -131,7 +124,7 @@ public void addAttachments(Attachments attachments) { newAttachment.setDisposition(attachments.getDisposition()); newAttachment.setContentId(attachments.getContentId()); if (this.attachments == null) { - this.attachments = new ArrayList(); + this.attachments = new ArrayList<>(); this.attachments.add(newAttachment); } else { this.attachments.add(newAttachment); @@ -154,7 +147,7 @@ public Map getSections() { public void addSection(String key, String value) { if (sections == null) { - sections = new HashMap(); + sections = new HashMap<>(); sections.put(key, value); } else { sections.put(key, value); @@ -169,7 +162,7 @@ public Map getHeaders() { public void addHeader(String key, String value) { if (headers == null) { - headers = new HashMap(); + headers = new HashMap<>(); headers.put(key, value); } else { headers.put(key, value); @@ -183,7 +176,7 @@ public List getCategories() { public void addCategory(String category) { if (categories == null) { - categories = new ArrayList(); + categories = new ArrayList<>(); categories.add(category); } else { categories.add(category); @@ -197,7 +190,7 @@ public Map getCustomArgs() { public void addCustomArg(String key, String value) { if (customArgs == null) { - customArgs = new HashMap(); + customArgs = new HashMap<>(); customArgs.put(key, value); } else { customArgs.put(key, value); diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java b/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java index 1a65a65d..b4093a0b 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java @@ -1,4 +1,4 @@ -package com.sendgrid; +package com.sendgrid.helpers.mail.objects; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java b/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java index 9323b837..1fccf490 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java @@ -1,4 +1,4 @@ -package com.sendgrid; +package com.sendgrid.helpers.mail.objects; import com.fasterxml.jackson.annotation.JsonIgnoreType; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java index 176387fa..7be4d30a 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java @@ -1,4 +1,4 @@ -package com.sendgrid; +package com.sendgrid.helpers.mail.objects; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java index 839c8fbf..3788a40a 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java @@ -1,4 +1,4 @@ -package com.sendgrid; +package com.sendgrid.helpers.mail.objects; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Content.java b/src/main/java/com/sendgrid/helpers/mail/objects/Content.java index b00f9566..0b005bbe 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/Content.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/Content.java @@ -1,4 +1,4 @@ -package com.sendgrid; +package com.sendgrid.helpers.mail.objects; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; @@ -9,9 +9,7 @@ public class Content { @JsonProperty("type") private String type; @JsonProperty("value") private String value; - public Content() { - return; - } + public Content() {} public Content(String type, String value) { this.setType(type); diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/ContentType.java b/src/main/java/com/sendgrid/helpers/mail/objects/ContentType.java new file mode 100644 index 00000000..070b53aa --- /dev/null +++ b/src/main/java/com/sendgrid/helpers/mail/objects/ContentType.java @@ -0,0 +1,92 @@ +package com.sendgrid.helpers.mail.objects; + +/** + * @author Marcos Barbero + */ +public class ContentType { + + /** + * Public constant media type that includes all media ranges (i.e. "*/*"). + */ + public static final String ALL = "*/*"; + + /** + * Public constant media type for {@code application/atom+xml}. + */ + public final static String APPLICATION_ATOM_XML = "application/atom+xml"; + + /** + * Public constant media type for {@code application/x-www-form-urlencoded}. + */ + public final static String APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded"; + + /** + * Public constant media type for {@code application/json}. + */ + public final static String APPLICATION_JSON = "application/json"; + + /** + * Public constant media type for {@code application/json;charset=UTF-8}. + */ + public final static String APPLICATION_JSON_UTF8 = APPLICATION_JSON + ";charset=UTF-8"; + + /** + * Public constant media type for {@code application/octet-stream}. + */ + public final static String APPLICATION_OCTET_STREAM = "application/octet-stream"; + + /** + * Public constant media type for {@code application/pdf}. + */ + public final static String APPLICATION_PDF = "application/pdf"; + + /** + * Public constant media type for {@code application/xhtml+xml}. + */ + public final static String APPLICATION_XHTML_XML = "application/xhtml+xml"; + + /** + * Public constant media type for {@code application/xml}. + */ + public final static String APPLICATION_XML = "application/xml"; + + /** + * Public constant media type for {@code image/gif}. + */ + public final static String IMAGE_GIF = "image/gif"; + + /** + * Public constant media type for {@code image/jpeg}. + */ + public final static String IMAGE_JPEG = "image/jpeg"; + + /** + * Public constant media type for {@code image/png}. + */ + public final static String IMAGE_PNG = "image/png"; + + /** + * Public constant media type for {@code multipart/form-data}. + */ + public final static String MULTIPART_FORM_DATA = "multipart/form-data"; + + /** + * Public constant media type for {@code text/html}. + */ + public final static String TEXT_HTML = "text/html"; + + /** + * Public constant media type for {@code text/markdown}. + */ + public final static String TEXT_MARKDOWN = "text/markdown"; + + /** + * Public constant media type for {@code text/plain}. + */ + public final static String TEXT_PLAIN = "text/plain"; + + /** + * Public constant media type for {@code text/xml}. + */ + public final static String TEXT_XML = "text/xml"; +} \ No newline at end of file diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Email.java b/src/main/java/com/sendgrid/helpers/mail/objects/Email.java index 43396a85..a33b7ca8 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/Email.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/Email.java @@ -1,4 +1,4 @@ -package com.sendgrid; +package com.sendgrid.helpers.mail.objects; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; @@ -9,9 +9,7 @@ public class Email { @JsonProperty("name") private String name; @JsonProperty("email") private String email; - public Email() { - return; - } + public Email() {} public Email(String email) { this.setEmail(email); diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java index 8e542c7f..ea020cdd 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java @@ -1,4 +1,4 @@ -package com.sendgrid; +package com.sendgrid.helpers.mail.objects; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java index ce30edbc..3bec6a58 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java @@ -1,4 +1,4 @@ -package com.sendgrid; +package com.sendgrid.helpers.mail.objects; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java index 63580458..598f31c6 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java @@ -1,4 +1,4 @@ -package com.sendgrid; +package com.sendgrid.helpers.mail.objects; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java index aeb7ede1..2d798a3b 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java @@ -1,4 +1,4 @@ -package com.sendgrid; +package com.sendgrid.helpers.mail.objects; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java b/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java index 50dcafc5..4cbf0528 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java @@ -1,4 +1,4 @@ -package com.sendgrid; +package com.sendgrid.helpers.mail.objects; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; @@ -30,7 +30,7 @@ public void addTo(Email email) { newEmail.setName(email.getName()); newEmail.setEmail(email.getEmail()); if (tos == null) { - tos = new ArrayList(); + tos = new ArrayList<>(); tos.add(newEmail); } else { tos.add(newEmail); @@ -47,7 +47,7 @@ public void addCc(Email email) { newEmail.setName(email.getName()); newEmail.setEmail(email.getEmail()); if (ccs == null) { - ccs = new ArrayList(); + ccs = new ArrayList<>(); ccs.add(newEmail); } else { ccs.add(newEmail); @@ -64,7 +64,7 @@ public void addBcc(Email email) { newEmail.setName(email.getName()); newEmail.setEmail(email.getEmail()); if (bccs == null) { - bccs = new ArrayList(); + bccs = new ArrayList<>(); bccs.add(newEmail); } else { bccs.add(newEmail); @@ -87,7 +87,7 @@ public Map getHeaders() { public void addHeader(String key, String value) { if (headers == null) { - headers = new HashMap(); + headers = new HashMap<>(); headers.put(key, value); } else { headers.put(key, value); @@ -101,7 +101,7 @@ public Map getSubstitutions() { public void addSubstitution(String key, String value) { if (substitutions == null) { - substitutions = new HashMap(); + substitutions = new HashMap<>(); substitutions.put(key, value); } else { substitutions.put(key, value); @@ -115,7 +115,7 @@ public Map getCustomArgs() { public void addCustomArg(String key, String value) { if (customArgs == null) { - customArgs = new HashMap(); + customArgs = new HashMap<>(); customArgs.put(key, value); } else { customArgs.put(key, value); diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java b/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java index 5818a145..23b5c2f4 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java @@ -1,4 +1,4 @@ -package com.sendgrid; +package com.sendgrid.helpers.mail.objects; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java index 85d1dc10..60caa5f1 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java @@ -1,4 +1,4 @@ -package com.sendgrid; +package com.sendgrid.helpers.mail.objects; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java index ad1121c2..332b9b27 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java @@ -1,4 +1,4 @@ -package com.sendgrid; +package com.sendgrid.helpers.mail.objects; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java index 4da565d5..2a3d0e74 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java @@ -1,4 +1,4 @@ -package com.sendgrid; +package com.sendgrid.helpers.mail.objects; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/src/test/java/com/sendgrid/MockSendGrid.java b/src/test/java/com/sendgrid/MockSendGrid.java index 35f65ae1..652f25d2 100644 --- a/src/test/java/com/sendgrid/MockSendGrid.java +++ b/src/test/java/com/sendgrid/MockSendGrid.java @@ -5,24 +5,25 @@ import java.util.Map; public class MockSendGrid extends SendGrid { - Request request; + private Request request; - public MockSendGrid(String apiKey) { - super(apiKey); - } + public MockSendGrid(String apiKey) { + super(apiKey); + } - public Response makeCall(Request request) throws IOException { - this.request = request; - Response response = new Response(); - response.setStatusCode(200); - response.setBody("{\"message\":\"success\"}"); - Map headers = new HashMap<>(); - headers.put("Test", "Header"); - response.setHeaders(headers); - return response; - } + @Override + public Response makeCall(Request request) throws IOException { + this.request = request; + Response response = new Response(); + response.setStatusCode(200); + response.setBody("{\"message\":\"success\"}"); + Map headers = new HashMap<>(); + headers.put("Test", "Header"); + response.setHeaders(headers); + return response; + } - public Request getRequest() { - return this.request; - } + public Request getRequest() { + return this.request; + } } \ No newline at end of file diff --git a/src/test/java/com/sendgrid/SendGridTest.java b/src/test/java/com/sendgrid/SendGridTest.java index 5ec45eab..dcb6092e 100644 --- a/src/test/java/com/sendgrid/SendGridTest.java +++ b/src/test/java/com/sendgrid/SendGridTest.java @@ -12,9 +12,9 @@ public class SendGridTest { private final String SENDGRID_API_KEY = ""; - public Map buildDefaultHeaders() { + private Map buildDefaultHeaders() { SendGrid sg = new SendGrid(SENDGRID_API_KEY); - Map requestHeaders = new HashMap(); + Map requestHeaders = new HashMap<>(); requestHeaders.put("Authorization", "Bearer " + SENDGRID_API_KEY); String USER_AGENT = "sendgrid/" + sg.getLibraryVersion() + ";java"; requestHeaders.put("User-agent", USER_AGENT); @@ -77,14 +77,7 @@ public void testHost() { @Test public void test_access_settings_activity_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -97,14 +90,7 @@ public void test_access_settings_activity_get() throws IOException { @Test public void test_access_settings_whitelist_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -117,14 +103,7 @@ public void test_access_settings_whitelist_post() throws IOException { @Test public void test_access_settings_whitelist_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -136,14 +115,7 @@ public void test_access_settings_whitelist_get() throws IOException { @Test public void test_access_settings_whitelist_delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -156,14 +128,7 @@ public void test_access_settings_whitelist_delete() throws IOException { @Test public void test_access_settings_whitelist__rule_id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -175,14 +140,7 @@ public void test_access_settings_whitelist__rule_id__get() throws IOException { @Test public void test_access_settings_whitelist__rule_id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -194,14 +152,7 @@ public void test_access_settings_whitelist__rule_id__delete() throws IOException @Test public void test_alerts_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -214,14 +165,7 @@ public void test_alerts_post() throws IOException { @Test public void test_alerts_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -233,14 +177,7 @@ public void test_alerts_get() throws IOException { @Test public void test_alerts__alert_id__patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -253,14 +190,7 @@ public void test_alerts__alert_id__patch() throws IOException { @Test public void test_alerts__alert_id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -272,14 +202,7 @@ public void test_alerts__alert_id__get() throws IOException { @Test public void test_alerts__alert_id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -291,14 +214,7 @@ public void test_alerts__alert_id__delete() throws IOException { @Test public void test_api_keys_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -311,14 +227,7 @@ public void test_api_keys_post() throws IOException { @Test public void test_api_keys_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -331,14 +240,7 @@ public void test_api_keys_get() throws IOException { @Test public void test_api_keys__api_key_id__put() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -351,14 +253,7 @@ public void test_api_keys__api_key_id__put() throws IOException { @Test public void test_api_keys__api_key_id__patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -371,14 +266,7 @@ public void test_api_keys__api_key_id__patch() throws IOException { @Test public void test_api_keys__api_key_id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -390,14 +278,7 @@ public void test_api_keys__api_key_id__get() throws IOException { @Test public void test_api_keys__api_key_id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -409,14 +290,7 @@ public void test_api_keys__api_key_id__delete() throws IOException { @Test public void test_asm_groups_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -429,14 +303,7 @@ public void test_asm_groups_post() throws IOException { @Test public void test_asm_groups_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -449,14 +316,7 @@ public void test_asm_groups_get() throws IOException { @Test public void test_asm_groups__group_id__patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -469,14 +329,7 @@ public void test_asm_groups__group_id__patch() throws IOException { @Test public void test_asm_groups__group_id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -488,14 +341,7 @@ public void test_asm_groups__group_id__get() throws IOException { @Test public void test_asm_groups__group_id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -507,14 +353,7 @@ public void test_asm_groups__group_id__delete() throws IOException { @Test public void test_asm_groups__group_id__suppressions_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -527,14 +366,7 @@ public void test_asm_groups__group_id__suppressions_post() throws IOException { @Test public void test_asm_groups__group_id__suppressions_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -546,14 +378,7 @@ public void test_asm_groups__group_id__suppressions_get() throws IOException { @Test public void test_asm_groups__group_id__suppressions_search_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -566,14 +391,7 @@ public void test_asm_groups__group_id__suppressions_search_post() throws IOExcep @Test public void test_asm_groups__group_id__suppressions__email__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -585,14 +403,7 @@ public void test_asm_groups__group_id__suppressions__email__delete() throws IOEx @Test public void test_asm_suppressions_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -604,14 +415,7 @@ public void test_asm_suppressions_get() throws IOException { @Test public void test_asm_suppressions_global_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -624,14 +428,7 @@ public void test_asm_suppressions_global_post() throws IOException { @Test public void test_asm_suppressions_global__email__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -643,14 +440,7 @@ public void test_asm_suppressions_global__email__get() throws IOException { @Test public void test_asm_suppressions_global__email__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -662,14 +452,7 @@ public void test_asm_suppressions_global__email__delete() throws IOException { @Test public void test_asm_suppressions__email__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -681,14 +464,7 @@ public void test_asm_suppressions__email__get() throws IOException { @Test public void test_browsers_stats_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -706,14 +482,7 @@ public void test_browsers_stats_get() throws IOException { @Test public void test_campaigns_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -726,14 +495,7 @@ public void test_campaigns_post() throws IOException { @Test public void test_campaigns_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -747,14 +509,7 @@ public void test_campaigns_get() throws IOException { @Test public void test_campaigns__campaign_id__patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -767,14 +522,7 @@ public void test_campaigns__campaign_id__patch() throws IOException { @Test public void test_campaigns__campaign_id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -786,14 +534,7 @@ public void test_campaigns__campaign_id__get() throws IOException { @Test public void test_campaigns__campaign_id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -805,14 +546,7 @@ public void test_campaigns__campaign_id__delete() throws IOException { @Test public void test_campaigns__campaign_id__schedules_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -825,14 +559,7 @@ public void test_campaigns__campaign_id__schedules_patch() throws IOException { @Test public void test_campaigns__campaign_id__schedules_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -845,14 +572,7 @@ public void test_campaigns__campaign_id__schedules_post() throws IOException { @Test public void test_campaigns__campaign_id__schedules_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -864,14 +584,7 @@ public void test_campaigns__campaign_id__schedules_get() throws IOException { @Test public void test_campaigns__campaign_id__schedules_delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -883,14 +596,7 @@ public void test_campaigns__campaign_id__schedules_delete() throws IOException { @Test public void test_campaigns__campaign_id__schedules_now_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -902,14 +608,7 @@ public void test_campaigns__campaign_id__schedules_now_post() throws IOException @Test public void test_campaigns__campaign_id__schedules_test_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -922,14 +621,7 @@ public void test_campaigns__campaign_id__schedules_test_post() throws IOExceptio @Test public void test_categories_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -944,14 +636,7 @@ public void test_categories_get() throws IOException { @Test public void test_categories_stats_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -969,14 +654,7 @@ public void test_categories_stats_get() throws IOException { @Test public void test_categories_stats_sums_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -995,14 +673,7 @@ public void test_categories_stats_sums_get() throws IOException { @Test public void test_clients_stats_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1017,14 +688,7 @@ public void test_clients_stats_get() throws IOException { @Test public void test_clients__client_type__stats_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1039,14 +703,7 @@ public void test_clients__client_type__stats_get() throws IOException { @Test public void test_contactdb_custom_fields_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -1059,14 +716,7 @@ public void test_contactdb_custom_fields_post() throws IOException { @Test public void test_contactdb_custom_fields_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1078,14 +728,7 @@ public void test_contactdb_custom_fields_get() throws IOException { @Test public void test_contactdb_custom_fields__custom_field_id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1097,14 +740,7 @@ public void test_contactdb_custom_fields__custom_field_id__get() throws IOExcept @Test public void test_contactdb_custom_fields__custom_field_id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "202"); Request request = new Request(); @@ -1116,14 +752,7 @@ public void test_contactdb_custom_fields__custom_field_id__delete() throws IOExc @Test public void test_contactdb_lists_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -1136,14 +765,7 @@ public void test_contactdb_lists_post() throws IOException { @Test public void test_contactdb_lists_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1155,14 +777,7 @@ public void test_contactdb_lists_get() throws IOException { @Test public void test_contactdb_lists_delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -1175,14 +790,7 @@ public void test_contactdb_lists_delete() throws IOException { @Test public void test_contactdb_lists__list_id__patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1196,14 +804,7 @@ public void test_contactdb_lists__list_id__patch() throws IOException { @Test public void test_contactdb_lists__list_id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1216,14 +817,7 @@ public void test_contactdb_lists__list_id__get() throws IOException { @Test public void test_contactdb_lists__list_id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "202"); Request request = new Request(); @@ -1236,14 +830,7 @@ public void test_contactdb_lists__list_id__delete() throws IOException { @Test public void test_contactdb_lists__list_id__recipients_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -1256,14 +843,7 @@ public void test_contactdb_lists__list_id__recipients_post() throws IOException @Test public void test_contactdb_lists__list_id__recipients_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1278,14 +858,7 @@ public void test_contactdb_lists__list_id__recipients_get() throws IOException { @Test public void test_contactdb_lists__list_id__recipients__recipient_id__post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -1297,14 +870,7 @@ public void test_contactdb_lists__list_id__recipients__recipient_id__post() thro @Test public void test_contactdb_lists__list_id__recipients__recipient_id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -1318,14 +884,7 @@ public void test_contactdb_lists__list_id__recipients__recipient_id__delete() th @Test public void test_contactdb_recipients_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -1338,14 +897,7 @@ public void test_contactdb_recipients_patch() throws IOException { @Test public void test_contactdb_recipients_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -1358,14 +910,7 @@ public void test_contactdb_recipients_post() throws IOException { @Test public void test_contactdb_recipients_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1379,14 +924,7 @@ public void test_contactdb_recipients_get() throws IOException { @Test public void test_contactdb_recipients_delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1399,14 +937,7 @@ public void test_contactdb_recipients_delete() throws IOException { @Test public void test_contactdb_recipients_billable_count_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1418,14 +949,7 @@ public void test_contactdb_recipients_billable_count_get() throws IOException { @Test public void test_contactdb_recipients_count_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1437,14 +961,7 @@ public void test_contactdb_recipients_count_get() throws IOException { @Test public void test_contactdb_recipients_search_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1457,14 +974,7 @@ public void test_contactdb_recipients_search_get() throws IOException { @Test public void test_contactdb_recipients__recipient_id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1476,14 +986,7 @@ public void test_contactdb_recipients__recipient_id__get() throws IOException { @Test public void test_contactdb_recipients__recipient_id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -1495,14 +998,7 @@ public void test_contactdb_recipients__recipient_id__delete() throws IOException @Test public void test_contactdb_recipients__recipient_id__lists_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1514,14 +1010,7 @@ public void test_contactdb_recipients__recipient_id__lists_get() throws IOExcept @Test public void test_contactdb_reserved_fields_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1533,14 +1022,7 @@ public void test_contactdb_reserved_fields_get() throws IOException { @Test public void test_contactdb_segments_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1553,14 +1035,7 @@ public void test_contactdb_segments_post() throws IOException { @Test public void test_contactdb_segments_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1572,14 +1047,7 @@ public void test_contactdb_segments_get() throws IOException { @Test public void test_contactdb_segments__segment_id__patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1593,14 +1061,7 @@ public void test_contactdb_segments__segment_id__patch() throws IOException { @Test public void test_contactdb_segments__segment_id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1613,14 +1074,7 @@ public void test_contactdb_segments__segment_id__get() throws IOException { @Test public void test_contactdb_segments__segment_id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -1633,14 +1087,7 @@ public void test_contactdb_segments__segment_id__delete() throws IOException { @Test public void test_contactdb_segments__segment_id__recipients_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1654,14 +1101,7 @@ public void test_contactdb_segments__segment_id__recipients_get() throws IOExcep @Test public void test_devices_stats_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1678,14 +1118,7 @@ public void test_devices_stats_get() throws IOException { @Test public void test_geo_stats_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1703,14 +1136,7 @@ public void test_geo_stats_get() throws IOException { @Test public void test_ips_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1727,14 +1153,7 @@ public void test_ips_get() throws IOException { @Test public void test_ips_assigned_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1746,14 +1165,7 @@ public void test_ips_assigned_get() throws IOException { @Test public void test_ips_pools_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1766,14 +1178,7 @@ public void test_ips_pools_post() throws IOException { @Test public void test_ips_pools_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1785,14 +1190,7 @@ public void test_ips_pools_get() throws IOException { @Test public void test_ips_pools__pool_name__put() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1805,14 +1203,7 @@ public void test_ips_pools__pool_name__put() throws IOException { @Test public void test_ips_pools__pool_name__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1824,14 +1215,7 @@ public void test_ips_pools__pool_name__get() throws IOException { @Test public void test_ips_pools__pool_name__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -1843,14 +1227,7 @@ public void test_ips_pools__pool_name__delete() throws IOException { @Test public void test_ips_pools__pool_name__ips_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -1863,14 +1240,7 @@ public void test_ips_pools__pool_name__ips_post() throws IOException { @Test public void test_ips_pools__pool_name__ips__ip__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -1882,14 +1252,7 @@ public void test_ips_pools__pool_name__ips__ip__delete() throws IOException { @Test public void test_ips_warmup_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1902,14 +1265,7 @@ public void test_ips_warmup_post() throws IOException { @Test public void test_ips_warmup_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1921,14 +1277,7 @@ public void test_ips_warmup_get() throws IOException { @Test public void test_ips_warmup__ip_address__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1940,14 +1289,7 @@ public void test_ips_warmup__ip_address__get() throws IOException { @Test public void test_ips_warmup__ip_address__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -1959,14 +1301,7 @@ public void test_ips_warmup__ip_address__delete() throws IOException { @Test public void test_ips__ip_address__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -1978,14 +1313,7 @@ public void test_ips__ip_address__get() throws IOException { @Test public void test_mail_batch_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -1997,14 +1325,7 @@ public void test_mail_batch_post() throws IOException { @Test public void test_mail_batch__batch_id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2016,14 +1337,7 @@ public void test_mail_batch__batch_id__get() throws IOException { @Test public void test_mail_send_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "202"); Request request = new Request(); @@ -2036,14 +1350,7 @@ public void test_mail_send_post() throws IOException { @Test public void test_mail_settings_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2057,14 +1364,7 @@ public void test_mail_settings_get() throws IOException { @Test public void test_mail_settings_address_whitelist_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2077,14 +1377,7 @@ public void test_mail_settings_address_whitelist_patch() throws IOException { @Test public void test_mail_settings_address_whitelist_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2096,14 +1389,7 @@ public void test_mail_settings_address_whitelist_get() throws IOException { @Test public void test_mail_settings_bcc_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2116,14 +1402,7 @@ public void test_mail_settings_bcc_patch() throws IOException { @Test public void test_mail_settings_bcc_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2135,14 +1414,7 @@ public void test_mail_settings_bcc_get() throws IOException { @Test public void test_mail_settings_bounce_purge_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2155,14 +1427,7 @@ public void test_mail_settings_bounce_purge_patch() throws IOException { @Test public void test_mail_settings_bounce_purge_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2174,14 +1439,7 @@ public void test_mail_settings_bounce_purge_get() throws IOException { @Test public void test_mail_settings_footer_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2194,14 +1452,7 @@ public void test_mail_settings_footer_patch() throws IOException { @Test public void test_mail_settings_footer_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2213,14 +1464,7 @@ public void test_mail_settings_footer_get() throws IOException { @Test public void test_mail_settings_forward_bounce_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2233,14 +1477,7 @@ public void test_mail_settings_forward_bounce_patch() throws IOException { @Test public void test_mail_settings_forward_bounce_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2252,14 +1489,7 @@ public void test_mail_settings_forward_bounce_get() throws IOException { @Test public void test_mail_settings_forward_spam_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2272,14 +1502,7 @@ public void test_mail_settings_forward_spam_patch() throws IOException { @Test public void test_mail_settings_forward_spam_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2291,14 +1514,7 @@ public void test_mail_settings_forward_spam_get() throws IOException { @Test public void test_mail_settings_plain_content_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2311,14 +1527,7 @@ public void test_mail_settings_plain_content_patch() throws IOException { @Test public void test_mail_settings_plain_content_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2330,14 +1539,7 @@ public void test_mail_settings_plain_content_get() throws IOException { @Test public void test_mail_settings_spam_check_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2350,14 +1552,7 @@ public void test_mail_settings_spam_check_patch() throws IOException { @Test public void test_mail_settings_spam_check_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2369,14 +1564,7 @@ public void test_mail_settings_spam_check_get() throws IOException { @Test public void test_mail_settings_template_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2389,14 +1577,7 @@ public void test_mail_settings_template_patch() throws IOException { @Test public void test_mail_settings_template_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2408,14 +1589,7 @@ public void test_mail_settings_template_get() throws IOException { @Test public void test_mailbox_providers_stats_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2433,14 +1607,7 @@ public void test_mailbox_providers_stats_get() throws IOException { @Test public void test_partner_settings_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2454,14 +1621,7 @@ public void test_partner_settings_get() throws IOException { @Test public void test_partner_settings_new_relic_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2474,14 +1634,7 @@ public void test_partner_settings_new_relic_patch() throws IOException { @Test public void test_partner_settings_new_relic_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2493,14 +1646,7 @@ public void test_partner_settings_new_relic_get() throws IOException { @Test public void test_scopes_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2512,14 +1658,7 @@ public void test_scopes_get() throws IOException { @Test public void test_senders_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -2532,14 +1671,7 @@ public void test_senders_post() throws IOException { @Test public void test_senders_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2551,14 +1683,7 @@ public void test_senders_get() throws IOException { @Test public void test_senders__sender_id__patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2571,14 +1696,7 @@ public void test_senders__sender_id__patch() throws IOException { @Test public void test_senders__sender_id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2590,14 +1708,7 @@ public void test_senders__sender_id__get() throws IOException { @Test public void test_senders__sender_id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -2609,14 +1720,7 @@ public void test_senders__sender_id__delete() throws IOException { @Test public void test_senders__sender_id__resend_verification_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -2628,14 +1732,7 @@ public void test_senders__sender_id__resend_verification_post() throws IOExcepti @Test public void test_stats_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2652,14 +1749,7 @@ public void test_stats_get() throws IOException { @Test public void test_subusers_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2672,14 +1762,7 @@ public void test_subusers_post() throws IOException { @Test public void test_subusers_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2694,14 +1777,7 @@ public void test_subusers_get() throws IOException { @Test public void test_subusers_reputations_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2714,14 +1790,7 @@ public void test_subusers_reputations_get() throws IOException { @Test public void test_subusers_stats_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2739,14 +1808,7 @@ public void test_subusers_stats_get() throws IOException { @Test public void test_subusers_stats_monthly_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2764,14 +1826,7 @@ public void test_subusers_stats_monthly_get() throws IOException { @Test public void test_subusers_stats_sums_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2790,14 +1845,7 @@ public void test_subusers_stats_sums_get() throws IOException { @Test public void test_subusers__subuser_name__patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -2810,14 +1858,7 @@ public void test_subusers__subuser_name__patch() throws IOException { @Test public void test_subusers__subuser_name__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -2829,14 +1870,7 @@ public void test_subusers__subuser_name__delete() throws IOException { @Test public void test_subusers__subuser_name__ips_put() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2849,14 +1883,7 @@ public void test_subusers__subuser_name__ips_put() throws IOException { @Test public void test_subusers__subuser_name__monitor_put() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2869,14 +1896,7 @@ public void test_subusers__subuser_name__monitor_put() throws IOException { @Test public void test_subusers__subuser_name__monitor_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2889,14 +1909,7 @@ public void test_subusers__subuser_name__monitor_post() throws IOException { @Test public void test_subusers__subuser_name__monitor_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2908,14 +1921,7 @@ public void test_subusers__subuser_name__monitor_get() throws IOException { @Test public void test_subusers__subuser_name__monitor_delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -2927,14 +1933,7 @@ public void test_subusers__subuser_name__monitor_delete() throws IOException { @Test public void test_subusers__subuser_name__stats_monthly_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2951,14 +1950,7 @@ public void test_subusers__subuser_name__stats_monthly_get() throws IOException @Test public void test_suppression_blocks_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -2974,14 +1966,7 @@ public void test_suppression_blocks_get() throws IOException { @Test public void test_suppression_blocks_delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -2994,14 +1979,7 @@ public void test_suppression_blocks_delete() throws IOException { @Test public void test_suppression_blocks__email__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3013,14 +1991,7 @@ public void test_suppression_blocks__email__get() throws IOException { @Test public void test_suppression_blocks__email__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -3032,14 +2003,7 @@ public void test_suppression_blocks__email__delete() throws IOException { @Test public void test_suppression_bounces_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3053,14 +2017,7 @@ public void test_suppression_bounces_get() throws IOException { @Test public void test_suppression_bounces_delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -3073,14 +2030,7 @@ public void test_suppression_bounces_delete() throws IOException { @Test public void test_suppression_bounces__email__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3092,14 +2042,7 @@ public void test_suppression_bounces__email__get() throws IOException { @Test public void test_suppression_bounces__email__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -3112,14 +2055,7 @@ public void test_suppression_bounces__email__delete() throws IOException { @Test public void test_suppression_invalid_emails_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3135,14 +2071,7 @@ public void test_suppression_invalid_emails_get() throws IOException { @Test public void test_suppression_invalid_emails_delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -3155,14 +2084,7 @@ public void test_suppression_invalid_emails_delete() throws IOException { @Test public void test_suppression_invalid_emails__email__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3174,14 +2096,7 @@ public void test_suppression_invalid_emails__email__get() throws IOException { @Test public void test_suppression_invalid_emails__email__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -3193,14 +2108,7 @@ public void test_suppression_invalid_emails__email__delete() throws IOException @Test public void test_suppression_spam_report__email__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3212,14 +2120,7 @@ public void test_suppression_spam_report__email__get() throws IOException { @Test public void test_suppression_spam_report__email__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -3231,14 +2132,7 @@ public void test_suppression_spam_report__email__delete() throws IOException { @Test public void test_suppression_spam_reports_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3254,14 +2148,7 @@ public void test_suppression_spam_reports_get() throws IOException { @Test public void test_suppression_spam_reports_delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -3274,14 +2161,7 @@ public void test_suppression_spam_reports_delete() throws IOException { @Test public void test_suppression_unsubscribes_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3297,14 +2177,7 @@ public void test_suppression_unsubscribes_get() throws IOException { @Test public void test_templates_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -3317,14 +2190,7 @@ public void test_templates_post() throws IOException { @Test public void test_templates_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3336,14 +2202,7 @@ public void test_templates_get() throws IOException { @Test public void test_templates__template_id__patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3356,14 +2215,7 @@ public void test_templates__template_id__patch() throws IOException { @Test public void test_templates__template_id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3375,14 +2227,7 @@ public void test_templates__template_id__get() throws IOException { @Test public void test_templates__template_id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -3394,14 +2239,7 @@ public void test_templates__template_id__delete() throws IOException { @Test public void test_templates__template_id__versions_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -3414,14 +2252,7 @@ public void test_templates__template_id__versions_post() throws IOException { @Test public void test_templates__template_id__versions__version_id__patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3434,14 +2265,7 @@ public void test_templates__template_id__versions__version_id__patch() throws IO @Test public void test_templates__template_id__versions__version_id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3453,14 +2277,7 @@ public void test_templates__template_id__versions__version_id__get() throws IOEx @Test public void test_templates__template_id__versions__version_id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -3472,14 +2289,7 @@ public void test_templates__template_id__versions__version_id__delete() throws I @Test public void test_templates__template_id__versions__version_id__activate_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3491,14 +2301,7 @@ public void test_templates__template_id__versions__version_id__activate_post() t @Test public void test_tracking_settings_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3512,14 +2315,7 @@ public void test_tracking_settings_get() throws IOException { @Test public void test_tracking_settings_click_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3532,14 +2328,7 @@ public void test_tracking_settings_click_patch() throws IOException { @Test public void test_tracking_settings_click_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3551,14 +2340,7 @@ public void test_tracking_settings_click_get() throws IOException { @Test public void test_tracking_settings_google_analytics_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3571,14 +2353,7 @@ public void test_tracking_settings_google_analytics_patch() throws IOException { @Test public void test_tracking_settings_google_analytics_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3590,14 +2365,7 @@ public void test_tracking_settings_google_analytics_get() throws IOException { @Test public void test_tracking_settings_open_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3610,14 +2378,7 @@ public void test_tracking_settings_open_patch() throws IOException { @Test public void test_tracking_settings_open_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3629,14 +2390,7 @@ public void test_tracking_settings_open_get() throws IOException { @Test public void test_tracking_settings_subscription_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3649,14 +2403,7 @@ public void test_tracking_settings_subscription_patch() throws IOException { @Test public void test_tracking_settings_subscription_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3668,14 +2415,7 @@ public void test_tracking_settings_subscription_get() throws IOException { @Test public void test_user_account_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3687,14 +2427,7 @@ public void test_user_account_get() throws IOException { @Test public void test_user_credits_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3706,14 +2439,7 @@ public void test_user_credits_get() throws IOException { @Test public void test_user_email_put() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3726,14 +2452,7 @@ public void test_user_email_put() throws IOException { @Test public void test_user_email_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3745,14 +2464,7 @@ public void test_user_email_get() throws IOException { @Test public void test_user_password_put() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3765,14 +2477,7 @@ public void test_user_password_put() throws IOException { @Test public void test_user_profile_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3785,14 +2490,7 @@ public void test_user_profile_patch() throws IOException { @Test public void test_user_profile_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3804,14 +2502,7 @@ public void test_user_profile_get() throws IOException { @Test public void test_user_scheduled_sends_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -3824,14 +2515,7 @@ public void test_user_scheduled_sends_post() throws IOException { @Test public void test_user_scheduled_sends_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3843,14 +2527,7 @@ public void test_user_scheduled_sends_get() throws IOException { @Test public void test_user_scheduled_sends__batch_id__patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -3863,14 +2540,7 @@ public void test_user_scheduled_sends__batch_id__patch() throws IOException { @Test public void test_user_scheduled_sends__batch_id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3882,14 +2552,7 @@ public void test_user_scheduled_sends__batch_id__get() throws IOException { @Test public void test_user_scheduled_sends__batch_id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -3901,14 +2564,7 @@ public void test_user_scheduled_sends__batch_id__delete() throws IOException { @Test public void test_user_settings_enforced_tls_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3921,14 +2577,7 @@ public void test_user_settings_enforced_tls_patch() throws IOException { @Test public void test_user_settings_enforced_tls_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3940,14 +2589,7 @@ public void test_user_settings_enforced_tls_get() throws IOException { @Test public void test_user_username_put() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3960,14 +2602,7 @@ public void test_user_username_put() throws IOException { @Test public void test_user_username_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3979,14 +2614,7 @@ public void test_user_username_get() throws IOException { @Test public void test_user_webhooks_event_settings_patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -3999,14 +2627,7 @@ public void test_user_webhooks_event_settings_patch() throws IOException { @Test public void test_user_webhooks_event_settings_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4018,14 +2639,7 @@ public void test_user_webhooks_event_settings_get() throws IOException { @Test public void test_user_webhooks_event_test_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -4038,14 +2652,7 @@ public void test_user_webhooks_event_test_post() throws IOException { @Test public void test_user_webhooks_parse_settings_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -4058,14 +2665,7 @@ public void test_user_webhooks_parse_settings_post() throws IOException { @Test public void test_user_webhooks_parse_settings_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4077,14 +2677,7 @@ public void test_user_webhooks_parse_settings_get() throws IOException { @Test public void test_user_webhooks_parse_settings__hostname__patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4097,14 +2690,7 @@ public void test_user_webhooks_parse_settings__hostname__patch() throws IOExcept @Test public void test_user_webhooks_parse_settings__hostname__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4116,14 +2702,7 @@ public void test_user_webhooks_parse_settings__hostname__get() throws IOExceptio @Test public void test_user_webhooks_parse_settings__hostname__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -4135,14 +2714,7 @@ public void test_user_webhooks_parse_settings__hostname__delete() throws IOExcep @Test public void test_user_webhooks_parse_stats_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4159,14 +2731,7 @@ public void test_user_webhooks_parse_stats_get() throws IOException { @Test public void test_whitelabel_domains_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -4179,14 +2744,7 @@ public void test_whitelabel_domains_post() throws IOException { @Test public void test_whitelabel_domains_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4203,14 +2761,7 @@ public void test_whitelabel_domains_get() throws IOException { @Test public void test_whitelabel_domains_default_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4222,14 +2773,7 @@ public void test_whitelabel_domains_default_get() throws IOException { @Test public void test_whitelabel_domains_subuser_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4241,14 +2785,7 @@ public void test_whitelabel_domains_subuser_get() throws IOException { @Test public void test_whitelabel_domains_subuser_delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -4260,14 +2797,7 @@ public void test_whitelabel_domains_subuser_delete() throws IOException { @Test public void test_whitelabel_domains__domain_id__patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4280,14 +2810,7 @@ public void test_whitelabel_domains__domain_id__patch() throws IOException { @Test public void test_whitelabel_domains__domain_id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4299,14 +2822,7 @@ public void test_whitelabel_domains__domain_id__get() throws IOException { @Test public void test_whitelabel_domains__domain_id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -4318,14 +2834,7 @@ public void test_whitelabel_domains__domain_id__delete() throws IOException { @Test public void test_whitelabel_domains__domain_id__subuser_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -4338,14 +2847,7 @@ public void test_whitelabel_domains__domain_id__subuser_post() throws IOExceptio @Test public void test_whitelabel_domains__id__ips_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4358,14 +2860,7 @@ public void test_whitelabel_domains__id__ips_post() throws IOException { @Test public void test_whitelabel_domains__id__ips__ip__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4377,14 +2872,7 @@ public void test_whitelabel_domains__id__ips__ip__delete() throws IOException { @Test public void test_whitelabel_domains__id__validate_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4396,14 +2884,7 @@ public void test_whitelabel_domains__id__validate_post() throws IOException { @Test public void test_whitelabel_ips_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -4416,14 +2897,7 @@ public void test_whitelabel_ips_post() throws IOException { @Test public void test_whitelabel_ips_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4438,14 +2912,7 @@ public void test_whitelabel_ips_get() throws IOException { @Test public void test_whitelabel_ips__id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4457,14 +2924,7 @@ public void test_whitelabel_ips__id__get() throws IOException { @Test public void test_whitelabel_ips__id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -4476,14 +2936,7 @@ public void test_whitelabel_ips__id__delete() throws IOException { @Test public void test_whitelabel_ips__id__validate_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4495,14 +2948,7 @@ public void test_whitelabel_ips__id__validate_post() throws IOException { @Test public void test_whitelabel_links_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "201"); Request request = new Request(); @@ -4517,14 +2963,7 @@ public void test_whitelabel_links_post() throws IOException { @Test public void test_whitelabel_links_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4537,14 +2976,7 @@ public void test_whitelabel_links_get() throws IOException { @Test public void test_whitelabel_links_default_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4557,14 +2989,7 @@ public void test_whitelabel_links_default_get() throws IOException { @Test public void test_whitelabel_links_subuser_get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4577,14 +3002,7 @@ public void test_whitelabel_links_subuser_get() throws IOException { @Test public void test_whitelabel_links_subuser_delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -4597,14 +3015,7 @@ public void test_whitelabel_links_subuser_delete() throws IOException { @Test public void test_whitelabel_links__id__patch() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4617,14 +3028,7 @@ public void test_whitelabel_links__id__patch() throws IOException { @Test public void test_whitelabel_links__id__get() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4636,14 +3040,7 @@ public void test_whitelabel_links__id__get() throws IOException { @Test public void test_whitelabel_links__id__delete() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "204"); Request request = new Request(); @@ -4655,14 +3052,7 @@ public void test_whitelabel_links__id__delete() throws IOException { @Test public void test_whitelabel_links__id__validate_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4674,14 +3064,7 @@ public void test_whitelabel_links__id__validate_post() throws IOException { @Test public void test_whitelabel_links__link_id__subuser_post() throws IOException { - SendGrid sg = null; - if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { - sg = new SendGrid("SENDGRID_API_KEY"); - sg.setHost(System.getenv("MOCK_HOST")); - } else { - sg = new SendGrid("SENDGRID_API_KEY", true); - sg.setHost("localhost:4010"); - } + SendGrid sg = createSendGrid(); sg.addRequestHeader("X-Mock", "200"); Request request = new Request(); @@ -4692,4 +3075,15 @@ public void test_whitelabel_links__link_id__subuser_post() throws IOException { Assert.assertEquals(200, response.getStatusCode()); } + private SendGrid createSendGrid() { + SendGrid sg; +// if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) { +// sg = new SendGrid("SENDGRID_API_KEY"); +// sg.setHost(System.getenv("MOCK_HOST")); +// } else { + sg = new SendGrid("SENDGRID_API_KEY", true); + sg.setHost("localhost:4010"); +// } + return sg; + } } diff --git a/src/test/java/com/sendgrid/helpers/AttachmentBuilderTest.java b/src/test/java/com/sendgrid/helpers/AttachmentBuilderTest.java index 824e8145..3ea3f379 100644 --- a/src/test/java/com/sendgrid/helpers/AttachmentBuilderTest.java +++ b/src/test/java/com/sendgrid/helpers/AttachmentBuilderTest.java @@ -1,6 +1,6 @@ package com.sendgrid.helpers; -import com.sendgrid.Attachments; +import com.sendgrid.helpers.mail.objects.Attachments; import org.apache.commons.codec.binary.Base64; import org.junit.Assert; import org.junit.Test; diff --git a/src/test/java/com/sendgrid/helpers/MailTest.java b/src/test/java/com/sendgrid/helpers/MailTest.java index e4eedd58..9476a1d5 100644 --- a/src/test/java/com/sendgrid/helpers/MailTest.java +++ b/src/test/java/com/sendgrid/helpers/MailTest.java @@ -1,7 +1,8 @@ -package com.sendgrid; +package com.sendgrid.helpers; +import com.sendgrid.helpers.mail.Mail; +import com.sendgrid.helpers.mail.objects.*; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; import java.io.IOException;