55import okhttp3 .mockwebserver .MockWebServer ;
66import okhttp3 .mockwebserver .RecordedRequest ;
77
8- import java .text .SimpleDateFormat ;
98import java .util .HashMap ;
109import java .util .concurrent .TimeUnit ;
1110
@@ -16,14 +15,11 @@ public class ScoreClientTest extends TestCase {
1615 private String customerId ;
1716 private String apiKey ;
1817
19- private SimpleDateFormat rfc2616 = new SimpleDateFormat ("EEE, dd MMM yyyy HH:mm:ss 'GMT'" );
20-
21-
2218 public void setUp () throws Exception {
2319 super .setUp ();
2420
2521 customerId = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890" ;
26- apiKey = "EXAMPLE----TE8sTgg45yusumoN6BYsBVkh +yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==" ;
22+ apiKey = "ABC12345yusumoN6BYsBVkh +yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==" ;
2723
2824 mockServer = new MockWebServer ();
2925 mockServer .start ();
@@ -40,7 +36,6 @@ public void testScoreClientConstructorMinimal() throws Exception {
4036 assertNotNull (client );
4137 }
4238
43-
4439 public void testScoreClientConstructorFull () throws Exception {
4540 ScoreClient client = new ScoreClient (customerId ,
4641 apiKey ,
@@ -58,7 +53,6 @@ public void testScoreClientConstructorFull() throws Exception {
5853 }
5954
6055 public void testScoreWithParams () throws Exception {
61-
6256 HashMap <String , String > params = new HashMap <String , String >() {{
6357 put ("originating_ip" , "127.0.0.1" );
6458 put ("account_lifecycle_event" , "create" );
@@ -70,24 +64,25 @@ public void testScoreWithParams() throws Exception {
7064 this .apiKey ,
7165 this .mockServer .url ("" ).toString ().replaceAll ("/$" , "" ), null , null , null );
7266
73- client .score ("18005555555 " , "create" , params );
67+ client .score ("11234567890 " , "create" , params );
7468
7569 RecordedRequest request = this .mockServer .takeRequest (1 , TimeUnit .SECONDS );
7670
7771 assertEquals ("method is not as expected" , "POST" , request .getMethod ());
78- assertEquals ("path is not as expected" , "/v1/score/18005555555" , request .getPath ());
79- assertEquals ("body is not as expected" , "originating_ip=127.0.0.1&account_lifecycle_event=create" ,
80- request .getBody ().readUtf8 ());
72+ assertEquals ("path is not as expected" , "/intelligence/phone" , request .getPath ());
73+
74+ String body = request .getBody ().readUtf8 ();
75+ assertTrue ("body does not contain phone_number" , body .contains ("phone_number=11234567890" ));
76+ assertTrue ("body does not contain originating_ip" , body .contains ("originating_ip=127.0.0.1" ));
77+ assertTrue ("body does not contain account_lifecycle_event" , body .contains ("account_lifecycle_event=create" ));
78+
8179 assertEquals ("Content-Type header is not as expected" , "application/x-www-form-urlencoded" ,
8280 request .getHeader ("Content-Type" ));
8381 assertEquals ("x-ts-auth-method header is not as expected" , "HMAC-SHA256" ,
8482 request .getHeader ("x-ts-auth-method" ));
8583 }
8684
8785 public void testScore () throws Exception {
88-
89- HashMap <String , Object > params = new HashMap <String , Object >();
90-
9186 this .mockServer .enqueue (new MockResponse ().setBody ("{}" ));
9287
9388 ScoreClient client = new ScoreClient (this .customerId ,
@@ -99,15 +94,15 @@ public void testScore() throws Exception {
9994 RecordedRequest request = this .mockServer .takeRequest (1 , TimeUnit .SECONDS );
10095
10196 assertEquals ("method is not as expected" , "POST" , request .getMethod ());
102- assertEquals ("path is not as expected" , "/v1/score/18005555555" , request .getPath ());
103- assertEquals ("body is not as expected" , "account_lifecycle_event=create" ,
104- request .getBody ().readUtf8 ());
97+ assertEquals ("path is not as expected" , "/intelligence/phone" , request .getPath ());
98+
99+ String body = request .getBody ().readUtf8 ();
100+ assertTrue ("body does not contain phone_number" , body .contains ("phone_number=18005555555" ));
101+ assertTrue ("body contains account_lifecycle_event" , body .contains ("account_lifecycle_event=create" ));
102+
105103 assertEquals ("Content-Type header is not as expected" , "application/x-www-form-urlencoded" ,
106104 request .getHeader ("Content-Type" ));
107105 assertEquals ("x-ts-auth-method header is not as expected" , "HMAC-SHA256" ,
108106 request .getHeader ("x-ts-auth-method" ));
109107 }
110-
111- }
112-
113-
108+ }
0 commit comments