From 4cae9898d1fa100ce2d61249cfd8ee3a46d0d051 Mon Sep 17 00:00:00 2001 From: Xan Johnson Date: Tue, 31 Oct 2023 16:07:08 -0600 Subject: [PATCH] Update tests and examples --- .../InternationalAutocompleteExample.java | 17 ---------------- .../api/URLPrefixSenderTest.java | 20 ++++++++++++++----- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/main/java/examples/InternationalAutocompleteExample.java b/src/main/java/examples/InternationalAutocompleteExample.java index 6bc7fb3..419831b 100644 --- a/src/main/java/examples/InternationalAutocompleteExample.java +++ b/src/main/java/examples/InternationalAutocompleteExample.java @@ -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) { diff --git a/src/test/java/com/smartystreets/api/URLPrefixSenderTest.java b/src/test/java/com/smartystreets/api/URLPrefixSenderTest.java index b7c42bf..ae32852 100644 --- a/src/test/java/com/smartystreets/api/URLPrefixSenderTest.java +++ b/src/test/java/com/smartystreets/api/URLPrefixSenderTest.java @@ -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()); } }