Skip to content

Commit 5e654c2

Browse files
committed
Added unit tests and updated existing
1 parent bb3e823 commit 5e654c2

24 files changed

Lines changed: 1226 additions & 27 deletions

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All _notable_ changes to this project will be documented in this file.
55
The format is based on _[Keep a Changelog][keepachangelog]_, and this project
66
adheres to _[Semantic Versioning][semver]_.
77

8+
## [2.0.0] (released: 2025-06-11)
9+
### Updated
10+
- Added unit tests and updated existing
11+
- Moved to the new version 2.x.x as JDK was moved to Java 11
12+
813
## [1.1.6] (released: 2025-04-28)
914
### Updated
1015
- Fixed issues
@@ -86,6 +91,7 @@ adheres to _[Semantic Versioning][semver]_.
8691
- Import a list of complaints from CSV file API
8792
- Add Import a list of bounces from CSV file API
8893

94+
[2.0.0]: https://github.com/mailgun/mailgun-java/compare/v1.1.6...v2.0.0
8995
[1.1.6]: https://github.com/mailgun/mailgun-java/compare/v1.1.5...v1.1.6
9096
[1.1.5]: https://github.com/mailgun/mailgun-java/compare/v1.1.4...v1.1.5
9197
[1.1.4]: https://github.com/mailgun/mailgun-java/compare/v1.1.3...v1.1.4

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Add the following to your `pom.xml`:
7676
<dependency>
7777
<groupId>com.mailgun</groupId>
7878
<artifactId>mailgun-java</artifactId>
79-
<version>1.1.6</version>
79+
<version>2.0.0</version>
8080
</dependency>
8181
...
8282
</dependencies>
@@ -85,7 +85,7 @@ Add the following to your `pom.xml`:
8585
Gradle Groovy DSL .
8686

8787
```xml
88-
implementation 'com.mailgun:mailgun-java:1.1.6'
88+
implementation 'com.mailgun:mailgun-java:2.0.0'
8989
```
9090

