|
2 | 2 |
|
3 | 3 | import com.github.tomakehurst.wiremock.junit.WireMockRule; |
4 | 4 | import com.maxmind.minfraud.exception.*; |
| 5 | +import com.maxmind.minfraud.request.Device; |
| 6 | +import com.maxmind.minfraud.request.Shipping; |
5 | 7 | import com.maxmind.minfraud.request.Transaction; |
6 | 8 | import com.maxmind.minfraud.response.FactorsResponse; |
7 | 9 | import com.maxmind.minfraud.response.InsightsResponse; |
|
14 | 16 | import org.junit.runner.RunWith; |
15 | 17 | import org.skyscreamer.jsonassert.JSONAssert; |
16 | 18 |
|
| 19 | +import java.net.InetAddress; |
| 20 | + |
17 | 21 | import static com.github.tomakehurst.wiremock.client.WireMock.*; |
18 | 22 | import static com.jcabi.matchers.RegexMatchers.matchesPattern; |
19 | 23 | import static com.maxmind.minfraud.request.RequestTestHelper.*; |
@@ -70,6 +74,23 @@ public void testFullFactorsTransaction() throws Exception { |
70 | 74 | } |
71 | 75 | } |
72 | 76 |
|
| 77 | + @Test |
| 78 | + public void testRequestEncoding() throws Exception { |
| 79 | + try (WebServiceClient client = createSuccessClient("insights", "{}")) { |
| 80 | + Transaction request = new Transaction.Builder( |
| 81 | + new Device.Builder(InetAddress.getByName("1.1.1.1")).build() |
| 82 | + ).shipping( |
| 83 | + new Shipping.Builder() |
| 84 | + .firstName("Allan dias á s maia") |
| 85 | + .build() |
| 86 | + ).build(); |
| 87 | + client.insights(request); |
| 88 | + |
| 89 | + verify(postRequestedFor(urlMatching("/minfraud/v2.0/insights")) |
| 90 | + .withRequestBody(equalToJson("{\"device\":{\"ip_address\":\"1.1.1.1\"},\"shipping\":{\"first_name\":\"Allan dias á s maia\"}}"))); |
| 91 | + } |
| 92 | + } |
| 93 | + |
73 | 94 | @Test |
74 | 95 | public void test200WithNoBody() throws Exception { |
75 | 96 | try (WebServiceClient client = createSuccessClient("insights", "")) { |
|
0 commit comments