From fd705404a13875c7b2bdc7205df808827388ffd4 Mon Sep 17 00:00:00 2001 From: Alessia Bardi Date: Wed, 3 Feb 2021 10:28:17 +0100 Subject: [PATCH] tests for EU Open Data portal dataset mapping --- .../dnetlib/dhp/oa/graph/raw/MappersTest.java | 29 ++ .../eu/dnetlib/dhp/oa/graph/raw/eu_odp.xml | 367 ++++++++++++++++++ 2 files changed, 396 insertions(+) create mode 100644 dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/raw/eu_odp.xml diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/raw/MappersTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/raw/MappersTest.java index 9827dcc99..ffe71aa03 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/raw/MappersTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/raw/MappersTest.java @@ -19,6 +19,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import eu.dnetlib.dhp.oa.graph.clean.CleaningFunctionTest; @@ -406,6 +407,34 @@ public class MappersTest { System.out.println(p.getTitle().get(0).getValue()); } + @Test + void testEUOpenDataPortal() throws IOException { + final String xml = IOUtils.toString(getClass().getResourceAsStream("eu_odp.xml")); + final List list = new OdfToOafMapper(vocs, false).processMdRecord(xml); + + System.out.println("***************"); + System.out.println(new ObjectMapper().writeValueAsString(list)); + System.out.println("***************"); + final Dataset p = (Dataset) list.get(0); + assertValidId(p.getId()); + assertValidId(p.getCollectedfrom().get(0).getKey()); + assertTrue(StringUtils.isNotBlank(p.getTitle().get(0).getValue())); + assertEquals(0, p.getAuthor().size()); + assertEquals(0, p.getPid().size()); + assertEquals("OPEN", p.getBestaccessright().getClassid()); + assertEquals("dataset", p.getResulttype().getClassname()); + assertEquals(1, p.getInstance().size()); + assertEquals("OPEN", p.getInstance().get(0).getAccessright().getClassid()); + assertValidId(p.getInstance().get(0).getCollectedfrom().getKey()); + assertValidId(p.getInstance().get(0).getHostedby().getKey()); + assertEquals( + "CC_BY_4_0", p.getInstance().get(0).getLicense().getValue()); + assertEquals(1, p.getInstance().get(0).getUrl().size()); + assertEquals(1, p.getInstance().size()); + System.out.println(p.getInstance().get(0).getUrl().get(0)); + System.out.println(p.getInstance().get(0).getHostedby().getValue()); + } + private void assertValidId(final String id) { assertEquals(49, id.length()); assertEquals('|', id.charAt(2)); diff --git a/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/raw/eu_odp.xml b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/raw/eu_odp.xml new file mode 100644 index 000000000..2fd7cfa2d --- /dev/null +++ b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/raw/eu_odp.xml @@ -0,0 +1,367 @@ + + + + r3c4b2081b22::0007d64b38bb2b399120f9993f95d911 + 60a0a5b0-b63c-473f-b8bc-207ea037eb3b + 2021-01-28T17:24:33.095+01:00 + r3c4b2081b22 + 2021-02-03T10:16:27.948+01:00 + + + + http://data.europa.eu/88u/dataset/60a0a5b0-b63c-473f-b8bc-207ea037eb3b + + + GMIS - Favourable feeding habitat of adult Atlantic bluefin tuna (ABFT) Monthly 1998-2017 (frequency of occurence, %) + + JRC + 2019 + + 2019-07-09 + + Dataset + + The favourable feeding habitat of the Atlantic bluefin tuna is daily identified linking their ecological traits with environmental variables from satellite remote sensing and physical ocean models. The feeding habitat is mostly related to the occurrence of productive oceanic features (such as eddies) that are detected by satellite sensors of ocean colour (chlorophyll-a fronts). The physical variables used are sea surface temperature and sea surface height anomaly. More information: https://fishreg.jrc.ec.europa.eu/fish-habitat, Peer-reviewed publication: http://www.sciencedirect.com/science/article/pii/S0079661116000070 + + + protected area + environmental monitoring + oceanography + ocean + Environmental Monitoring Facilities + Environment + Protected Sites + Oceanographic Geographical Features + environmental data + http://publications.europa.eu/resource/authority/data-theme/TECH + http://publications.europa.eu/resource/authority/data-theme/ENVI + http://eurovoc.europa.eu/2114 + http://eurovoc.europa.eu/2107 + http://eurovoc.europa.eu/4801 + http://eurovoc.europa.eu/3140 + + + http://publications.europa.eu/resource/authority/file-type/OP_DATPRO + + + + http://publications.europa.eu/resource/authority/country/ESH + + + http://publications.europa.eu/resource/authority/country/ESP + + + http://publications.europa.eu/resource/authority/country/EST + + + http://publications.europa.eu/resource/authority/country/ETH + + + http://publications.europa.eu/resource/authority/country/DNK + + + http://publications.europa.eu/resource/authority/country/DZA + + + http://publications.europa.eu/resource/authority/country/EGY + + + http://publications.europa.eu/resource/authority/country/ERI + + + http://publications.europa.eu/resource/authority/country/FIN + + + http://publications.europa.eu/resource/authority/country/FRA + + + http://publications.europa.eu/resource/authority/country/1A0 + + + http://publications.europa.eu/resource/authority/country/AUT + + + http://publications.europa.eu/resource/authority/country/BGR + + + http://publications.europa.eu/resource/authority/country/MDA + + + http://publications.europa.eu/resource/authority/country/MCO + + + http://publications.europa.eu/resource/authority/country/LUX + + + http://publications.europa.eu/resource/authority/country/LTU + + + http://publications.europa.eu/resource/authority/country/MAR + + + http://publications.europa.eu/resource/authority/country/LVA + + + http://publications.europa.eu/resource/authority/country/LBN + + + http://publications.europa.eu/resource/authority/country/JOR + + + http://publications.europa.eu/resource/authority/country/LIE + + + http://publications.europa.eu/resource/authority/country/LBY + + + http://publications.europa.eu/resource/authority/country/TUN + + + http://publications.europa.eu/resource/authority/country/TUR + + + http://publications.europa.eu/resource/authority/country/SVK + + + http://publications.europa.eu/resource/authority/country/SVN + + + http://publications.europa.eu/resource/authority/country/SRB + + + http://publications.europa.eu/resource/authority/country/SSD + + + http://publications.europa.eu/resource/authority/country/TCD + + + http://publications.europa.eu/resource/authority/country/TGO + + + http://publications.europa.eu/resource/authority/country/SWE + + + http://publications.europa.eu/resource/authority/country/SYR + + + http://publications.europa.eu/resource/authority/country/AND + + + http://publications.europa.eu/resource/authority/country/BFA + + + http://publications.europa.eu/resource/authority/country/GRC + + + http://publications.europa.eu/resource/authority/country/GNB + + + http://publications.europa.eu/resource/authority/country/GGY + + + http://publications.europa.eu/resource/authority/country/GEO + + + http://publications.europa.eu/resource/authority/country/GBR + + + http://publications.europa.eu/resource/authority/country/FRO + + + http://publications.europa.eu/resource/authority/country/GMB + + + http://publications.europa.eu/resource/authority/country/GIN + + + http://publications.europa.eu/resource/authority/country/GIB + + + http://publications.europa.eu/resource/authority/country/GHA + + + http://publications.europa.eu/resource/authority/country/MKD + + + http://publications.europa.eu/resource/authority/country/MLI + + + http://publications.europa.eu/resource/authority/country/MLT + + + http://publications.europa.eu/resource/authority/country/MNE + + + http://publications.europa.eu/resource/authority/country/MRT + + + http://publications.europa.eu/resource/authority/country/NER + + + http://publications.europa.eu/resource/authority/country/NGA + + + http://publications.europa.eu/resource/authority/country/NLD + + + http://publications.europa.eu/resource/authority/country/NOR + + + http://publications.europa.eu/resource/authority/country/POL + + + http://publications.europa.eu/resource/authority/country/ALB + + + http://publications.europa.eu/resource/authority/country/BEN + + + http://publications.europa.eu/resource/authority/country/VAT + + + http://publications.europa.eu/resource/authority/country/UKR + + + http://publications.europa.eu/resource/authority/country/CAF + + + http://publications.europa.eu/resource/authority/country/BLR + + + http://publications.europa.eu/resource/authority/country/CIV + + + http://publications.europa.eu/resource/authority/country/CHE + + + http://publications.europa.eu/resource/authority/country/CPV + + + http://publications.europa.eu/resource/authority/country/CMR + + + http://publications.europa.eu/resource/authority/country/CZE + + + http://publications.europa.eu/resource/authority/country/CYP + + + http://publications.europa.eu/resource/authority/country/DJI + + + http://publications.europa.eu/resource/authority/country/DEU + + + http://publications.europa.eu/resource/authority/country/ITA + + + http://publications.europa.eu/resource/authority/country/JEY + + + http://publications.europa.eu/resource/authority/country/ISL + + + http://publications.europa.eu/resource/authority/country/ISR + + + http://publications.europa.eu/resource/authority/country/IRL + + + http://publications.europa.eu/resource/authority/country/IRQ + + + http://publications.europa.eu/resource/authority/country/HUN + + + http://publications.europa.eu/resource/authority/country/IMN + + + http://publications.europa.eu/resource/authority/country/GRL + + + http://publications.europa.eu/resource/authority/country/HRV + + + http://publications.europa.eu/resource/authority/country/ALA + + + http://publications.europa.eu/resource/authority/country/BEL + + + http://publications.europa.eu/resource/authority/country/BIH + + + http://publications.europa.eu/resource/authority/country/SLE + + + http://publications.europa.eu/resource/authority/country/SEN + + + http://publications.europa.eu/resource/authority/country/SDN + + + http://publications.europa.eu/resource/authority/country/SAU + + + http://publications.europa.eu/resource/authority/country/RUS + + + http://publications.europa.eu/resource/authority/country/ROU + + + http://publications.europa.eu/resource/authority/country/PSE + + + http://publications.europa.eu/resource/authority/country/PRT + + + http://publications.europa.eu/resource/authority/country/SOM + + + http://publications.europa.eu/resource/authority/country/SMR + + + + EU + OPEN + 0021 + 2019-07-09 + + + CC_BY_4_0 + ENG + + + + + https%3A%2F%2Fdata.europa.eu%2Feuodp%2Fdata%2Fapiodp%2Faction%2Fpackage_search + + + + + + + false + false + 0.9 + + + + + +