9191

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: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.mailgun</groupId>
88
<artifactId>mailgun-java</artifactId>
9-
<version>1.1.6</version>
9+
<version>2.0.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>${project.groupId}:${project.artifactId}</name>
@@ -104,6 +104,12 @@
104104
<version>${junit-jupiter.version}</version>
105105
<scope>test</scope>
106106
</dependency>
107+
<dependency>
108+
<groupId>org.mockito</groupId>
109+
<artifactId>mockito-core</artifactId>
110+
<version>5.5.0</version>
111+
<scope>test</scope>
112+
</dependency>
107113
<dependency>
108114
<groupId>com.github.tomakehurst</groupId>
109115
<artifactId>wiremock</artifactId>
@@ -177,6 +183,68 @@
177183
</excludes>
178184
</configuration>
179185
</plugin>
186+
<plugin>
187+
<groupId>org.jacoco</groupId>
188+
<artifactId>jacoco-maven-plugin</artifactId>
189+
<version>0.8.13</version>
190+
<configuration>
191+
<excludes>
192+
<exclude>**/*.yml</exclude>
193+
<exclude>**/*.tf</exclude>
194+
<exclude>**/*.sh</exclude>
195+
<exclude>**/*.yaml</exclude>
196+
<exclude>**/*.xml</exclude>
197+
<exclude>**/*.properties</exclude>
198+
<exclude>**/*.avsc</exclude>
199+
<exclude>**/config/*</exclude>
200+
<exclude>**/com/mailgun/model/**</exclude>
201+
<exclude>**/com/mailgun/enums/**</exclude>
202+
<exclude>**/com/mailgun/exception/**</exclude>
203+
</excludes>
204+
</configuration>
205+
<executions>
206+
<execution>
207+
<id>pre-unit-prepare</id>
208+
<goals>
209+
<goal>prepare-agent</goal>
210+
</goals>
211+
<configuration>
212+
<destFile>${project.build.directory}/jacoco-ut.exec</destFile>
213+
</configuration>
214+
</execution>
215+
<execution>
216+
<id>pre-integration-prepare</id>
217+
<goals>
218+
<goal>prepare-agent-integration</goal>
219+
</goals>
220+
<configuration>
221+
<destFile>${project.build.directory}/jacoco-it.exec</destFile>
222+
</configuration>
223+
</execution>
224+
<execution>
225+
<id>report-unit</id>
226+
<phase>test</phase>
227+
<goals>
228+
<goal>report</goal>
229+
</goals>
230+
<configuration>
231+
<outputDirectory>${project.build.directory}/jacoco-ut</outputDirectory>
232+
<dataFile>${project.build.directory}/jacoco-ut.exec</dataFile>
233+
</configuration>
234+
</execution>
235+
<execution>
236+
<id>report-integration</id>
237+
<phase>verify</phase>
238+
<goals>
239+
<goal>report</goal>
240+
</goals>
241+
<configuration>
242+
<outputDirectory>${project.build.directory}/jacoco-it</outputDirectory>
243+
<dataFile>${project.build.directory}/jacoco-it.exec</dataFile>
244+
</configuration>
245+
</execution>
246+
</executions>
247+
</plugin>
180248
</plugins>
181249
</build>
182250

src/main/java/com/mailgun/client/MailgunClient.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package com.mailgun.client;
22

3-
import java.util.concurrent.Executors;
4-
53
import com.fasterxml.jackson.databind.ObjectMapper;
64
import com.mailgun.api.MailgunApi;
75
import com.mailgun.form.FormEncoder;
86
import com.mailgun.util.ConsoleLogger;
97
import com.mailgun.util.MailgunApiUtil;
108
import com.mailgun.util.ObjectMapperUtil;
9+
10+
import java.util.concurrent.Executors;
11+
1112
import feign.AsyncClient;
1213
import feign.AsyncFeign;
1314
import feign.Client;

src/main/java/com/mailgun/form/FormEncoder.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public FormEncoder(Encoder delegate) {
4949
}
5050
}
5151

52+
public FormEncoder(Encoder delegate, Map<ContentType, ContentProcessor> processors) {
53+
this.delegate = delegate;
54+
this.processors = processors;
55+
}
56+
5257
@Override
5358
@SuppressWarnings("unchecked")
5459
public void encode(Object object, Type bodyType, RequestTemplate template) throws EncodeException {

src/main/java/com/mailgun/form/ManyFormDataWriter.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@
88

99
public class ManyFormDataWriter extends AbstractWriter {
1010

11-
private final SingleFormDataWriter formDataWriter = new SingleFormDataWriter();
11+
private final SingleFormDataWriter formDataWriter;
12+
13+
public ManyFormDataWriter(SingleFormDataWriter formDataWriter) {
14+
this.formDataWriter = formDataWriter;
15+
}
16+
17+
public ManyFormDataWriter() {
18+
this.formDataWriter = new SingleFormDataWriter();
19+
}
1220

1321
@Override
1422
public boolean isApplicable(Object value) {

src/main/java/com/mailgun/form/PojoUtil.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import lombok.Setter;
77
import lombok.SneakyThrows;
88
import lombok.experimental.FieldDefaults;
9+
import lombok.experimental.UtilityClass;
910
import lombok.val;
1011

1112
import java.lang.reflect.Field;
@@ -24,6 +25,7 @@
2425
*
2526
* @author Artem Labazin
2627
*/
28+
@UtilityClass
2729
public final class PojoUtil {
2830

2931
public static boolean isUserPojo (@NonNull Object object) {
@@ -72,10 +74,6 @@ public static Map<String, Object> toMap (@NonNull Object object) {
7274
return result;
7375
}
7476

75-
private PojoUtil () throws UnexpectedException {
76-
throw new UnexpectedException("It is not allowed to instantiate this class");
77-
}
78-
7977
@Setter
8078
@NoArgsConstructor
8179
@FieldDefaults(level = PRIVATE)

src/test/java/com/mailgun/api/WireMockBaseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@Slf4j
1111
public abstract class WireMockBaseTest {
1212

13-
static WireMockServer wireMockServer;
13+
protected static WireMockServer wireMockServer;
1414

1515
@BeforeAll
1616
static void beforeAll() {

src/test/java/com/mailgun/api/MailgunAccountMetricsApiTest.java renamed to src/test/java/com/mailgun/api/v1/MailgunAccountMetricsApiTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
package com.mailgun.api;
1+
package com.mailgun.api.v1;
22

33
import com.fasterxml.jackson.core.JsonProcessingException;
44
import com.fasterxml.jackson.databind.JsonNode;
55
import com.fasterxml.jackson.databind.ObjectMapper;
6-
import com.mailgun.api.v1.MailgunAccountMetricsApi;
6+
import com.mailgun.api.ResponseSampleLoaderUtil;
7+
import com.mailgun.api.WireMockBaseTest;
78
import com.mailgun.client.MailgunClient;
89
import com.mailgun.enums.ApiVersion;
910
import com.mailgun.model.metrics.AccountMetrics;

0 commit comments

Comments
 (0)