PxwebIndicatorsParser { public List<StatisticalIndicator> parse(List<DatasourceLayer> layers) { return parse(null, layers); } PxwebIndicatorsParser(PxwebConfig config); List<StatisticalIndicator> parse(List<DatasourceLayer> layers);  }
@Test public void testParseWithPXfileConfig() throws Exception { PxwebIndicatorsParser parser = getParser("config2pxfile.json"); List<StatisticalIndicator> indicators = parser.parse(getLayers()); int expectedCount = 31; String expectedName = "Taajama-aste, %"; String expectedId = "kuntien_avainluvut_2017_aikasarja.px::M408"; assertEquals("Should find " + expectedCount + " indicators", expectedCount, indicators.size()); assertEquals("Should find " + expectedName + " as first indicator name", expectedName, indicators.get(0).getName(PropertyUtil.getDefaultLanguage())); assertEquals("Should find " + expectedId + " as first indicator id", expectedId, indicators.get(0).getId()); assertEquals("Should find one dimension", 1, indicators.get(0).getDataModel().getDimensions().size()); assertEquals("Should find dimension 'vuosi'", "Vuosi", indicators.get(0).getDataModel().getDimension("vuosi").getName()); }
@Test @Ignore("Assumes network connectivity") public void testParseConfigWithoutIndicatorKey() throws Exception { PxwebIndicatorsParser parser = getParser("config2folderstruct_tk.json"); PropertyUtil.addProperty("oskari.locales", "en, fi, sv", true); List<StatisticalIndicator> indicators = parser.parse(getLayers()); int expectedCount = 2; String expectedName = "Municipal key figures 1987-2018"; String expectedId = "kuntien_avainluvut_2019_aikasarja.px"; assertEquals("Should find " + expectedCount + " indicators", expectedCount, indicators.size()); assertEquals("Should find " + expectedName + " as first indicator name", expectedName, indicators.get(0).getName(PropertyUtil.getDefaultLanguage())); assertEquals("Should find " + expectedId + " as first indicator id", expectedId, indicators.get(0).getId()); assertEquals("Should find two dimensions", 2, indicators.get(0).getDataModel().getDimensions().size()); assertEquals("Should find dimension 'Vuosi'", "Year", indicators.get(0).getDataModel().getDimension("Vuosi").getName()); assertEquals("Should find dimension 'Information'", "Information", indicators.get(0).getDataModel().getDimension("Tiedot").getName()); PropertyUtil.clearProperties(); }
@Test @Ignore("Assumes network connectivity") public void testParseConfigWithIndicatorKey() throws Exception { PxwebIndicatorsParser parser = getParser("config2folderstruct_tk_indicator_key.json"); PropertyUtil.addProperty("oskari.locales", "en, fi, sv", true); List<StatisticalIndicator> indicators = parser.parse(getLayers()); int expectedCount = 32; String expectedName = "Degree of urbanisation, %"; String expectedId = "kuntien_avainluvut_2019_aikasarja.px::M408"; assertEquals("Should find " + expectedCount + " indicators", expectedCount, indicators.size()); assertEquals("Should find " + expectedName + " as first indicator name", expectedName, indicators.get(0).getName(PropertyUtil.getDefaultLanguage())); assertEquals("Should find " + expectedId + " as first indicator id", expectedId, indicators.get(0).getId()); assertEquals("Should find two dimensions", 1, indicators.get(0).getDataModel().getDimensions().size()); assertEquals("Should find dimension 'vuosi'", "Vuosi", indicators.get(0).getDataModel().getDimension("vuosi").getName()); PropertyUtil.clearProperties(); }
@Test @Ignore("Assumes network connectivity") public void testParseConfigWithoutIndicatorKeyHKI() throws Exception { PxwebIndicatorsParser parser = getParser("config2folderstruct_hki.json"); List<StatisticalIndicator> indicators = parser.parse(getLayers()); int expectedCount = 16; String expectedName = "Helsingin asuntokuntien tulot asuntokunnan elinvaiheen ja alueen mukaan 2014-"; String expectedId = "Asuntokuntien tulot/A01AS_HKI_Asuntokuntien_tulot_elinvaihe.px"; assertEquals("Should find " + expectedCount + " indicators", expectedCount, indicators.size()); assertEquals("Should find " + expectedName + " as first indicator name", expectedName, indicators.get(0).getName(PropertyUtil.getDefaultLanguage())); assertEquals("Should find " + expectedId + " as first indicator id", expectedId, indicators.get(0).getId()); assertEquals("Should find three dimensions", 3, indicators.get(0).getDataModel().getDimensions().size()); assertEquals("Should find dimension 'vuosi'", "Vuosi", indicators.get(0).getDataModel().getDimension("vuosi").getName()); assertEquals("Should find dimension 'Elinvaihe'", "Elinvaihe", indicators.get(0).getDataModel().getDimension("Elinvaihe").getName()); assertEquals("Should find dimension 'Tieto'", "Tieto", indicators.get(0).getDataModel().getDimension("Tieto").getName()); }
@Test public void testParseWithFolderStructureConfig() throws Exception { PxwebIndicatorsParser parser = getParser("config2folderstructWithIndicatorKey.json"); List<StatisticalIndicator> indicators = parser.parse(getLayers()); int expectedCount = 62; String expectedName = "Taajama-aste, %"; String expectedId = "kuntien_avainluvut_2017_aikasarja.px::M408"; assertEquals("Should find " + expectedCount + " indicators", expectedCount, indicators.size()); assertEquals("Should find " + expectedName + " as first indicator name", expectedName, indicators.get(0).getName(PropertyUtil.getDefaultLanguage())); assertEquals("Should find " + expectedId + " as first indicator id", expectedId, indicators.get(0).getId()); assertEquals("Should find one dimension", 1, indicators.get(0).getDataModel().getDimensions().size()); assertEquals("Should find dimension 'vuosi'", "Vuosi", indicators.get(0).getDataModel().getDimension("vuosi").getName()); }
@Test @Ignore("Assumes network connectivity") public void testHKIModelLive() throws Exception { JSONObject json = ResourceHelper.readJSONResource("config2folderstruct_hki_live.json", this); PxwebConfig config = new PxwebConfig(json, 1); PxwebIndicatorsParser parser = new PxwebIndicatorsParser(config); List<DatasourceLayer> layers = new ArrayList<>(); List<StatisticalIndicator> indicators = parser.parse(layers); System.out.println(indicators.size()); }
@Test @Ignore("Assumes network connectivity") public void testLUKEModelLive() throws Exception { JSONObject json = ResourceHelper.readJSONResource("config2folderstruct_luke.json", this); PxwebConfig config = new PxwebConfig(json, 1); PxwebIndicatorsParser parser = new PxwebIndicatorsParser(config); List<DatasourceLayer> layers = new ArrayList<>(); List<StatisticalIndicator> indicators = parser.parse(layers); System.out.println(indicators.size()); }