Skip to content

Commit c6c5eb6

Browse files
authored
DEFECT-34640 fix tests and other defects (#77)
* fix tests and other defects * fix version * add retry to test * change and version * fix another test * add snyk * fixing permission * move snyk scan * temp remove snyk * add snyk back * update image * some versions were not migrated * add more versions and parallelize it * modify test to allow parellel execution * fix webhook test for parallel
1 parent 3ffdecb commit c6c5eb6

21 files changed

+270
-60
lines changed

.circleci/config.yml

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,76 +5,100 @@ workflows:
55
jobs:
66
- unit-tests:
77
name: java8
8-
image: "circleci/openjdk"
9-
version: "8"
8+
image: "cimg/openjdk"
9+
version: "8.0"
1010
- unit-tests:
1111
name: java9
1212
image: "circleci/openjdk"
1313
version: "9"
14-
requires:
15-
- java8
1614
- unit-tests:
1715
name: java10
1816
image: "circleci/openjdk"
1917
version: "10"
20-
requires:
21-
- java9
2218
- unit-tests:
2319
name: java11
24-
image: "circleci/openjdk"
25-
version: "11"
26-
requires:
27-
- java10
20+
image: "cimg/openjdk"
21+
version: "11.0"
2822
- unit-tests:
2923
name: java12
3024
image: "cimg/openjdk"
3125
version: "12.0.2"
32-
requires:
33-
- java11
3426
- unit-tests:
3527
name: java13
3628
image: "cimg/openjdk"
3729
version: "13.0.0"
38-
requires:
39-
- java12
4030
- unit-tests:
4131
name: java14
4232
image: "cimg/openjdk"
4333
version: "14.0.0"
44-
requires:
45-
- java13
4634
- unit-tests:
4735
name: java15
4836
image: "cimg/openjdk"
4937
version: "15.0.0"
50-
requires:
51-
- java14
5238
- unit-tests:
5339
name: java16
5440
image: "cimg/openjdk"
5541
version: "16.0.0"
56-
requires:
57-
- java15
5842
- unit-tests:
5943
name: java17
6044
image: "cimg/openjdk"
61-
version: "17.0.0"
62-
requires:
63-
- java16
45+
version: "17.0"
6446
- unit-tests:
6547
name: java18
6648
image: "cimg/openjdk"
6749
version: "18.0.1"
68-
requires:
69-
- java17
7050
- unit-tests:
7151
name: java19
7252
image: "cimg/openjdk"
7353
version: "19.0.0"
74-
requires:
75-
- java18
54+
- unit-tests:
55+
name: java21
56+
image: "cimg/openjdk"
57+
version: "21.0"
58+
- unit-tests:
59+
name: java22
60+
image: "cimg/openjdk"
61+
version: "22.0"
62+
- unit-tests:
63+
name: java23
64+
image: "cimg/openjdk"
65+
version: "23.0"
66+
- unit-tests:
67+
name: java24
68+
image: "cimg/openjdk"
69+
version: "24.0"
70+
- unit-tests:
71+
name: java25
72+
image: "cimg/openjdk"
73+
version: "25.0"
74+
- security-scan:
75+
context:
76+
- snyk
7677

7778
jobs:
79+
security-scan:
80+
docker:
81+
- image: cimg/openjdk:11.0
82+
steps:
83+
- checkout
84+
- run:
85+
name: Install dependencies
86+
command: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgpg.skip=true -B -V
87+
- run:
88+
name: Install Snyk CLI
89+
command: |
90+
curl -Lo ./snyk "https://static.snyk.io/cli/latest/snyk-linux"
91+
chmod +x ./snyk
92+
sudo mv ./snyk /usr/local/bin/
93+
- run:
94+
name: Run Snyk Scan
95+
command: |
96+
snyk auth $SNYK_TOKEN
97+
snyk monitor \
98+
--all-projects \
99+
--exclude=test \
100+
--org=$SNYK_ORG_ID
101+
78102
unit-tests:
79103
parameters:
80104
version:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 1.13.0
4+
5+
* A new feature (metadata on InboundMessage)
6+
* Compatibility improvements
7+
* Security updates
8+
39
## 1.12.2
410
* small change to fix removed code
511

pom.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
</developers>
2424

2525
<properties>
26-
<postmark.version>1.12.2</postmark.version>
26+
<postmark.version>1.13.0</postmark.version>
2727
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2828
<java.version>1.8</java.version>
2929
<jackson.minimum.version>2.9.7</jackson.minimum.version>
30-
<jackson.version>2.14.1</jackson.version>
30+
<jackson.version>2.15.0</jackson.version>
3131
<junit.jupiter.version>5.8.2</junit.jupiter.version>
3232
<junit.platform.version>1.3.2</junit.platform.version>
3333
</properties>
@@ -51,26 +51,26 @@
5151
<dependency>
5252
<groupId>org.apache.httpcomponents.client5</groupId>
5353
<artifactId>httpclient5</artifactId>
54-
<version>5.3</version>
54+
<version>5.5</version>
5555
</dependency>
5656

5757
<!-- Serialization to JSON -->
5858
<dependency>
5959
<groupId>com.fasterxml.jackson.core</groupId>
6060
<artifactId>jackson-core</artifactId>
61-
<version>${jackson.version}</version>
61+
<version>2.15.0</version>
6262
</dependency>
6363

6464
<dependency>
6565
<groupId>com.fasterxml.jackson.core</groupId>
6666
<artifactId>jackson-annotations</artifactId>
67-
<version>${jackson.version}</version>
67+
<version>2.15.0</version>
6868
</dependency>
6969

7070
<dependency>
7171
<groupId>com.fasterxml.jackson.core</groupId>
7272
<artifactId>jackson-databind</artifactId>
73-
<version>${jackson.version}</version>
73+
<version>2.15.0</version>
7474
</dependency>
7575

7676
<!-- MIME auto detect on files -->
@@ -85,21 +85,21 @@
8585
<dependency>
8686
<groupId>org.junit.jupiter</groupId>
8787
<artifactId>junit-jupiter-api</artifactId>
88-
<version>${junit.jupiter.version}</version>
88+
<version>5.8.2</version>
8989
<scope>test</scope>
9090
</dependency>
9191

9292
<dependency>
9393
<groupId>org.junit.jupiter</groupId>
9494
<artifactId>junit-jupiter-engine</artifactId>
95-
<version>${junit.jupiter.version}</version>
95+
<version>5.8.2</version>
9696
<scope>test</scope>
9797
</dependency>
9898

9999
<dependency>
100100
<groupId>org.junit.platform</groupId>
101101
<artifactId>junit-platform-runner</artifactId>
102-
<version>${junit.platform.version}</version>
102+
<version>1.8.0</version>
103103
<scope>test</scope>
104104
</dependency>
105105

src/main/java/com/postmarkapp/postmark/client/data/model/messages/InboundMessage.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.postmarkapp.postmark.client.data.parser.jackson.CustomDateDeserializer;
44

55
import java.util.List;
6+
import java.util.Map;
67
import java.util.Date;
78

89
/**
@@ -31,6 +32,7 @@ public class InboundMessage {
3132
private String status;
3233
private List<Attachment> attachments;
3334
private String messageStream;
35+
private Map<String, String> metadata;
3436

3537
// GETTERS AND SETTERS
3638

@@ -185,4 +187,12 @@ public List<Attachment> getAttachments() {
185187
public void setAttachments(List<Attachment> attachments) {
186188
this.attachments = attachments;
187189
}
190+
191+
public Map<String, String> getMetadata() {
192+
return metadata;
193+
}
194+
195+
public void setMetadata(Map<String, String> metadata) {
196+
this.metadata = metadata;
197+
}
188198
}

src/main/java/com/postmarkapp/postmark/client/data/parser/DataHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public class DataHandler {
1717
public DataHandler() {
1818
this.mapper = new ObjectMapper();
1919
this.mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
20-
this.mapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE);
20+
// Use PropertyNamingStrategies for Jackson 2.12+ compatibility (replaces deprecated PropertyNamingStrategy)
21+
this.mapper.setPropertyNamingStrategy(PropertyNamingStrategies.UpperCamelCaseStrategy.INSTANCE);
2122
setLiberalMapper();
2223
}
2324

src/test/java/base/BaseTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.postmarkapp.postmark.Postmark;
44
import com.postmarkapp.postmark.client.AccountApiClient;
55
import com.postmarkapp.postmark.client.ApiClient;
6+
import org.junit.jupiter.api.TestInstance;
67

78
import java.io.IOException;
89
import java.io.InputStream;
@@ -14,6 +15,7 @@
1415
/**
1516
* Created by bash on 11/14/17.
1617
*/
18+
@TestInstance(TestInstance.Lifecycle.PER_METHOD)
1719
public class BaseTest {
1820

1921
// Constants names for API tokens
@@ -75,9 +77,19 @@ private void initConfingFromFile() {
7577
properties = new Properties();
7678

7779
try {
78-
properties.load(in);
80+
if (in != null) {
81+
properties.load(in);
82+
}
7983
} catch (IOException e) {
8084
e.printStackTrace();
85+
} finally {
86+
if (in != null) {
87+
try {
88+
in.close();
89+
} catch (IOException e) {
90+
// Ignore close errors
91+
}
92+
}
8193
}
8294
}
8395
}

src/test/java/integration/BounceTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121
*/
2222
public class BounceTest extends BaseTest {
2323

24-
ApiClient client = getDefaultApiClientCustomUrl();
24+
ApiClient client;
25+
26+
@org.junit.jupiter.api.BeforeEach
27+
void setUp() {
28+
client = getDefaultApiClientCustomUrl();
29+
}
2530

2631
@Test
2732
void deliveryStats() throws PostmarkException, IOException {

src/test/java/integration/DataRemovalTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616
* Created by bash on 11/09/22.
1717
*/
1818
public class DataRemovalTest extends BaseTest {
19-
AccountApiClient client = getDefaultAccountApiClient();
19+
AccountApiClient client;
20+
21+
@org.junit.jupiter.api.BeforeEach
22+
void setUp() {
23+
client = getDefaultAccountApiClient();
24+
}
25+
2026
@Test
2127
void requestDataRemoval() throws PostmarkException, IOException {
2228
DataRemoval dataRemoval = new DataRemoval("[email protected]",

src/test/java/integration/DomainTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818
*/
1919
public class DomainTest extends BaseTest {
2020

21-
AccountApiClient client = getDefaultAccountApiClient();
21+
AccountApiClient client;
22+
23+
@org.junit.jupiter.api.BeforeEach
24+
void setUp() {
25+
client = getDefaultAccountApiClient();
26+
}
2227

2328
@Test
2429
void list() throws PostmarkException, IOException {

src/test/java/integration/MessageStreamsTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515

1616
public class MessageStreamsTest extends BaseTest {
1717

18-
ApiClient client = getDefaultApiClient();
18+
ApiClient client;
19+
20+
@org.junit.jupiter.api.BeforeEach
21+
void setUp() {
22+
client = getDefaultApiClient();
23+
}
1924

2025
private MessageStream findMessageStream(String streamId) throws PostmarkException, IOException {
2126
MessageStream foundStream = null;

0 commit comments

Comments
 (0)