1010
1111import static org .junit .Assert .assertArrayEquals ;
1212import static org .junit .Assert .assertEquals ;
13+ import static org .junit .Assert .assertTrue ;
14+ import static org .junit .Assert .assertFalse ;
1315
1416public class ClientTest {
1517 //region [ Single Lookup ]
@@ -23,7 +25,7 @@ public void testSendingSinglePrefixOnlyLookup() throws Exception {
2325
2426 client .send (new Lookup ("1" ));
2527
26- assertEquals ("http://localhost/?search=1&max_results=5" , capturingSender .getRequest ().getUrl ());
28+ assertEquals ("http://localhost/?search=1&max_results=5&max_group_results=100 " , capturingSender .getRequest ().getUrl ());
2729 }
2830
2931 @ Test
@@ -32,7 +34,7 @@ public void testSendingSinglePartiallyPopulatedLookup() throws Exception {
3234 URLPrefixSender sender = new URLPrefixSender ("http://localhost/" , capturingSender );
3335 FakeSerializer serializer = new FakeSerializer (new Result ());
3436 Client client = new Client (sender , serializer );
35- String expectedURL = "http://localhost/?country=1&search=2&max_results=5&include_only_locality=4&include_only_postal_code=5" ;
37+ String expectedURL = "http://localhost/?country=1&search=2&max_results=5&max_group_results=100& include_only_locality=4&include_only_postal_code=5" ;
3638 Lookup lookup = new Lookup ();
3739 lookup .setCountry ("1" );
3840 lookup .setSearch ("2" );
@@ -50,7 +52,7 @@ public void testSendingSingleFullyPopulatedLookup() throws Exception {
5052 URLPrefixSender sender = new URLPrefixSender ("http://localhost/" , capturingSender );
5153 FakeSerializer serializer = new FakeSerializer (new Result ());
5254 Client client = new Client (sender , serializer );
53- String expectedURL = "http://localhost/?country=1&search=2&max_results=10&include_only_locality=4&include_only_postal_code=5" ;
55+ String expectedURL = "http://localhost/?country=1&search=2&max_results=10&max_group_results=100& include_only_locality=4&include_only_postal_code=5" ;
5456 Lookup lookup = new Lookup ();
5557 lookup .setCountry ("1" );
5658 lookup .setSearch ("2" );
@@ -63,6 +65,43 @@ public void testSendingSingleFullyPopulatedLookup() throws Exception {
6365 assertEquals (expectedURL , capturingSender .getRequest ().getUrl ());
6466 }
6567
68+ @ Test
69+ public void testSendingLookupWithGeolocation () throws Exception {
70+ RequestCapturingSender capturingSender = new RequestCapturingSender ();
71+ URLPrefixSender sender = new URLPrefixSender ("http://localhost/" , capturingSender );
72+ FakeSerializer serializer = new FakeSerializer (new Result ());
73+ Client client = new Client (sender , serializer );
74+ Lookup lookup = new Lookup ("1" );
75+ lookup .setGeolocation (true );
76+
77+ client .send (lookup );
78+
79+ assertTrue (capturingSender .getRequest ().getUrl ().contains ("geolocation=on" ));
80+ }
81+
82+ @ Test
83+ public void testSendingLookupWithCustomMaxGroupResults () throws Exception {
84+ RequestCapturingSender capturingSender = new RequestCapturingSender ();
85+ URLPrefixSender sender = new URLPrefixSender ("http://localhost/" , capturingSender );
86+ FakeSerializer serializer = new FakeSerializer (new Result ());
87+ Client client = new Client (sender , serializer );
88+ Lookup lookup = new Lookup ("1" );
89+ lookup .setMaxGroupResults (50 );
90+
91+ client .send (lookup );
92+
93+ assertTrue (capturingSender .getRequest ().getUrl ().contains ("max_group_results=50" ));
94+ }
95+
96+ @ Test
97+ public void testDefaultValues () {
98+ Lookup lookup = new Lookup ();
99+
100+ assertEquals (5 , lookup .getMaxResults ());
101+ assertEquals (100 , lookup .getMaxGroupResults ());
102+ assertFalse (lookup .isGeolocation ());
103+ }
104+
66105 //endregion
67106
68107 //region [ Response Handling ]
0 commit comments