Skip to content

Commit

Permalink
Update tests and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
XanSmarty committed Oct 31, 2023
1 parent eb559ec commit 4cae989
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
17 changes: 0 additions & 17 deletions src/main/java/examples/InternationalAutocompleteExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,6 @@ public static void main(String[] args) {
System.out.println(ex.getMessage());
ex.printStackTrace();
}

String addressID = "OS0DMy8DPgNNTUpGTEhHAyA5LTo";

lookup = new Lookup("Louis");
lookup.setAddressID(addressID);
lookup.setCountry("FRA");
lookup.setLocality("Paris");
try {
client.send(lookup);

System.out.println("*** Result ***");
System.out.println();
printResult(lookup);
} catch (SmartyException | IOException | InterruptedException ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();
}
}

private static void printResult(Lookup lookup) {
Expand Down
20 changes: 15 additions & 5 deletions src/test/java/com/smartystreets/api/URLPrefixSenderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,25 @@
public class URLPrefixSenderTest {

@Test
public void testProvidedURLOverridesRequestURL() throws Exception {
public void testRequestURLPresent() throws Exception {
Request request = new Request();
request.setUrlPrefix("http://www.google.com/the/path/stays");
String override = "https://smartystreets.com/the/path/is/ignored?";
request.setUrlPrefix("/jimbo");
Sender inner = new MockSender(new Response(123, null));
Sender sender = new URLPrefixSender(override, inner);
Sender sender = new URLPrefixSender("http://mysite.com/lookup", inner);

Response response = sender.send(request);

assertEquals(override, request.getUrl());
assertEquals("http://mysite.com/lookup/jimbo?", request.getUrl());
}

@Test
public void testRequestURLNotPresent() throws Exception {
Request request = new Request();
Sender inner = new MockSender(new Response(123, null));
Sender sender = new URLPrefixSender("http://mysite.com/lookup", inner);

Response response = sender.send(request);

assertEquals("http://mysite.com/lookup?", request.getUrl());
}
}

0 comments on commit 4cae989

Please sign in to comment.