diff --git a/pom.xml b/pom.xml index 21e92e7..cc61f0d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,45 +1,45 @@ - - 4.0.0 - - io.ljunggren - geoapify-api - 0.0.1-SNAPSHOT - jar - - geoapify-api - http://maven.apache.org - - - UTF-8 - 1.8 - 1.8 - - - - - org.apache.httpcomponents - httpclient - 4.5.8 - - - org.projectlombok - lombok - 1.18.22 - provided - - - io.ljunggren - json-utils - 0.0.1-SNAPSHOT - - - junit - junit - 4.13.2 - test - - - - + + 4.0.0 + + io.ljunggren + geoapify-api + 0.0.1-SNAPSHOT + jar + + geoapify-api + http://maven.apache.org + + + UTF-8 + 1.8 + 1.8 + + + + + org.apache.httpcomponents + httpclient + 4.5.8 + + + org.projectlombok + lombok + 1.18.38 + provided + + + io.ljunggren + json-utils + 0.0.1-SNAPSHOT + + + junit + junit + 4.13.2 + test + + + + diff --git a/src/main/java/io/ljunggren/geoapify/api/service/BaseService.java b/src/main/java/io/ljunggren/geoapify/api/service/BaseService.java index d57be3b..fc06eac 100644 --- a/src/main/java/io/ljunggren/geoapify/api/service/BaseService.java +++ b/src/main/java/io/ljunggren/geoapify/api/service/BaseService.java @@ -1,53 +1,52 @@ -package io.ljunggren.geoapify.api.service; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; - -import org.apache.http.HttpResponse; -import org.apache.http.client.config.CookieSpecs; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; - -import com.fasterxml.jackson.core.JsonProcessingException; - -import io.ljunggren.json.utils.JsonUtils; - -public class BaseService { - - protected String apiKey; - protected String domain = "https://api.geoapify.com"; - - protected BaseService(String apiKey) { - this.apiKey = apiKey; - } - - protected CloseableHttpClient getHttpClient() { - return HttpClients.custom() - .setDefaultRequestConfig(RequestConfig.custom() - .setCookieSpec(CookieSpecs.STANDARD).build()) - .build(); - } - - protected static String getResult(HttpResponse response) throws UnsupportedOperationException, IOException { - BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8)); - StringBuilder result = new StringBuilder(); - String line = new String(); - while ((line = rd.readLine()) != null) { - result.append(line); - } - return result.toString(); - } - - protected T parse(String json, Class clazz) throws Exception { - try { - return JsonUtils.jsonToObject(json, clazz); - } catch (JsonProcessingException e) { - throw new Exception("Unable to parse response"); - } - } - - -} +package io.ljunggren.geoapify.api.service; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; + +import org.apache.http.HttpResponse; +import org.apache.http.client.config.CookieSpecs; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; + +import com.fasterxml.jackson.core.JsonProcessingException; + +import io.ljunggren.json.utils.JsonUtils; + +public class BaseService { + + protected String apiKey; + protected String domain = "https://api.geoapify.com"; + + protected BaseService(String apiKey) { + this.apiKey = apiKey; + } + + protected CloseableHttpClient getHttpClient() { + return HttpClients.custom() + .setDefaultRequestConfig(RequestConfig.custom() + .setCookieSpec(CookieSpecs.STANDARD).build()) + .build(); + } + + protected static String getResult(HttpResponse response) throws UnsupportedOperationException, IOException { + BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8)); + StringBuilder result = new StringBuilder(); + String line = new String(); + while ((line = rd.readLine()) != null) { + result.append(line); + } + return result.toString(); + } + + protected T parse(String json, Class clazz) throws Exception { + try { + return JsonUtils.jsonToObject(json, clazz); + } catch (JsonProcessingException e) { + throw new Exception("Unable to parse response"); + } + } + +} diff --git a/src/test/java/io/ljunggren/geoapify/api/AppTest.java b/src/test/java/io/ljunggren/geoapify/api/AppTest.java deleted file mode 100644 index 20ac4fb..0000000 --- a/src/test/java/io/ljunggren/geoapify/api/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.ljunggren.geoapify.api; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -}