Skip to content

Commit

Permalink
MET-5974: upgrade enrichment API client version. (#674)
Browse files Browse the repository at this point in the history
  • Loading branch information
jochen-vermeulen authored May 8, 2024
1 parent d6f7d29 commit 548f562
Show file tree
Hide file tree
Showing 9 changed files with 233 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
import java.util.stream.Stream;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
Expand Down Expand Up @@ -91,12 +91,12 @@ private static String getResourceFileContent(String fileName) {
}

private static void setEntityAPIMocks() {
wireMockServer.stubFor(get(urlEqualTo("/entitymgmt/concept/base/84?wskey=api2demo"))
wireMockServer.stubFor(get(urlEqualTo("/entitymgmt/concept/84?wskey=api2demo"))
.willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBody(getResourceFileContent("entity-api/entity-api-response-mgmt-concept-base.json"))
.withStatus(HttpStatus.OK.value())));
wireMockServer.stubFor(get(urlEqualTo("/entitymgmt/concept/base/3401?wskey=api2demo"))
wireMockServer.stubFor(get(urlEqualTo("/entitymgmt/concept/3401?wskey=api2demo"))
.willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBody(getResourceFileContent("entity-api/entity-api-response-mgmt-concept-base-ii.json"))
Expand Down Expand Up @@ -137,7 +137,7 @@ private static void setEntityAPIMocks() {
.withStatus(HttpStatus.OK.value())));

wireMockServer.stubFor(
get(urlEqualTo("/entitymgmt/organization/base/1482250000004671158?wskey=api2demo"))
get(urlEqualTo("/entitymgmt/organization/1482250000004671158?wskey=api2demo"))
.willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBody(getResourceFileContent("entity-api/entity-api-response-mgmt-organization-base.json"))
Expand Down Expand Up @@ -206,7 +206,7 @@ private static void setEntityAPIMocks() {
.withHeader("Content-Type", "application/json")
.withBody(getResourceFileContent("entity-api/entity-api-response-concept-ii.json"))
.withStatus(HttpStatus.OK.value())));
wireMockServer.stubFor(get(urlEqualTo("/entitymgmt/concept/base/62?wskey=api2demo"))
wireMockServer.stubFor(get(urlEqualTo("/entitymgmt/concept/62?wskey=api2demo"))
.willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBody(
Expand Down Expand Up @@ -325,10 +325,6 @@ void testEnrichmentWorkerHappyFlow(String inputRecord, RecordStatus recordStatus
setDereferenceMocks();
setEntityAPIMocks();

TreeSet<Mode> modeSetWithBoth = new TreeSet<>();
modeSetWithBoth.add(Mode.ENRICHMENT);
modeSetWithBoth.add(Mode.DEREFERENCE);

EnricherProvider enricherProvider = new EnricherProvider();
enricherProvider.setEnrichmentPropertiesValues(
"http://localhost:" + wireMockServer.port() + "/entitymgmt",
Expand All @@ -349,11 +345,12 @@ void testEnrichmentWorkerHappyFlow(String inputRecord, RecordStatus recordStatus
// Execute the worker
final EnrichmentWorkerImpl worker = new EnrichmentWorkerImpl(dereferencer, enricher);

ProcessedResult<String> output = worker.process(inputRecord, modeSetWithBoth);
ProcessedResult<String> output = worker.process(inputRecord, Set.of(Mode.ENRICHMENT, Mode.DEREFERENCE));

LOGGER.info("REPORT: {}\n\n", output.getReport());
LOGGER.info("RECORD: {}\n\n", output.getProcessedRecord());
LOGGER.info("STATUS: {}", output.getRecordStatus());

assertEquals(recordStatus, output.getRecordStatus());
}

Expand Down Expand Up @@ -527,17 +524,18 @@ void testEnrichmentWorkerSerializationException() {
final EnrichmentWorkerImpl worker = spy(new EnrichmentWorkerImpl(null, null));

final ProcessedResult<String> stringProcessedResult = worker.process(
"<?xml version=\"1.0\"?>\n"
+ "<rdf:RDF\n"
+ "xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"
+ "xmlns:si=\"https://www.europeana.eu/rdf/\">\n"
+ "<rdf:Description rdf:about=\"https://www.europeana.eu\">\n"
+ " <si:title>Europe Cultural Heritage</si:title>\n"
+ " <si:author>Europeana</si:author>\n"
+ "</rdf:Description>\n"
+ "</rdf:RDF>");
"""
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:si="https://www.europeana.eu/rdf/">
<rdf:Description rdf:about="https://www.europeana.eu">
<si:title>Europe Cultural Heritage</si:title>
<si:author>Europeana</si:author>
</rdf:Description>
</rdf:RDF>""");
final String returnedString = stringProcessedResult.getProcessedRecord();
assertEquals(null, returnedString);
assertNull(returnedString);
for (Report report : stringProcessedResult.getReport()) {
assertEquals(Type.ERROR, report.getMessageType());
assertTrue(report.getMessage().contains("Error serializing rdf"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"@context": "http://www.europeana.eu/schemas/context/entity.jsonld",
"id": "http://data.europeana.eu/organization/1482250000004671158",
"id": "http://data.europeana.eu/organization/1585",
"type": "Organization",
"prefLabel": {
"en": "The European Film Gateway"
Expand All @@ -13,49 +13,50 @@
"hiddenLabel": [
"EFG - The European Film Gateway"
],
"europeanaRole": {
"en": [
"Aggregator",
"Data Partner"
]
},
"organizationDomain": {
"en": [
"Film"
]
},
"geographicLevel": {
"en": "European"
"europeanaRole": [
{
"id": "http://data.europeana.eu/vocabulary/role/Aggregator",
"type": "Concept"
},
{
"id": "http://data.europeana.eu/vocabulary/role/ProvidingInstitution",
"type": "Concept"
}
],
"country": {
"id": "http://data.europeana.eu/place/80",
"type": "Place"
},
"country": "DE",
"language": [
"en"
],
"homepage": "http://www.europeanfilmgateway.eu",
"hasAddress": {
"id": "https://crm.zoho.com/crm/org51823723/tab/Accounts/1482250000004671158#address",
"id": "https://crm.zoho.eu/crm/org20085137532/tab/Accounts/486281000000944495#address",
"type": "Address",
"streetAddress": "Schaumainkai 41",
"postalCode": "60596",
"locality": "Frankfurt am Main",
"countryName": "Germany"
},
"identifier": [
"1482250000004671158"
"486281000000944495"
],
"sameAs": [
"https://crm.zoho.com/crm/org51823723/tab/Accounts/1482250000004671158"
"https://crm.zoho.eu/crm/org20085137532/tab/Accounts/486281000000944495",
"http://data.europeana.eu/organization/1482250000004671158"
],
"isAggregatedBy": {
"id": "http://data.europeana.eu/organization/1482250000004671158#aggregation",
"id": "http://data.europeana.eu/organization/1585#aggregation",
"type": "Aggregation",
"created": "2022-10-17T15:41:19Z",
"modified": "2022-12-05T17:18:33Z",
"created": "2024-02-22T17:13:29Z",
"modified": "2024-04-12T19:09:35Z",
"pageRank": 0.0,
"recordCount": 624987,
"score": 2829,
"recordCount": 601694,
"score": 1331,
"aggregates": [
"http://data.europeana.eu/organization/1482250000004671158#aggr_europeana",
"http://data.europeana.eu/organization/1482250000004671158#aggr_source_1"
"http://data.europeana.eu/organization/1585#aggr_europeana",
"http://data.europeana.eu/organization/1585#aggr_source_1"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,52 +1,66 @@
{
"@context": "http://www.europeana.eu/schemas/context/entity.jsonld",
"id": "https://entity-api-v2-production.eanadev.org/entity/search?wskey=api2demo&type=organization&text=Lietuvos%20Centrinis%20Valstyb%C3%A9s%20Archyvas&page=0&pageSize=10",
"type": "ResultPage",
"total": 1,
"partOf": {
"id": "https://entity-api-v2-production.eanadev.org/entity/search?wskey=api2demo&type=organization&text=Lietuvos%20Centrinis%20Valstyb%C3%A9s%20Archyvas",
"type": "ResultList",
"total": 1
"id": "http://data.europeana.eu/organization/2852",
"type": "Organization",
"prefLabel": {
"lt": "Lietuvos Centrinis Valstybes Archyvas",
"en": "Lithuanian Central State Archives"
},
"items": [
"acronym": {
"lt": [
"LCVA"
]
},
"description": {
"cs": "Litevský národní archiv",
"en": "Lithuanian national archives"
},
"europeanaRole": [
{
"id": "http://data.europeana.eu/organization/1482250000004507806",
"type": "Organization",
"prefLabel": {
"en": "Lithuanian Central State Archives",
"lt": "Lietuvos Centrinis Valstybes Archyvas"
},
"acronym": {
"lt": [
"LCVA"
]
},
"description": {
"cs": "Litevský národní archiv",
"en": "Lithuanian national archives"
},
"europeanaRole": [
"Data Provider"
],
"organizationDomain": [
"Archive"
],
"country": "LT",
"homepage": "http://www.archyvai.lt",
"mbox": [
"[email protected]"
],
"identifier": [
"1482250000004507806"
],
"sameAs": [
"https://crm.zoho.com/crm/org51823723/tab/Accounts/1482250000004507806",
"http://www.wikidata.org/entity/Q16458815",
"http://viaf.org/viaf/137563199",
"http://d-nb.info/gnd/1023214474",
"http://id.loc.gov/authorities/names/no2005018599",
"http://g.co/kg/g/12353pr3"
]
"id": "http://data.europeana.eu/vocabulary/role/ProvidingInstitution",
"type": "Concept"
}
]
}
],
"country": {
"id": "http://data.europeana.eu/place/94",
"type": "Place"
},
"language": [
"lt"
],
"homepage": "http://www.archyvai.lt",
"mbox": [
"[email protected]"
],
"hasAddress": {
"id": "https://crm.zoho.eu/crm/org20085137532/tab/Accounts/486281000000941518#address",
"type": "Address",
"countryName": "Lithuania"
},
"identifier": [
"486281000000941518"
],
"sameAs": [
"https://crm.zoho.eu/crm/org20085137532/tab/Accounts/486281000000941518",
"http://www.wikidata.org/entity/Q16458815",
"http://data.europeana.eu/organization/1482250000004507806",
"http://viaf.org/viaf/137563199",
"http://d-nb.info/gnd/1023214474",
"http://id.loc.gov/authorities/names/no2005018599",
"http://g.co/kg/g/12353pr3"
],
"isAggregatedBy": {
"id": "http://data.europeana.eu/organization/2852#aggregation",
"type": "Aggregation",
"created": "2024-02-22T17:17:16Z",
"modified": "2024-04-12T19:52:36Z",
"pageRank": 0.0,
"recordCount": 12812,
"score": 946,
"aggregates": [
"http://data.europeana.eu/organization/2852#aggr_europeana",
"http://data.europeana.eu/organization/2852#aggr_source_1",
"http://data.europeana.eu/organization/2852#aggr_source_2"
]
}
}
Loading

0 comments on commit 548f562

Please sign in to comment.