From c1da7e9d3e67f9a268cb1af5fa1f7c6c2bff23ed Mon Sep 17 00:00:00 2001 From: Jorge Ortiz Date: Fri, 26 Jul 2024 19:46:42 +0200 Subject: [PATCH] MET-6037 update unit tests to support fix changes --- .../indexing/IndexerPreprocessorTest.java | 40 ++- .../europeana_record_to_sample_index_rdf.xml | 232 ++++++------------ 2 files changed, 116 insertions(+), 156 deletions(-) diff --git a/metis-indexing/src/test/java/eu/europeana/indexing/IndexerPreprocessorTest.java b/metis-indexing/src/test/java/eu/europeana/indexing/IndexerPreprocessorTest.java index bbd31f24f..d65388115 100644 --- a/metis-indexing/src/test/java/eu/europeana/indexing/IndexerPreprocessorTest.java +++ b/metis-indexing/src/test/java/eu/europeana/indexing/IndexerPreprocessorTest.java @@ -1,6 +1,9 @@ package eu.europeana.indexing; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import eu.europeana.indexing.base.IndexingTestUtils; import eu.europeana.indexing.exception.IndexingException; @@ -18,6 +21,9 @@ */ class IndexerPreprocessorTest { + private static final String CONTENT_TIER_URI = "http://www.europeana.eu/schemas/epf/contentTier"; + private static final String METADATA_TIER_URI = "http://www.europeana.eu/schemas/epf/metadataTier"; + /** * Preprocess record. * @@ -26,6 +32,7 @@ class IndexerPreprocessorTest { */ @Test void preprocessRecord() throws SerializationException, IndexingException { + // given final RdfConversionUtils conversionUtils = new RdfConversionUtils(); final RDF inputRdf = conversionUtils.convertStringToRdf( IndexingTestUtils.getResourceFileContent("europeana_record_to_sample_index_rdf.xml")); @@ -33,9 +40,38 @@ void preprocessRecord() throws SerializationException, IndexingException { true, List.of(), true, true); + // when TierResults results = IndexerPreprocessor.preprocessRecord(inputRdf, indexingProperties); - assertEquals("4", results.getMediaTier().toString()); - assertEquals("B", results.getMetadataTier().toString()); + // then + List tierProvidedData = inputRdf.getAggregationList() + .stream() + .map(provideddata -> provideddata.getHasQualityAnnotationList() + .stream() + .map(q -> q.getQualityAnnotation().getHasBody() + .getResource()).toList()) + .findFirst().orElse(null); + + List tierEuropeanaData = inputRdf.getEuropeanaAggregationList() + .stream() + .map(eudata -> eudata.getHasQualityAnnotationList() + .stream() + .map(q -> q.getQualityAnnotation().getHasBody().getResource()) + .toList()) + .findFirst().orElse(null); + + // verify two different aggregation has different calculations + assertArrayEquals(new String[]{CONTENT_TIER_URI + "1", METADATA_TIER_URI + "A"}, tierProvidedData.toArray()); + assertArrayEquals(new String[]{CONTENT_TIER_URI + "1", METADATA_TIER_URI + "B"}, tierEuropeanaData.toArray()); + + // verify return of tier calculation + assertEquals("1", results.getMediaTier().toString()); + assertEquals("A", results.getMetadataTier().toString()); + + // verify return is equal to aggregation and not europeana aggregation + assertTrue(tierProvidedData.contains(CONTENT_TIER_URI + results.getMediaTier().toString()) && + tierProvidedData.contains(METADATA_TIER_URI + results.getMetadataTier().toString())); + assertFalse(tierEuropeanaData.contains(CONTENT_TIER_URI + results.getMediaTier().toString()) && + tierEuropeanaData.contains(METADATA_TIER_URI + results.getMetadataTier().toString())); } } diff --git a/metis-indexing/src/test/resources/europeana_record_to_sample_index_rdf.xml b/metis-indexing/src/test/resources/europeana_record_to_sample_index_rdf.xml index 945c43188..948f71738 100644 --- a/metis-indexing/src/test/resources/europeana_record_to_sample_index_rdf.xml +++ b/metis-indexing/src/test/resources/europeana_record_to_sample_index_rdf.xml @@ -1,97 +1,37 @@ - - - - c1739a4bddc51ed13cbb57f9d911dae9 - 62-7 - - application/pdf - 13924049 - 300 + + + + + image/jpeg + 112031 + 562 + 761 + sRGB + #C0C0C0 + #A9A9A9 + #BDB76B + #BC8F8F + #D2B48C + #808080 + portrait - + text/html - 0 + 1477 - - Titus Brandsma - Тит Брандсма - Titus Brandsma - Titus Brandsma - Titus Brandsma - Titus Brandsma - Tito Brandsma - Titus Brandsma - Titus Brandsma - Titus Brandsma - Tytus Brandsma - Titus Brandsma - Titus Brandsma - Titus Brandsma - Anno Sjoerd Brandsma - F. Titus Brandsma O.Carm. - Брандсма, Титус - Титус Брандсма - Брандсма, Тит - Tito Brandsma - Beato tito brandsma - Anno Sjoerd Titus Brandsma - Titus Brandsma, O.Carm. - Anno Sjoerd Brandsma - F. Titus Brandsma O.Carm. - Titus Brandsma - Anno Sjoerd Brandsma - Bł. Tytus - Błogosławiony Tytus - Anno Sjoerd Brandsma - F. Titus Brandsma O.Carm. - Anno Sjoerd Brandsma - T. Brandsma - Tito Brandsma - Titus Brandsma, O.Carm. - F. Titus Brandsma O.Carm. - P. Titus Brandsma O.Carm. - Fra Titus Brandsma O.Carm. - Anno Sjoerd Brandsma - Niederländischer Theologe im Widerstand gegen den Nationalsozialismus - Nederländsk karmelitermunk, präst, och professor i filosofi - Dutch Carmelite friar, Catholic priest, professor of philosophy and saint - Sacerdote olandese - Prêtre carme néerlandais, canonisé le 15 mai 2022 - Călugăr carmelit, profesor de filozofie, victimă a regimului nazist - Nederlands priester, martelaar en heilige - Frare carmelita holandès, sacerdot catòlic, professor de filosofia i esperantista - 1881-02-23 - 1942-07-26 - - - - - - - - - - - - - - - - - - 1942/1942 + + 1923 - 1942-01-01 - 1942-12-31 - 1942/1942 - - - 1942~ - approximate - - 1942-01-01 - 1942-12-31 - 1942~ + 1923-01-01 + 1923-12-31 + 1923 20. Jahrhundert @@ -141,6 +81,11 @@ '900 Novecento 20e siècle + Siglo 20 + El siglo pasado + Siglo veinte + Siglo XX después de Cristo + Siglo XX d. C. 1901-01-01 2000-12-31 @@ -152,82 +97,61 @@ + - - Brandsma, Anno Sjoerd, 1881-1942 - Brandsma, Titus, father, 1881-1942 - Brandsma, Titus, Saint, 1881-1942 - - - - - - - Brandsma, Titus, 1881-1942 - - - archival material - - The physical materials that make up the mass of an archive. Distinguished from AAT "archives (groupings)." - De fysieke materialen die samen een archief vormen. In de AAT te onderscheiden van 'archieven (groepen)'. - archival materials - archiefmateriaal - - - - - - - - - + + + + + + + - - - - #providedCHO_NL-BwdADRKF-2_62-7 - nld - - true - - - - - - Brandsma, Titus, O.Carm., 1881-1942 - - [ca. 1942] - 62-7 - dut - Teksten (fotokopieën, vijf bladzijden), door - Titus geschreven voor zijn boek over de H. Theresia. (originelen aanwezig in - het N.C.I. te Boxmeer). - - 1942/1942 - 1 omslag - - + + Beaupre, Antoni.(Red.) + 1923 + Wojewódzka Biblioteka Publiczna w Krakowie + image/vnd.djvu + pol + Spółka Wydawnicza "Czas" + Biblioteka Książąt Czartoryskich + 20 w. + gazety polskie + Czas. 1923, nr 251 (10 XI) + czasopismo + Dziennik polityczny i literacko-społeczny; organ konserwatystów. - Opis fiz.: 4 s. ; 61 cm. false - - + + TEXT - - + + + #nnhSX08 + pol + true + 1923 + + + + + + Europeana Foundation Europeana Foundation - 50_test_13032023_1018 + 305_local_26072024_1620 Netherlands - + nl - 8 + 6 - - Archive and Documentation Center for RK Friesland - Archief- en Documentatiecentrum voor R.K. Friesland + + Digital Libraries Federation + Federacja Bibliotek Cyfrowych - - Archives Portal Europe + + Malopolska Digital Library + Małopolska Biblioteka Cyfrowa