UnsdDataParser { public Map<String, IndicatorValue> get(StatisticalIndicatorDataModel selectors, String indicator, String[] areaCodes) { UnsdRequest request = new UnsdRequest(config); request.setIndicator(indicator); request.setAreaCodes(areaCodes); Map<String, IndicatorValue> result = new HashMap<>(); try { while (true) { JSONObject response = JSONHelper.createJSONObject(request.getIndicatorData(selectors)); result.putAll(parseIndicatorData(response)); if (isLastPage(response)) { break; } request.nextPage(); } } catch (JSONException ex) { throw new APIException("Error during parsing UNSD data response.", ex); } return result; } UnsdDataParser(UnsdConfig config); Map<String, IndicatorValue> get(StatisticalIndicatorDataModel selectors, String indicator, String[] areaCodes); StatisticalIndicatorDataDimension getTimeperiodDimensionFromIndicatorData(String timePeriodDimensionId,
            String indicator, String[] areaCodes); static void parseTimePeriod(Map<Integer, Set<Integer>> geoAreaCodesForYears, JSONObject response); static List<IdNamePair> getSortedListOfYearsThatBelongToSeveralGeoAreas(
            Map<Integer,  Set<Integer>> countOfAreaCodesForYear);  }
@Test public void testIndicatorSource() throws JSONException { Map<String, String> sources = UnsdIndicatorParser.parseSource(dataResponseUnlimited); assertNotNull("Indicator doesn't have source.", sources.get("en")); }
@Test public void testIndicatorDimensions() { StatisticalIndicatorDataModel m = UnsdIndicatorParser.parseDimensions(dataResponseUnlimited); assertNotNull(m); assertNotNull(m.getDimensions()); assertEquals(EXPECTED_DIMENSIONS_COUNT, m.getDimensions().size()); StatisticalIndicatorDataDimension d = m.getDimensions().get(0); assertEquals(EXPECTED_DIMENSION_ID, d.getId()); List<IdNamePair> dimensionsAllowedValues = d.getAllowedValues(); assertNotNull(dimensionsAllowedValues); assertEquals(EXPECTED_DIMENSION_ALLOWED_VALUES.size(), dimensionsAllowedValues.size()); EXPECTED_DIMENSION_ALLOWED_VALUES.forEach(v -> assertTrue( String.format("Expected key %s not found from dimensions parsed allowed values", v.getKey()), dimensionsAllowedValues.contains(v))); }