diff --git a/LICENSE b/LICENSE index b9c823a..947fcf7 100644 --- a/LICENSE +++ b/LICENSE @@ -14,7 +14,7 @@ copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE diff --git a/src/main/java/com/wildbit/java/postmark/client/ApiClient.java b/src/main/java/com/wildbit/java/postmark/client/ApiClient.java index 2eb7ac6..f91d3b0 100644 --- a/src/main/java/com/wildbit/java/postmark/client/ApiClient.java +++ b/src/main/java/com/wildbit/java/postmark/client/ApiClient.java @@ -120,9 +120,9 @@ public TemplateValidation validateTemplate(TemplateToValidate data) throws Postm public MessageResponse deliverMessage(TemplatedMessage data) throws PostmarkException, IOException { - /** - * Since template models can be complex, it is allowed that template model is a String or Object. - * If it's a String, we will auto convert it to Object. + /* + Since template models can be complex, it is allowed that template model is a String or Object. + If it's a String, we will auto convert it to Object. */ if (data.getTemplateModel().getClass() == String.class) { data.setTemplateModel(dataHandler.fromJson(data.getTemplateModel().toString(),Object.class)); @@ -191,7 +191,7 @@ public OutboundMessageClicks getMessageClicks(String id, Parameters parameters) } /* - Inbound Messsages + Inbound Messages */ public InboundMessages getInboundMessages(Parameters parameters) throws PostmarkException, IOException { diff --git a/src/main/java/com/wildbit/java/postmark/client/HttpClientHandler.java b/src/main/java/com/wildbit/java/postmark/client/HttpClientHandler.java index a840293..7bc45b1 100644 --- a/src/main/java/com/wildbit/java/postmark/client/HttpClientHandler.java +++ b/src/main/java/com/wildbit/java/postmark/client/HttpClientHandler.java @@ -50,12 +50,11 @@ protected String execute(HttpClient.REQUEST_TYPES request_type, String url) thro * @param request_type HTTP request type * @param url HTTP request URL * @param data request data to send - * @return HTTP response message * @throws PostmarkException Errors thrown by invalid or unhandled requests made to Postmark * @throws IOException Errors thrown by Data Handler * * @see HttpClient for details about HTTP request execution. - * @return request response + * @return HTTP response message */ protected String execute(HttpClient.REQUEST_TYPES request_type, String url, Object data) throws PostmarkException, IOException { HttpClient.ClientResponse response = httpClient.execute(request_type, getSecureUrl(url), dataHandler.toJson(data)); diff --git a/src/main/java/com/wildbit/java/postmark/client/Parameters.java b/src/main/java/com/wildbit/java/postmark/client/Parameters.java index 31187a5..7cac117 100644 --- a/src/main/java/com/wildbit/java/postmark/client/Parameters.java +++ b/src/main/java/com/wildbit/java/postmark/client/Parameters.java @@ -68,7 +68,7 @@ public String toString() { for (HashMap.Entry entry : parameters.entrySet()) { parameterString += addParameters(parameterString, entry.getKey() + "=" + entry.getValue()); - }; + } return parameterString; } diff --git a/src/main/java/com/wildbit/java/postmark/client/data/DataHandler.java b/src/main/java/com/wildbit/java/postmark/client/data/DataHandler.java index 3b0bba0..26e7831 100644 --- a/src/main/java/com/wildbit/java/postmark/client/data/DataHandler.java +++ b/src/main/java/com/wildbit/java/postmark/client/data/DataHandler.java @@ -5,7 +5,6 @@ import com.fasterxml.jackson.databind.*; import java.io.IOException; -import java.util.ArrayList; /** * This class represents data handler between API client and HTTP client. @@ -72,8 +71,8 @@ public String formatErrorMessage(String data) throws IOException { } /** - * Sets data mapper to be strict when making conversion of data to POJO objects. - * If there is a mismatch between POJO object and String in any other case than letter case, + * Sets data mapper to be strict when making conversion of data to objects. + * If there is a mismatch between object and String in any other case than letter case, * exception will be thrown. */ public void setStrictMapper() { @@ -84,7 +83,7 @@ public void setStrictMapper() { } /** - * Sets data mapper to be very liberal when making conversion of data to POJO objects. + * Sets data mapper to be very liberal when making conversion of data to objects. * Most of the time exception will NOT be thrown. */ public void setLiberalMapper() { diff --git a/src/main/java/com/wildbit/java/postmark/client/data/model/message/BaseMessage.java b/src/main/java/com/wildbit/java/postmark/client/data/model/message/BaseMessage.java index bec0354..867da9e 100644 --- a/src/main/java/com/wildbit/java/postmark/client/data/model/message/BaseMessage.java +++ b/src/main/java/com/wildbit/java/postmark/client/data/model/message/BaseMessage.java @@ -189,13 +189,13 @@ public void setHeaders(ArrayList
headers) { public void addHeader(String name, String value) { if (this.headers == null) { - setHeaders(new ArrayList
()); + setHeaders(new ArrayList<>()); } this.headers.add(new Header(name,value)); } public void clearHeaders() { - if (this.headers == null) { + if (this.headers != null) { this.headers.clear(); } } diff --git a/src/main/java/com/wildbit/java/postmark/client/data/model/message/BaseMessageResponse.java b/src/main/java/com/wildbit/java/postmark/client/data/model/message/BaseMessageResponse.java index cfafdd4..89f8baa 100644 --- a/src/main/java/com/wildbit/java/postmark/client/data/model/message/BaseMessageResponse.java +++ b/src/main/java/com/wildbit/java/postmark/client/data/model/message/BaseMessageResponse.java @@ -1,5 +1,4 @@ package com.wildbit.java.postmark.client.data.model.message; -import java.util.Date; /** * HTTP send request response object diff --git a/src/main/java/com/wildbit/java/postmark/client/data/model/stats/BaseStat.java b/src/main/java/com/wildbit/java/postmark/client/data/model/stats/BaseStat.java index 5b466e2..383b745 100644 --- a/src/main/java/com/wildbit/java/postmark/client/data/model/stats/BaseStat.java +++ b/src/main/java/com/wildbit/java/postmark/client/data/model/stats/BaseStat.java @@ -3,7 +3,7 @@ import java.util.Date; /** - * Parrent stats class - object. Contains attributes each stat contains. + * Parent stats class - object. Contains attributes each stat contains. */ public class BaseStat { diff --git a/src/main/java/com/wildbit/java/postmark/client/data/model/templates/BaseTemplatedMessage.java b/src/main/java/com/wildbit/java/postmark/client/data/model/templates/BaseTemplatedMessage.java index 9602296..41672f8 100644 --- a/src/main/java/com/wildbit/java/postmark/client/data/model/templates/BaseTemplatedMessage.java +++ b/src/main/java/com/wildbit/java/postmark/client/data/model/templates/BaseTemplatedMessage.java @@ -162,13 +162,13 @@ public void setHeaders(ArrayList
headers) { public void addHeader(String name, String value) { if (this.headers == null) { - setHeaders(new ArrayList
()); + setHeaders(new ArrayList<>()); } this.headers.add(new Header(name,value)); } public void clearHeaders() { - if (this.headers == null) { + if (this.headers != null) { this.headers.clear(); } } @@ -211,16 +211,16 @@ private String readFileContentType(String path) { */ private String convertRecipients(HashMap recipients) { - String recipientsString = ""; + StringBuilder recipientsString = new StringBuilder(); Iterator> entries = recipients.entrySet().iterator(); while (entries.hasNext()) { HashMap.Entry entry = entries.next(); - recipientsString += "\"" + entry.getKey() + "\"" + "<" + entry.getValue() + ">"; - if (entries.hasNext()) { recipientsString += ","; } + recipientsString.append("\"").append(entry.getKey()).append("\"").append("<").append(entry.getValue()).append(">"); + if (entries.hasNext()) { recipientsString.append(","); } } - return recipientsString; + return recipientsString.toString(); } } diff --git a/src/main/resources/.properties b/src/main/resources/.properties index 6625b46..35b4ac2 100644 --- a/src/main/resources/.properties +++ b/src/main/resources/.properties @@ -1 +1 @@ -Version: ${postmark.version} \ No newline at end of file +Version= ${postmark.version} \ No newline at end of file diff --git a/src/test/java/MessageTest.java b/src/test/java/MessageTest.java index e3dd316..c4c7755 100644 --- a/src/test/java/MessageTest.java +++ b/src/test/java/MessageTest.java @@ -1,6 +1,5 @@ import com.wildbit.java.postmark.Postmark; import com.wildbit.java.postmark.client.ApiClient; -import com.wildbit.java.postmark.client.data.DataHandler; import com.wildbit.java.postmark.client.data.model.message.Message; import com.wildbit.java.postmark.client.data.model.message.MessageResponse; import com.wildbit.java.postmark.client.exception.InvalidMessageException; @@ -31,10 +30,7 @@ void send() throws PostmarkException, IOException { void invalidMessagetoSend() throws PostmarkException, IOException { Message message = new Message("from@example.com", null, "Hello from Postmark!", "Hello body"); - Throwable exception = assertThrows(InvalidMessageException.class, () -> { - client.deliverMessage(message); - }); - + Throwable exception = assertThrows(InvalidMessageException.class, () -> client.deliverMessage(message)); assertEquals("Zero recipients specified", exception.getMessage()); } } diff --git a/src/test/java/MessagesTest.java b/src/test/java/MessagesTest.java index 5deb89a..97e1ea0 100644 --- a/src/test/java/MessagesTest.java +++ b/src/test/java/MessagesTest.java @@ -6,7 +6,6 @@ import java.io.IOException; -import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/src/test/java/PostmarkTest.java b/src/test/java/PostmarkTest.java index 2bc7b54..f01ad5c 100644 --- a/src/test/java/PostmarkTest.java +++ b/src/test/java/PostmarkTest.java @@ -2,7 +2,6 @@ import org.junit.jupiter.api.Test; import java.io.IOException; -import java.util.Map; import static org.junit.jupiter.api.Assertions.*; diff --git a/src/test/java/client/HttpClientTest.java b/src/test/java/client/HttpClientTest.java index bc9136f..ec0c7bb 100644 --- a/src/test/java/client/HttpClientTest.java +++ b/src/test/java/client/HttpClientTest.java @@ -1,13 +1,8 @@ package client; -import com.wildbit.java.postmark.client.BaseApiClient; -import com.wildbit.java.postmark.client.HttpClient; -import com.wildbit.java.postmark.client.HttpClientHandler; import com.wildbit.java.postmark.client.exception.PostmarkException; import org.junit.jupiter.api.Test; -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; import java.io.IOException; import java.util.*; diff --git a/src/test/java/client/data/DataHandlerTest.java b/src/test/java/client/data/DataHandlerTest.java index c97c3d5..1ee65f4 100644 --- a/src/test/java/client/data/DataHandlerTest.java +++ b/src/test/java/client/data/DataHandlerTest.java @@ -28,12 +28,11 @@ HashMap getHashMap() { } String getStringHashMap() { - String stringHashMap = "{\n" + + + return "{\n" + " \"Key2\" : \"Value2\",\n" + " \"Key1\" : \"Value1\"\n" + "}"; - - return stringHashMap; } @Test @@ -45,7 +44,7 @@ void liberalMapper() throws IOException { @Test void strictMapper() throws IOException { Throwable exception = assertThrows(UnrecognizedPropertyException.class, - ()->{dataHandler.fromJson(getStringHashMap(), BaseMessageResponse.class);} ); + ()-> dataHandler.fromJson(getStringHashMap(), BaseMessageResponse.class)); } diff --git a/src/test/java/data/MessageTest.java b/src/test/java/data/MessageTest.java index 575edf3..6a17da6 100644 --- a/src/test/java/data/MessageTest.java +++ b/src/test/java/data/MessageTest.java @@ -1,14 +1,10 @@ package data; -import com.wildbit.java.postmark.Postmark; -import com.wildbit.java.postmark.client.ApiClient; import com.wildbit.java.postmark.client.data.DataHandler; import com.wildbit.java.postmark.client.data.model.message.Message; import org.junit.jupiter.api.Test; -import javax.ws.rs.core.MultivaluedHashMap; - import java.io.IOException; import java.util.ArrayList; import java.util.HashMap;