Skip to content

Commit 56d7e3e

Browse files
committed
Added unit tests and updated existing
1 parent 1dc6a6c commit 56d7e3e

19 files changed

Lines changed: 1343 additions & 147 deletions

lombok.config

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# this is root dir and don't search for parent
2+
config.stopBubbling = true
3+
# add @Generated and Jacoco will detect Lombok generated code and ignore them in reports
4+
lombok.addLombokGeneratedAnnotation = true
5+
6+
# Copy the Qualifier annotation from the instance variables to the constructor
7+
# see https://github.com/rzwitserloot/lombok/issues/745
8+
lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Qualifier
9+
lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Value
10+
11+
lombok.equalsAndHashCode.callSuper=call
12+
lombok.toString.callSuper=call
13+
14+
# Use JDK's NonNull annotation instead of Lombok's
15+
lombok.nonNull.exceptionType = JDK

pom.xml

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@
8383
</dependency>
8484
<dependency>
8585
<groupId>org.mockito</groupId>
86-
<artifactId>mockito-all</artifactId>
87-
<version>1.10.19</version>
86+
<artifactId>mockito-core</artifactId>
87+
<version>4.11.0</version>
8888
<scope>test</scope>
8989
</dependency>
9090
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/mockwebserver -->
@@ -201,6 +201,68 @@
201201
<target>11</target>
202202
</configuration>
203203
</plugin>
204+
<plugin>
205+
<groupId>org.jacoco</groupId>
206+
<artifactId>jacoco-maven-plugin</artifactId>
207+
<version>0.8.13</version>
208+
<configuration>
209+
<excludes>
210+
<exclude>**/*.yml</exclude>
211+
<exclude>**/*.tf</exclude>
212+
<exclude>**/*.sh</exclude>
213+
<exclude>**/*.yaml</exclude>
214+
<exclude>**/*.xml</exclude>
215+
<exclude>**/*.properties</exclude>
216+
<exclude>**/*.avsc</exclude>
217+
<exclude>**/com/mailjet/client/errors/**</exclude>
218+
<exclude>**/com/mailjet/client/enums/**</exclude>
219+
<exclude>**/com/mailjet/client/resource/**</exclude>
220+
<exclude>**/com/mailjet/client/transactional/response/**</exclude>
221+
</excludes>
222+
</configuration>
223+
<executions>
224+
<execution>
225+
<id>pre-unit-prepare</id>
226+
<goals>
227+
<goal>prepare-agent</goal>
228+
</goals>
229+
<configuration>
230+
<destFile>${project.build.directory}/jacoco-ut.exec</destFile>
231+
</configuration>
232+
</execution>
233+
<execution>
234+
<id>pre-integration-prepare</id>
235+
<goals>
236+
<goal>prepare-agent-integration</goal>
237+
</goals>
238+
<configuration>
239+
<destFile>${project.build.directory}/jacoco-it.exec</destFile>
240+
</configuration>
241+
</execution>
242+
<execution>
243+
<id>report-unit</id>
244+
<phase>test</phase>
245+
<goals>
246+
<goal>report</goal>
247+
</goals>
248+
<configuration>
249+
<outputDirectory>${project.build.directory}/jacoco-ut</outputDirectory>
250+
<dataFile>${project.build.directory}/jacoco-ut.exec</dataFile>
251+
</configuration>
252+
</execution>
253+
<execution>
254+
<id>report-integration</id>
255+
<phase>verify</phase>
256+
<goals>
257+
<goal>report</goal>
258+
</goals>
259+
<configuration>
260+
<outputDirectory>${project.build.directory}/jacoco-it</outputDirectory>
261+
<dataFile>${project.build.directory}/jacoco-it.exec</dataFile>
262+
</configuration>
263+
</execution>
264+
</executions>
265+
</plugin>
204266
</plugins>
205267
</build>
206268
<profiles>

src/main/java/com/mailjet/client/MailjetRequest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616

1717
package com.mailjet.client;
1818

19-
import static com.mailjet.client.MailjetRequestUtil.decodeDecimals;
19+
import com.mailjet.client.enums.ApiAuthenticationType;
20+
import com.mailjet.client.enums.ApiVersion;
21+
22+
import org.json.JSONObject;
2023

2124
import java.io.File;
2225
import java.io.IOException;
@@ -27,11 +30,10 @@
2730
import java.nio.file.Paths;
2831
import java.util.HashMap;
2932

30-
import com.mailjet.client.enums.ApiAuthenticationType;
31-
import com.mailjet.client.enums.ApiVersion;
3233
import lombok.Getter;
3334
import okhttp3.HttpUrl;
34-
import org.json.JSONObject;
35+
36+
import static com.mailjet.client.MailjetRequestUtil.decodeDecimals;
3537

3638
/**
3739
*

src/main/java/com/mailjet/client/MailjetResponse.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import org.json.JSONArray;
1010
import org.json.JSONObject;
1111

12+
import lombok.Getter;
13+
1214
/**
1315
*
1416
* @author Guillaume Badi
@@ -17,19 +19,19 @@ public class MailjetResponse {
1719

1820
private final JSONObject responseObject;
1921
private final String rawResponse;
22+
/**
23+
* -- GETTER --
24+
*
25+
* @return HTTP status code returned by Mailjet server
26+
*/
27+
@Getter
2028
private final int status;
2129

2230
public MailjetResponse(int status, String rawResponse) {
2331
responseObject = new JSONObject(rawResponse);
2432
this.rawResponse = rawResponse;
2533
this.status = status;
2634
}
27-
/**
28-
* @return HTTP status code returned by Mailjet server
29-
*/
30-
public int getStatus() {
31-
return status;
32-
}
3335

3436
/**
3537
* @return Raw response string sent by Mailjet server

src/main/java/com/mailjet/client/Main.java

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/main/java/com/mailjet/client/easy/MJEasyClient.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,19 @@
66
import com.mailjet.client.resource.Email;
77
import com.mailjet.client.resource.sms.SmsSend;
88

9+
import lombok.Getter;
10+
911
/**
1012
* Mailjet easy client
1113
*/
14+
@Getter
1215
public class MJEasyClient {
16+
/**
17+
* -- GETTER --
18+
* Get the internal Mailjet client
19+
*
20+
* @return MailjetClient instance
21+
*/
1322
private final MailjetClient client;
1423

1524
/**
@@ -54,11 +63,11 @@ public MJEasyClient() {
5463
}
5564

5665
/**
57-
* Get the internal Mailjet client
58-
* @return MailjetClient instance
66+
* Constructor using a pre-configured MailjetClient instance.
67+
* @param client Pre-configured MailjetClient instance
5968
*/
60-
public MailjetClient getClient() {
61-
return client;
69+
protected MJEasyClient(MailjetClient client) {
70+
this.client = client;
6271
}
6372

6473
/**

src/test/java/com/mailjet/client/Base64Test.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import junit.framework.TestCase;
44
import org.junit.Assert;
55

6+
import java.nio.charset.StandardCharsets;
7+
68
import static java.nio.charset.StandardCharsets.UTF_8;
79

810
public class Base64Test extends TestCase {
@@ -14,7 +16,7 @@ public void test_should_base64_decode_provided_string() {
1416
byte[] result = Base64.decode(mock);
1517

1618
// THEN
17-
Assert.assertEquals("test:testéa$$à)=/*", new String(result));
19+
Assert.assertEquals("test:testéa$$à)=/*", new String(result, StandardCharsets.UTF_8));
1820
}
1921

2022
public void test_should_base64_encode_provided_bytes_array() {

src/test/java/com/mailjet/client/MJEasyClientTest.java

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)