Skip to content

Commit 5f222bf

Browse files
authored
Merge branch 'master' into greg/new-payment-processor
2 parents 75c9acb + b7fbbf2 commit 5f222bf

10 files changed

Lines changed: 92 additions & 77 deletions

File tree

.github/workflows/test.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Run tests
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
runs-on: ${{ matrix.os }}
6+
strategy:
7+
fail-fast: false
8+
matrix:
9+
os: [ubuntu-latest, windows-latest, macos-latest]
10+
version: [ 8, 9, 10, 11, 12, 13, 14, 15 ]
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
submodules: true
15+
- uses: actions/setup-java@v1
16+
with:
17+
java-version: ${{ matrix.version }}
18+
- run: mvn javadoc:javadoc
19+
- run: mvn test -B

.travis.yml

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

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CHANGELOG
77
* The HTTP client now allows up to 20 connections to be active at once.
88
Previously the limit was 2. Reported by mjancewicz. GitHub #110.
99
* `TSYS` was added to the `Payment.Processor` enum.
10+
* The device IP address is no longer a required input.
1011

1112
1.15.0 (2020-07-09)
1213
-------------------

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# MaxMind minFraud Score, Insights, and Factors Java API
2-
[![Build Status](https://travis-ci.org/maxmind/minfraud-api-java.png?branch=master)](https://travis-ci.org/maxmind/minfraud-api-java)
32

43
## Description ##
54

@@ -130,7 +129,6 @@ Checked exceptions:
130129
### Insights
131130

132131
```java
133-
134132
Transaction request = new Transaction.Builder(
135133
new Device.Builder(InetAddress.getByName("1.1.1.1"))
136134
.acceptLanguage("en-US")
@@ -232,7 +230,6 @@ Transaction request = new Transaction.Builder(
232230

233231
WebServiceClient client = new WebServiceClient.Builder(6, "ABCD567890").build();
234232

235-
236233
System.out.println(client.insights(request));
237234
```
238235

pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,22 @@
4242
<dependency>
4343
<groupId>com.fasterxml.jackson.core</groupId>
4444
<artifactId>jackson-core</artifactId>
45-
<version>2.11.2</version>
45+
<version>2.11.3</version>
4646
</dependency>
4747
<dependency>
4848
<groupId>com.fasterxml.jackson.core</groupId>
4949
<artifactId>jackson-databind</artifactId>
50-
<version>2.11.1</version>
50+
<version>2.11.2</version>
5151
</dependency>
5252
<dependency>
5353
<groupId>com.fasterxml.jackson.core</groupId>
5454
<artifactId>jackson-annotations</artifactId>
55-
<version>2.11.2</version>
55+
<version>2.11.3</version>
5656
</dependency>
5757
<dependency>
5858
<groupId>com.fasterxml.jackson.datatype</groupId>
5959
<artifactId>jackson-datatype-jsr310</artifactId>
60-
<version>2.11.2</version>
60+
<version>2.11.3</version>
6161
</dependency>
6262
<dependency>
6363
<groupId>com.maxmind.geoip2</groupId>
@@ -67,7 +67,7 @@
6767
<dependency>
6868
<groupId>org.apache.httpcomponents</groupId>
6969
<artifactId>httpclient</artifactId>
70-
<version>4.5.12</version>
70+
<version>4.5.13</version>
7171
</dependency>
7272
<dependency>
7373
<!-- httpclient pulls this in. We pull in a newer version
@@ -119,7 +119,7 @@
119119
<dependency>
120120
<groupId>com.fasterxml.jackson.jr</groupId>
121121
<artifactId>jackson-jr-objects</artifactId>
122-
<version>2.11.2</version>
122+
<version>2.11.3</version>
123123
<scope>test</scope>
124124
</dependency>
125125
<dependency>
@@ -229,7 +229,7 @@
229229
<configuration>
230230
<format>xml</format>
231231
<maxmem>256m</maxmem>
232-
<check />
232+
<check/>
233233
</configuration>
234234
</plugin>
235235
<plugin>

src/main/java/com/maxmind/minfraud/WebServiceClient.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ public WebServiceClient.Builder disableHttps() {
147147
return this;
148148
}
149149

150-
151150
/**
152151
* @param val The host to use.
153152
* @return Builder object
@@ -166,7 +165,6 @@ public WebServiceClient.Builder port(int val) {
166165
return this;
167166
}
168167

169-
170168
/**
171169
* @param val List of locale codes to use in name property from most
172170
* preferred to least preferred.

src/main/java/com/maxmind/minfraud/request/Device.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,18 @@ public static final class Builder {
3535
String sessionId;
3636

3737
/**
38-
* The constructor for the {@code Device.Builder} class
38+
* Constructor for the {@code Device.Builder} class
39+
*/
40+
public Builder() {
41+
}
42+
43+
/**
44+
* Constructor for the {@code Device.Builder} class
3945
*
4046
* @param ipAddress The IP address associated with the device used
4147
* by the customer in the transaction.
4248
*/
4349
public Builder(InetAddress ipAddress) {
44-
if (ipAddress == null) {
45-
throw new IllegalArgumentException("ipAddress must not be null");
46-
}
47-
4850
this.ipAddress = ipAddress;
4951
}
5052

@@ -68,6 +70,16 @@ public Device.Builder acceptLanguage(String acceptLanguage) {
6870
return this;
6971
}
7072

73+
/**
74+
* @param ipAddress The IP address associated with the device used
75+
* by the customer in the transaction.
76+
* @return The builder object.
77+
*/
78+
public Device.Builder ipAddress(InetAddress ipAddress) {
79+
this.ipAddress = ipAddress;
80+
return this;
81+
}
82+
7183
/**
7284
* @param sessionAge The number of seconds between the creation of the
7385
* user's session and the time of the transaction.
@@ -139,7 +151,6 @@ public String getSessionId() {
139151
*/
140152
@JsonProperty("ip_address")
141153
public InetAddress getIpAddress() {
142-
143154
return ipAddress;
144155
}
145156
}

src/main/java/com/maxmind/minfraud/request/Transaction.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,17 @@ public static class Builder {
5454
final List<ShoppingCartItem> shoppingCart = new ArrayList<>();
5555

5656
/**
57-
* The constructor for {@code Builder}
57+
* Constructor for {@code Builder}
58+
*/
59+
public Builder() {
60+
}
61+
62+
/**
63+
* Constructor for {@code Builder}
5864
*
5965
* @param device The {@code Device} model for the request
6066
*/
6167
public Builder(Device device) {
62-
if (device == null) {
63-
throw new IllegalArgumentException("device must not be null");
64-
}
6568
this.device = device;
6669
}
6770

@@ -101,6 +104,15 @@ public Builder customInputs(CustomInputs val) {
101104
return this;
102105
}
103106

107+
/**
108+
* @param val The Device object.
109+
* @return The builder object.
110+
*/
111+
public Builder device(Device val) {
112+
device = val;
113+
return this;
114+
}
115+
104116
/**
105117
* @param val The Email object.
106118
* @return The builder object.

src/test/java/com/maxmind/minfraud/request/DeviceTest.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,23 @@ public DeviceTest() throws UnknownHostException {
1717
}
1818

1919
@Test
20-
public void testIpAddress() throws Exception {
20+
public void testConstructorWithoutIP() throws Exception {
21+
Device device = new Builder().build();
22+
assertEquals(null, device.getIpAddress());
23+
}
24+
25+
@Test
26+
public void testIpAddressThroughConstructor() throws Exception {
2127
Device device = new Builder(ip).build();
2228
assertEquals(ip, device.getIpAddress());
2329
}
2430

31+
@Test
32+
public void testIpAddress() throws Exception {
33+
Device device = new Builder().ipAddress(ip).build();
34+
assertEquals(ip, device.getIpAddress());
35+
}
36+
2537
@Test
2638
public void testUserAgent() throws Exception {
2739
String ua = "Mozila 5";
@@ -36,7 +48,6 @@ public void testAcceptLanguage() throws Exception {
3648
assertEquals(al, device.getAcceptLanguage());
3749
}
3850

39-
4051
@Test
4152
public void testSessionAge() throws Exception {
4253
Double hour = 3600d;

src/test/java/com/maxmind/minfraud/request/TransactionTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ private Transaction.Builder builder() throws UnknownHostException {
1212
return new Transaction.Builder(new Device.Builder(InetAddress.getByName("152.216.7.110")).build());
1313
}
1414

15+
@Test
16+
public void testConstructorWithoutDevice() throws Exception {
17+
Transaction request = new Transaction.Builder().build();
18+
assertEquals(null, request.getDevice());
19+
}
20+
1521
@Test
1622
public void testAccount() throws Exception {
1723
Transaction request = this.builder().account(new Account.Builder().userId("1").build()).build();
@@ -43,6 +49,19 @@ public void testDevice() throws Exception {
4349
assertEquals(InetAddress.getByName("152.216.7.110"), request.getDevice().getIpAddress());
4450
}
4551

52+
@Test
53+
public void testDeviceThroughMethod() throws Exception {
54+
InetAddress ip = InetAddress.getByName("152.216.7.110");
55+
56+
Device device = new Device.Builder().ipAddress(ip).build();
57+
58+
Transaction request = new Transaction.Builder()
59+
.device(device)
60+
.build();
61+
62+
assertEquals(ip, request.getDevice().getIpAddress());
63+
}
64+
4665
@Test
4766
public void testEmail() throws Exception {
4867
Transaction request = this.builder().email(new Email.Builder().domain("test.com").build()).build();

0 commit comments

Comments
 (0)