diff --git a/src/main/java/com/github/dannil/scbjavaclient/client/AbstractClient.java b/src/main/java/com/github/dannil/scbjavaclient/client/AbstractClient.java index d1d682613..d445dd3a6 100644 --- a/src/main/java/com/github/dannil/scbjavaclient/client/AbstractClient.java +++ b/src/main/java/com/github/dannil/scbjavaclient/client/AbstractClient.java @@ -16,13 +16,11 @@ package com.github.dannil.scbjavaclient.client; -import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.logging.Level; import java.util.logging.Logger; -import com.fasterxml.jackson.databind.JsonNode; import com.github.dannil.scbjavaclient.exception.SCBClientUrlNotFoundException; import com.github.dannil.scbjavaclient.utility.JsonUtility; import com.github.dannil.scbjavaclient.utility.Localization; @@ -163,33 +161,54 @@ protected String post(String url, String query) { * @param url * the URL to retrieve the regions from * @return a list of the available regions for the given URL - * @throws UnsupportedOperationException + * @throws IllegalArgumentException * if the specified URL doesn't supply a regions table */ public List getRegions(String url) { - String content = get(url); - - JsonNode contentAsJsonNode = JsonUtility.toNode(content); - - List codes = contentAsJsonNode.findValuesAsText("code"); - List values = contentAsJsonNode.findValues("values"); - - int position = codes.indexOf("Region"); - if (position < 0) { - Object[] variables = new Object[] { url }; - - throw new UnsupportedOperationException(this.localization.getString("regions_is_not_supported_for_url", - variables)); - } - - JsonNode jsonRegions = values.get(position); - - List regions = new ArrayList(jsonRegions.size()); - for (int j = 0; j < jsonRegions.size(); j++) { - regions.add(jsonRegions.get(j).asText()); + String json = get(url); + String code = "Region"; + try { + List values = JsonUtility.getValues(json, code); + return values; + } catch (IllegalArgumentException e) { + Object[] variables = new Object[] { code, url }; + throw new IllegalArgumentException(this.localization.getString("code_is_not_supported_for_url", variables), + e); } - return regions; + // if (!inputs.containsKey("Region")) { + // Object[] variables = new Object[] { url }; + // + // throw new + // UnsupportedOperationException(this.localization.getString("regions_is_not_supported_for_url", + // variables)); + // } + // return inputs.get("Region"); + + // String content = get(url); + // + // JsonNode contentAsJsonNode = JsonUtility.toNode(content); + // + // List codes = contentAsJsonNode.findValuesAsText("code"); + // List values = contentAsJsonNode.findValues("values"); + // + // int position = codes.indexOf("Region"); + // if (position < 0) { + // Object[] variables = new Object[] { url }; + // + // throw new + // UnsupportedOperationException(this.localization.getString("regions_is_not_supported_for_url", + // variables)); + // } + // + // JsonNode jsonRegions = values.get(position); + // + // List regions = new ArrayList(jsonRegions.size()); + // for (int j = 0; j < jsonRegions.size(); j++) { + // regions.add(jsonRegions.get(j).asText()); + // } + // + // return regions; } /** @@ -202,29 +221,41 @@ public List getRegions(String url) { * if the specified URL doesn't supply a years table */ public List getYears(String url) { - String content = get(url); - - JsonNode contentAsJsonNode = JsonUtility.toNode(content); - - List codes = contentAsJsonNode.findValuesAsText("code"); - List values = contentAsJsonNode.findValues("values"); - - int position = codes.indexOf("Tid"); - if (position < 0) { - Object[] variables = new Object[] { url }; - - throw new UnsupportedOperationException(this.localization.getString("years_is_not_supported_for_url", - variables)); - } - - JsonNode jsonYears = values.get(position); - - List years = new ArrayList(jsonYears.size()); - for (int j = 0; j < jsonYears.size(); j++) { - years.add(jsonYears.get(j).asText()); + String json = get(url); + String code = "Tid"; + try { + List values = JsonUtility.getValues(json, code); + return values; + } catch (IllegalArgumentException e) { + Object[] variables = new Object[] { code, url }; + throw new IllegalArgumentException(this.localization.getString("code_is_not_supported_for_url", variables), + e); } - - return years; + // + // String content = get(url); + // + // JsonNode contentAsJsonNode = JsonUtility.toNode(content); + // + // List codes = contentAsJsonNode.findValuesAsText("code"); + // List values = contentAsJsonNode.findValues("values"); + // + // int position = codes.indexOf("Tid"); + // if (position < 0) { + // Object[] variables = new Object[] { url }; + // + // throw new + // UnsupportedOperationException(this.localization.getString("years_is_not_supported_for_url", + // variables)); + // } + // + // JsonNode jsonYears = values.get(position); + // + // List years = new ArrayList(jsonYears.size()); + // for (int j = 0; j < jsonYears.size(); j++) { + // years.add(jsonYears.get(j).asText()); + // } + // + // return years; } // private void validateLocale() { diff --git a/src/main/java/com/github/dannil/scbjavaclient/client/SCBClient.java b/src/main/java/com/github/dannil/scbjavaclient/client/SCBClient.java index 9b55c19c0..b86c43dfe 100644 --- a/src/main/java/com/github/dannil/scbjavaclient/client/SCBClient.java +++ b/src/main/java/com/github/dannil/scbjavaclient/client/SCBClient.java @@ -101,14 +101,14 @@ public PopulationClient population() { * the table to fetch data from * @return a JSON string containing all available data in the specified table * - * @see com.github.dannil.scbjavaclient.utility.JsonUtility#getContentCodes(String) - * JsonUtility#getContentsCodes(String) + * @see com.github.dannil.scbjavaclient.utility.JsonUtility#getValues(String, String) + * JsonUtility#getValues(String, String) */ public String getRawData(String table) { String json = super.get(table); Map> inputs = new HashMap>(); - inputs.put("ContentsCode", JsonUtility.getContentCodes(json)); + inputs.put("ContentsCode", JsonUtility.getValues(json, "ContentsCode")); return getRawData(table, inputs); } diff --git a/src/main/java/com/github/dannil/scbjavaclient/model/environment/landandwaterarea/Area.java b/src/main/java/com/github/dannil/scbjavaclient/model/environment/landandwaterarea/Area.java index dbca630c7..6ba5c0663 100644 --- a/src/main/java/com/github/dannil/scbjavaclient/model/environment/landandwaterarea/Area.java +++ b/src/main/java/com/github/dannil/scbjavaclient/model/environment/landandwaterarea/Area.java @@ -17,6 +17,7 @@ package com.github.dannil.scbjavaclient.model.environment.landandwaterarea; import java.util.List; +import java.util.Map; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; @@ -24,6 +25,8 @@ import com.github.dannil.scbjavaclient.model.ValueNode; import com.github.dannil.scbjavaclient.utility.JsonUtility; import com.github.dannil.scbjavaclient.utility.requester.AbstractRequester; +import com.github.dannil.scbjavaclient.utility.requester.RequestMethod; +import com.github.dannil.scbjavaclient.utility.requester.RequesterFactory; /** * Model for area data. @@ -118,12 +121,13 @@ public String toString() { } /** - * Get the codes for the area model from the API. + * Get the available codes and their respective values for the area data from the API. * - * @return a list of codes that is used by the API to index the values + * @return a list of the available codes and their values */ - public static List getCodes() { - return JsonUtility.getCodes(AbstractRequester.getCodes("MI/MI0802/Areal2012")); + public static Map> getInputs() { + AbstractRequester get = RequesterFactory.getRequester(RequestMethod.GET); + return JsonUtility.getInputs(get.getBodyAsStringFromTable("MI/MI0802/Areal2012")); } } diff --git a/src/main/java/com/github/dannil/scbjavaclient/model/population/demography/FertilityRate.java b/src/main/java/com/github/dannil/scbjavaclient/model/population/demography/FertilityRate.java index 6c9abb379..217efff41 100644 --- a/src/main/java/com/github/dannil/scbjavaclient/model/population/demography/FertilityRate.java +++ b/src/main/java/com/github/dannil/scbjavaclient/model/population/demography/FertilityRate.java @@ -17,6 +17,7 @@ package com.github.dannil.scbjavaclient.model.population.demography; import java.util.List; +import java.util.Map; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; @@ -24,6 +25,8 @@ import com.github.dannil.scbjavaclient.model.ValueNode; import com.github.dannil.scbjavaclient.utility.JsonUtility; import com.github.dannil.scbjavaclient.utility.requester.AbstractRequester; +import com.github.dannil.scbjavaclient.utility.requester.RequestMethod; +import com.github.dannil.scbjavaclient.utility.requester.RequesterFactory; /** * Model for fertility rate. @@ -118,12 +121,13 @@ public String toString() { } /** - * Get the codes for the fertility rate from the API. - * - * @return a list of codes that is used by the API to index the values + * Get the available codes and their respective values for the fertility rate data from the API. + * + * @return a list of the available codes and their values */ - public static List getCodes() { - return JsonUtility.getCodes(AbstractRequester.getCodes("BE/BE0701/FruktsamhetSumNy")); + public static Map> getInputs() { + AbstractRequester get = RequesterFactory.getRequester(RequestMethod.GET); + return JsonUtility.getInputs(get.getBodyAsStringFromTable("BE/BE0701/FruktsamhetSumNy")); } } diff --git a/src/main/java/com/github/dannil/scbjavaclient/model/population/demography/MeanAgeFirstChild.java b/src/main/java/com/github/dannil/scbjavaclient/model/population/demography/MeanAgeFirstChild.java index fe7f3dd5f..a6f1c2b32 100644 --- a/src/main/java/com/github/dannil/scbjavaclient/model/population/demography/MeanAgeFirstChild.java +++ b/src/main/java/com/github/dannil/scbjavaclient/model/population/demography/MeanAgeFirstChild.java @@ -17,6 +17,7 @@ package com.github.dannil.scbjavaclient.model.population.demography; import java.util.List; +import java.util.Map; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; @@ -24,6 +25,8 @@ import com.github.dannil.scbjavaclient.model.ValueNode; import com.github.dannil.scbjavaclient.utility.JsonUtility; import com.github.dannil.scbjavaclient.utility.requester.AbstractRequester; +import com.github.dannil.scbjavaclient.utility.requester.RequestMethod; +import com.github.dannil.scbjavaclient.utility.requester.RequesterFactory; /** * Model for mean age first child data. @@ -118,12 +121,14 @@ public String toString() { } /** - * Get the codes for the mean age first child model from the API. + * Get the available codes and their respective values for the mean age first child data from + * the API. * - * @return a list of codes that is used by the API to index the values + * @return a list of the available codes and their values */ - public static List getCodes() { - return JsonUtility.getCodes(AbstractRequester.getCodes("BE/BE0701/MedelAlderNY")); + public static Map> getCodes() { + AbstractRequester get = RequesterFactory.getRequester(RequestMethod.GET); + return JsonUtility.getInputs(get.getBodyAsStringFromTable("BE/BE0701/MedelAlderNY")); } } diff --git a/src/main/java/com/github/dannil/scbjavaclient/model/population/name/NumberOfChildrenBornWithFirstName.java b/src/main/java/com/github/dannil/scbjavaclient/model/population/name/NumberOfChildrenBornWithFirstName.java index a557b21fd..989153aac 100644 --- a/src/main/java/com/github/dannil/scbjavaclient/model/population/name/NumberOfChildrenBornWithFirstName.java +++ b/src/main/java/com/github/dannil/scbjavaclient/model/population/name/NumberOfChildrenBornWithFirstName.java @@ -17,6 +17,7 @@ package com.github.dannil.scbjavaclient.model.population.name; import java.util.List; +import java.util.Map; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; @@ -24,6 +25,8 @@ import com.github.dannil.scbjavaclient.model.ValueNode; import com.github.dannil.scbjavaclient.utility.JsonUtility; import com.github.dannil.scbjavaclient.utility.requester.AbstractRequester; +import com.github.dannil.scbjavaclient.utility.requester.RequestMethod; +import com.github.dannil.scbjavaclient.utility.requester.RequesterFactory; /** * Model for number of children born with first name. @@ -114,12 +117,14 @@ public String toString() { } /** - * Get the codes for the number of children born with first name from the API. - * - * @return a list of codes that is used by the API to index the values + * Get the available codes and their respective values for the number of children born with + * first name data from the API. + * + * @return a list of the available codes and their values */ - public static List getCodes() { - return JsonUtility.getCodes(AbstractRequester.getCodes("BE/BE0001/BE0001T04Ar")); + public static Map> getCodes() { + AbstractRequester get = RequesterFactory.getRequester(RequestMethod.GET); + return JsonUtility.getInputs(get.getBodyAsStringFromTable("BE/BE0001/BE0001T04Ar")); } } diff --git a/src/main/java/com/github/dannil/scbjavaclient/model/population/statistic/AverageAge.java b/src/main/java/com/github/dannil/scbjavaclient/model/population/statistic/AverageAge.java index 04b9f6075..3501cae84 100644 --- a/src/main/java/com/github/dannil/scbjavaclient/model/population/statistic/AverageAge.java +++ b/src/main/java/com/github/dannil/scbjavaclient/model/population/statistic/AverageAge.java @@ -17,6 +17,7 @@ package com.github.dannil.scbjavaclient.model.population.statistic; import java.util.List; +import java.util.Map; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; @@ -24,6 +25,8 @@ import com.github.dannil.scbjavaclient.model.ValueNode; import com.github.dannil.scbjavaclient.utility.JsonUtility; import com.github.dannil.scbjavaclient.utility.requester.AbstractRequester; +import com.github.dannil.scbjavaclient.utility.requester.RequestMethod; +import com.github.dannil.scbjavaclient.utility.requester.RequesterFactory; /** * Model for average age. @@ -118,12 +121,13 @@ public String toString() { } /** - * Get the codes for the average age from the API. + * Get the available codes and their respective values for the average age data from the API. * - * @return a list of codes that is used by the API to index the values + * @return a list of the available codes and their values */ - public static List getCodes() { - return JsonUtility.getCodes(AbstractRequester.getCodes("BE/BE0101/BE0101B/BefolkningMedelAlder")); + public static Map> getInputs() { + AbstractRequester get = RequesterFactory.getRequester(RequestMethod.GET); + return JsonUtility.getInputs(get.getBodyAsStringFromTable("BE/BE0101/BE0101B/BefolkningMedelAlder")); } } diff --git a/src/main/java/com/github/dannil/scbjavaclient/model/population/statistic/LiveBirth.java b/src/main/java/com/github/dannil/scbjavaclient/model/population/statistic/LiveBirth.java index c7895b9f4..5abbcfee3 100644 --- a/src/main/java/com/github/dannil/scbjavaclient/model/population/statistic/LiveBirth.java +++ b/src/main/java/com/github/dannil/scbjavaclient/model/population/statistic/LiveBirth.java @@ -17,6 +17,7 @@ package com.github.dannil.scbjavaclient.model.population.statistic; import java.util.List; +import java.util.Map; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; @@ -24,6 +25,8 @@ import com.github.dannil.scbjavaclient.model.ValueNode; import com.github.dannil.scbjavaclient.utility.JsonUtility; import com.github.dannil.scbjavaclient.utility.requester.AbstractRequester; +import com.github.dannil.scbjavaclient.utility.requester.RequestMethod; +import com.github.dannil.scbjavaclient.utility.requester.RequesterFactory; /** * Model for live births data. @@ -146,12 +149,13 @@ public String toString() { } /** - * Get the codes for the live births from the API. - * - * @return a list of codes that is used by the API to index the values + * Get the available codes and their respective values for the live birth data from the API. + * + * @return a list of the available codes and their values */ - public static List getCodes() { - return JsonUtility.getCodes(AbstractRequester.getCodes("BE/BE0101/BE0101H/FoddaK")); + public static Map> getCodes() { + AbstractRequester get = RequesterFactory.getRequester(RequestMethod.GET); + return JsonUtility.getInputs(get.getBodyAsStringFromTable("BE/BE0101/BE0101H/FoddaK")); } } diff --git a/src/main/java/com/github/dannil/scbjavaclient/model/population/statistic/Population.java b/src/main/java/com/github/dannil/scbjavaclient/model/population/statistic/Population.java index a78869de0..26b4b372a 100644 --- a/src/main/java/com/github/dannil/scbjavaclient/model/population/statistic/Population.java +++ b/src/main/java/com/github/dannil/scbjavaclient/model/population/statistic/Population.java @@ -17,6 +17,7 @@ package com.github.dannil.scbjavaclient.model.population.statistic; import java.util.List; +import java.util.Map; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; @@ -24,6 +25,8 @@ import com.github.dannil.scbjavaclient.model.ValueNode; import com.github.dannil.scbjavaclient.utility.JsonUtility; import com.github.dannil.scbjavaclient.utility.requester.AbstractRequester; +import com.github.dannil.scbjavaclient.utility.requester.RequestMethod; +import com.github.dannil.scbjavaclient.utility.requester.RequesterFactory; /** * Model for population data. @@ -174,12 +177,13 @@ public String toString() { } /** - * Get the codes for the population model from the API. - * - * @return a list of codes that is used by the API to index the values + * Get the available codes and their respective values for the population data from the API. + * + * @return a list of the available codes and their values */ - public static List getCodes() { - return JsonUtility.getCodes(AbstractRequester.getCodes("BE/BE0101/BE0101A/BefolkningNy")); + public static Map> getCodes() { + AbstractRequester get = RequesterFactory.getRequester(RequestMethod.GET); + return JsonUtility.getInputs(get.getBodyAsStringFromTable("BE/BE0101/BE0101A/BefolkningNy")); } } diff --git a/src/main/java/com/github/dannil/scbjavaclient/utility/JsonUtility.java b/src/main/java/com/github/dannil/scbjavaclient/utility/JsonUtility.java index 71db9e026..334914e24 100644 --- a/src/main/java/com/github/dannil/scbjavaclient/utility/JsonUtility.java +++ b/src/main/java/com/github/dannil/scbjavaclient/utility/JsonUtility.java @@ -223,39 +223,88 @@ public static List jsonToListOf(String json, Class clazz) { } /** - * Extracts the codes from the input. - * - * @param content - * the input which should be parsed - * @return a list of codes for the input - */ - public static List getCodes(String content) { - JsonNode data = toNode(content); - return data.findValuesAsText("code"); - } - - /** - * Retrieves the contents codes from the specified JSON. + * Extracts the codes and their respective values from the JSON. * * @param json - * the json to retrieve the contents codes from - * @return a list of the available contents codes + * the JSON which should be parsed + * @return a collection of all codes and their respective values */ - public static List getContentCodes(String json) { - List valueTexts = new ArrayList(); + public static Map> getInputs(String json) { + Map> inputs = new HashMap>(); JsonNode node = JsonUtility.toNode(json, "variables"); + if (node == null) { + throw new SCBClientParsingException(); + } for (int i = 0; i < node.size(); i++) { JsonNode child = node.get(i); - if (child.get("code").asText().equals("ContentsCode")) { - JsonNode values = child.get("values"); - for (int j = 0; j < values.size(); j++) { - valueTexts.add(values.get(j).asText()); - } - break; + List values = new ArrayList(); + JsonNode valuesNode = child.get("values"); + for (int j = 0; j < valuesNode.size(); j++) { + values.add(valuesNode.get(j).asText()); } + inputs.put(child.get("code").asText(), values); } - return valueTexts; + return inputs; + } + + /** + * Extracts the values for a code from the JSON. + * + * @param json + * the json + * @param code + * the code + * @return a list of values + * @throws IllegalArgumentException + * if the JSON doesn't contain the code + */ + public static List getValues(String json, String code) throws IllegalArgumentException { + Map> inputs = getInputs(json); + if (!inputs.containsKey(code)) { + throw new IllegalArgumentException(); + } + return inputs.get(code); + } + + /** + * Extracts the codes from the JSON. + * + * @param json + * the json which should be parsed + * @return a list of codes + */ + public static List getCodes(String json) { + List codes = new ArrayList(getInputs(json).keySet()); + return codes; + + // return getInputs(json).keySet().; + // JsonNode data = toNode(content); + // return data.findValuesAsText("code"); } + // /** + // * Extracts the contents codes from the input. + // * + // * @param json + // * the json which should be parsed + // * @return a list of contents codes + // */ + // public static List getContentsCodes(String json) { + // // List valueTexts = new ArrayList(); + // // + // // JsonNode node = JsonUtility.toNode(json, "variables"); + // // for (int i = 0; i < node.size(); i++) { + // // JsonNode child = node.get(i); + // // if (child.get("code").asText().equals("ContentsCode")) { + // // JsonNode values = child.get("values"); + // // for (int j = 0; j < values.size(); j++) { + // // valueTexts.add(values.get(j).asText()); + // // } + // // break; + // // } + // // } + // // return valueTexts; + // return getInputs(json).get("ContentsCode"); + // } } diff --git a/src/main/java/com/github/dannil/scbjavaclient/utility/requester/AbstractRequester.java b/src/main/java/com/github/dannil/scbjavaclient/utility/requester/AbstractRequester.java index ecc399cae..2dd936445 100644 --- a/src/main/java/com/github/dannil/scbjavaclient/utility/requester/AbstractRequester.java +++ b/src/main/java/com/github/dannil/scbjavaclient/utility/requester/AbstractRequester.java @@ -143,15 +143,14 @@ protected String getBody(HttpResponse response) { } /** - * Return the available codes from the specified table. + * Return the content from the specified table. * * @param table - * the table to fetch the codes from - * @return the available codes from the specified table + * the table to fetch the content from + * @return the content of the table */ - public static String getCodes(String table) { - AbstractRequester get = RequesterFactory.getRequester(RequestMethod.GET); - return get.getBodyAsString("http://api.scb.se/OV0104/v1/doris/sv/ssd/" + table); + public String getBodyAsStringFromTable(String table) { + return getBodyAsString("http://api.scb.se/OV0104/v1/doris/sv/ssd/" + table); } /** diff --git a/src/main/resources/language_en_US.properties b/src/main/resources/language_en_US.properties index da7607c8e..fc925b904 100644 --- a/src/main/resources/language_en_US.properties +++ b/src/main/resources/language_en_US.properties @@ -4,4 +4,5 @@ test = TestEnglish unique = UniqueEnglish regions_is_not_supported_for_url = Regions is not supported for URL {0} -years_is_not_supported_for_url = Years is not supported for URL {0} \ No newline at end of file +years_is_not_supported_for_url = Years is not supported for URL {0} +code_is_not_supported_for_url {0} is not supported for URL {1} \ No newline at end of file diff --git a/src/main/resources/language_sv_SE.properties b/src/main/resources/language_sv_SE.properties index f61aa4eab..95e32372f 100644 --- a/src/main/resources/language_sv_SE.properties +++ b/src/main/resources/language_sv_SE.properties @@ -3,4 +3,5 @@ hello = Hej test = TestSvenska regions_is_not_supported_for_url = Regioner stöds inte för URL {0} -years_is_not_supported_for_url = År stöds inte för URL {0} \ No newline at end of file +years_is_not_supported_for_url = År stöds inte för URL {0} +code_is_not_supported_for_url {0} stödjs inte för URL {1} \ No newline at end of file diff --git a/src/test/java/com/github/dannil/scbjavaclient/client/AbstractClient_IntegrationTest.java b/src/test/java/com/github/dannil/scbjavaclient/client/AbstractClient_IntegrationTest.java index 004390c11..0d29c2944 100644 --- a/src/test/java/com/github/dannil/scbjavaclient/client/AbstractClient_IntegrationTest.java +++ b/src/test/java/com/github/dannil/scbjavaclient/client/AbstractClient_IntegrationTest.java @@ -32,6 +32,7 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; +import com.github.dannil.scbjavaclient.exception.SCBClientParsingException; import com.github.dannil.scbjavaclient.utility.QueryBuilder; @RunWith(JUnit4.class) @@ -103,7 +104,7 @@ public void getRegions() { assertFalse(regions.isEmpty()); } - @Test(expected = UnsupportedOperationException.class) + @Test(expected = IllegalArgumentException.class) public void getRegionsInvalidTable() { DummyClient client = new DummyClient(); @@ -122,7 +123,7 @@ public void getYears() { assertFalse(years.isEmpty()); } - @Test(expected = UnsupportedOperationException.class) + @Test(expected = SCBClientParsingException.class) public void getYearsInvalidTable() { DummyClient client = new DummyClient(); diff --git a/src/test/java/com/github/dannil/scbjavaclient/model/environment/landandwaterarea/Area_UnitTest.java b/src/test/java/com/github/dannil/scbjavaclient/model/environment/landandwaterarea/Area_UnitTest.java index 72d3145b7..3371cb959 100644 --- a/src/test/java/com/github/dannil/scbjavaclient/model/environment/landandwaterarea/Area_UnitTest.java +++ b/src/test/java/com/github/dannil/scbjavaclient/model/environment/landandwaterarea/Area_UnitTest.java @@ -126,8 +126,8 @@ public void getValues() { } @Test - public void getCodes() { - assertNotNull(Area.getCodes()); + public void getInputs() { + assertNotNull(Area.getInputs()); } @Test diff --git a/src/test/java/com/github/dannil/scbjavaclient/model/population/demography/FertilityRate_UnitTest.java b/src/test/java/com/github/dannil/scbjavaclient/model/population/demography/FertilityRate_UnitTest.java index ce005714c..949ff84ab 100644 --- a/src/test/java/com/github/dannil/scbjavaclient/model/population/demography/FertilityRate_UnitTest.java +++ b/src/test/java/com/github/dannil/scbjavaclient/model/population/demography/FertilityRate_UnitTest.java @@ -88,8 +88,8 @@ public void setValues() { } @Test - public void getCodes() { - assertNotNull(FertilityRate.getCodes()); + public void getInputs() { + assertNotNull(FertilityRate.getInputs()); } @Test diff --git a/src/test/java/com/github/dannil/scbjavaclient/model/population/statistic/AverageAge_UnitTest.java b/src/test/java/com/github/dannil/scbjavaclient/model/population/statistic/AverageAge_UnitTest.java index d22534ea5..4e91ba47f 100644 --- a/src/test/java/com/github/dannil/scbjavaclient/model/population/statistic/AverageAge_UnitTest.java +++ b/src/test/java/com/github/dannil/scbjavaclient/model/population/statistic/AverageAge_UnitTest.java @@ -88,8 +88,8 @@ public void setValues() { } @Test - public void getCodes() { - assertNotNull(AverageAge.getCodes()); + public void getInputs() { + assertNotNull(AverageAge.getInputs()); } @Test diff --git a/src/test/java/com/github/dannil/scbjavaclient/utility/RequestPoster_UnitTest.java b/src/test/java/com/github/dannil/scbjavaclient/utility/RequestPoster_UnitTest.java deleted file mode 100644 index 50730995d..000000000 --- a/src/test/java/com/github/dannil/scbjavaclient/utility/RequestPoster_UnitTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2016 Daniel Nilsson - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.github.dannil.scbjavaclient.utility; - -import static org.junit.Assert.assertNull; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -import com.github.dannil.scbjavaclient.exception.SCBClientUrlNotFoundException; -import com.github.dannil.scbjavaclient.utility.requester.AbstractRequester; - -@RunWith(JUnit4.class) -public class RequestPoster_UnitTest { - - // @Test - // public void callPrivateConstructor() throws InstantiationException, IllegalAccessException, - // IllegalArgumentException, InvocationTargetException { - // Constructor[] cons = AbstractRequester.class.getDeclaredConstructors(); - // cons[0].setAccessible(true); - // cons[0].newInstance(); - // cons[0].setAccessible(false); - // - // assertFalse(cons[0].isAccessible()); - // } - - @Test(expected = SCBClientUrlNotFoundException.class) - public void getCodesInvalidTable() { - String response = AbstractRequester.getCodes("ABCABCABC"); - - assertNull(response); - } - -}