diff --git a/metis-enrichment/metis-enrichment-client/src/test/java/eu/europeana/enrichment/rest/client/EnrichmentWorkerImplTest.java b/metis-enrichment/metis-enrichment-client/src/test/java/eu/europeana/enrichment/rest/client/EnrichmentWorkerImplTest.java index 5a8adf1be..8bcce9fe7 100644 --- a/metis-enrichment/metis-enrichment-client/src/test/java/eu/europeana/enrichment/rest/client/EnrichmentWorkerImplTest.java +++ b/metis-enrichment/metis-enrichment-client/src/test/java/eu/europeana/enrichment/rest/client/EnrichmentWorkerImplTest.java @@ -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; @@ -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")) @@ -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")) @@ -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( @@ -325,10 +325,6 @@ void testEnrichmentWorkerHappyFlow(String inputRecord, RecordStatus recordStatus setDereferenceMocks(); setEntityAPIMocks(); - TreeSet modeSetWithBoth = new TreeSet<>(); - modeSetWithBoth.add(Mode.ENRICHMENT); - modeSetWithBoth.add(Mode.DEREFERENCE); - EnricherProvider enricherProvider = new EnricherProvider(); enricherProvider.setEnrichmentPropertiesValues( "http://localhost:" + wireMockServer.port() + "/entitymgmt", @@ -349,11 +345,12 @@ void testEnrichmentWorkerHappyFlow(String inputRecord, RecordStatus recordStatus // Execute the worker final EnrichmentWorkerImpl worker = new EnrichmentWorkerImpl(dereferencer, enricher); - ProcessedResult output = worker.process(inputRecord, modeSetWithBoth); + ProcessedResult 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()); } @@ -527,17 +524,18 @@ void testEnrichmentWorkerSerializationException() { final EnrichmentWorkerImpl worker = spy(new EnrichmentWorkerImpl(null, null)); final ProcessedResult stringProcessedResult = worker.process( - "\n" - + "\n" - + "\n" - + " Europe Cultural Heritage\n" - + " Europeana\n" - + "\n" - + ""); + """ + + + + Europe Cultural Heritage + Europeana + + """); 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")); diff --git a/metis-enrichment/metis-enrichment-client/src/test/resources/entity-api/entity-api-response-mgmt-organization-base.json b/metis-enrichment/metis-enrichment-client/src/test/resources/entity-api/entity-api-response-mgmt-organization-base.json index 2f5bd2166..3618d3b1a 100644 --- a/metis-enrichment/metis-enrichment-client/src/test/resources/entity-api/entity-api-response-mgmt-organization-base.json +++ b/metis-enrichment/metis-enrichment-client/src/test/resources/entity-api/entity-api-response-mgmt-organization-base.json @@ -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" @@ -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" ] } -} +} \ No newline at end of file diff --git a/metis-enrichment/metis-enrichment-client/src/test/resources/entity-api/entity-api-response-organization-ii.json b/metis-enrichment/metis-enrichment-client/src/test/resources/entity-api/entity-api-response-organization-ii.json index aa2a45a45..f93eadd1c 100644 --- a/metis-enrichment/metis-enrichment-client/src/test/resources/entity-api/entity-api-response-organization-ii.json +++ b/metis-enrichment/metis-enrichment-client/src/test/resources/entity-api/entity-api-response-organization-ii.json @@ -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": [ - "lcva@archyvai.lt" - ], - "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": [ + "lcva@archyvai.lt" + ], + "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" + ] + } +} \ No newline at end of file diff --git a/metis-enrichment/metis-enrichment-client/src/test/resources/entity-api/entity-api-response-organization-iii.json b/metis-enrichment/metis-enrichment-client/src/test/resources/entity-api/entity-api-response-organization-iii.json index aa2a45a45..f93eadd1c 100644 --- a/metis-enrichment/metis-enrichment-client/src/test/resources/entity-api/entity-api-response-organization-iii.json +++ b/metis-enrichment/metis-enrichment-client/src/test/resources/entity-api/entity-api-response-organization-iii.json @@ -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": [ - "lcva@archyvai.lt" - ], - "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": [ + "lcva@archyvai.lt" + ], + "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" + ] + } +} \ No newline at end of file diff --git a/metis-enrichment/metis-enrichment-client/src/test/resources/entity-api/entity-api-response-organization.json b/metis-enrichment/metis-enrichment-client/src/test/resources/entity-api/entity-api-response-organization.json index 456fb6a51..3618d3b1a 100644 --- a/metis-enrichment/metis-enrichment-client/src/test/resources/entity-api/entity-api-response-organization.json +++ b/metis-enrichment/metis-enrichment-client/src/test/resources/entity-api/entity-api-response-organization.json @@ -1,49 +1,62 @@ { "@context": "http://www.europeana.eu/schemas/context/entity.jsonld", - "id": "https://entity-api-v2-production.eanadev.org/entity/search?lang=en&text=EFG%20-%20The%20European%20Film%20Gateway&type=organization&wskey=api2demo&page=0&pageSize=10", - "type": "ResultPage", - "total": 1, - "partOf": { - "id": "https://entity-api-v2-production.eanadev.org/entity/search?lang=en&text=EFG%20-%20The%20European%20Film%20Gateway&type=organization&wskey=api2demo", - "type": "ResultList", - "total": 1 + "id": "http://data.europeana.eu/organization/1585", + "type": "Organization", + "prefLabel": { + "en": "The European Film Gateway" }, - "items": [ + "acronym": { + "en": [ + "EFG" + ] + }, + "hiddenLabel": [ + "EFG - The European Film Gateway" + ], + "europeanaRole": [ + { + "id": "http://data.europeana.eu/vocabulary/role/Aggregator", + "type": "Concept" + }, { - "id": "http://data.europeana.eu/organization/1482250000004671158", - "type": "Organization", - "prefLabel": { - "en": "The European Film Gateway" - }, - "acronym": { - "en": [ - "EFG" - ] - }, - "europeanaRole": [ - "Aggregator", - "Data Partner" - ], - "organizationDomain": [ - "Film" - ], - "geographicLevel": "European", - "country": "DE", - "homepage": "http://www.europeanfilmgateway.eu", - "hasAddress": { - "id": "https://crm.zoho.com/crm/org51823723/tab/Accounts/1482250000004671158#address", - "type": "Address", - "streetAddress": "Schaumainkai 41", - "postalCode": "60596", - "locality": "Frankfurt am Main", - "countryName": "Germany" - }, - "identifier": [ - "1482250000004671158" - ], - "sameAs": [ - "https://crm.zoho.com/crm/org51823723/tab/Accounts/1482250000004671158" - ] + "id": "http://data.europeana.eu/vocabulary/role/ProvidingInstitution", + "type": "Concept" } - ] -} + ], + "country": { + "id": "http://data.europeana.eu/place/80", + "type": "Place" + }, + "language": [ + "en" + ], + "homepage": "http://www.europeanfilmgateway.eu", + "hasAddress": { + "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": [ + "486281000000944495" + ], + "sameAs": [ + "https://crm.zoho.eu/crm/org20085137532/tab/Accounts/486281000000944495", + "http://data.europeana.eu/organization/1482250000004671158" + ], + "isAggregatedBy": { + "id": "http://data.europeana.eu/organization/1585#aggregation", + "type": "Aggregation", + "created": "2024-02-22T17:13:29Z", + "modified": "2024-04-12T19:09:35Z", + "pageRank": 0.0, + "recordCount": 601694, + "score": 1331, + "aggregates": [ + "http://data.europeana.eu/organization/1585#aggr_europeana", + "http://data.europeana.eu/organization/1585#aggr_source_1" + ] + } +} \ No newline at end of file diff --git a/metis-enrichment/metis-enrichment-common/pom.xml b/metis-enrichment/metis-enrichment-common/pom.xml index 32c6f2bd4..5cdcb9439 100644 --- a/metis-enrichment/metis-enrichment-common/pom.xml +++ b/metis-enrichment/metis-enrichment-common/pom.xml @@ -9,7 +9,7 @@ metis-enrichment-common - 2.0 + 2.1.0 diff --git a/metis-enrichment/metis-enrichment-common/src/main/java/eu/europeana/enrichment/api/external/model/Organization.java b/metis-enrichment/metis-enrichment-common/src/main/java/eu/europeana/enrichment/api/external/model/Organization.java index c0ae58c7c..969b0e39a 100644 --- a/metis-enrichment/metis-enrichment-common/src/main/java/eu/europeana/enrichment/api/external/model/Organization.java +++ b/metis-enrichment/metis-enrichment-common/src/main/java/eu/europeana/enrichment/api/external/model/Organization.java @@ -136,7 +136,7 @@ public void setDepiction(Resource depiction) { } private void init(eu.europeana.entitymanagement.definitions.model.Organization organization) { - this.country = organization.getCountry(); + this.country = organization.getCountry().getEntityId(); this.homepage = new Resource(organization.getHomepage()); this.descriptions = convertMapToLabels(organization.getDescription()); this.acronyms = convertMultilingualMapToLabel(organization.getAcronym()); diff --git a/metis-enrichment/metis-enrichment-common/src/main/java/eu/europeana/enrichment/utils/EnrichmentBaseConverter.java b/metis-enrichment/metis-enrichment-common/src/main/java/eu/europeana/enrichment/utils/EnrichmentBaseConverter.java index 7d21796f2..fe5107bd3 100644 --- a/metis-enrichment/metis-enrichment-common/src/main/java/eu/europeana/enrichment/utils/EnrichmentBaseConverter.java +++ b/metis-enrichment/metis-enrichment-common/src/main/java/eu/europeana/enrichment/utils/EnrichmentBaseConverter.java @@ -12,6 +12,7 @@ import java.util.List; import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBException; +import java.util.Objects; /** * This class contains conversion tools for the {@link EnrichmentBase} class. @@ -42,7 +43,8 @@ public static EnrichmentBase convertToEnrichmentBase(String entityXml) throws JA * @return the enrichment bases */ public static List convertEntitiesToEnrichmentBase(List entities) { - return entities.stream().map(EnrichmentBaseConverter::convertEntitiesToEnrichmentBase).toList(); + return entities.stream().map(EnrichmentBaseConverter::convertEntitiesToEnrichmentBase) + .filter(Objects::nonNull).toList(); } /** @@ -58,6 +60,7 @@ public static EnrichmentBase convertEntitiesToEnrichmentBase(Entity entity) { case Concept -> new Concept((eu.europeana.entitymanagement.definitions.model.Concept) entity); case TimeSpan -> new TimeSpan((eu.europeana.entitymanagement.definitions.model.TimeSpan) entity); case Organization -> new Organization((eu.europeana.entitymanagement.definitions.model.Organization) entity); + default -> null; }; } } diff --git a/metis-enrichment/metis-enrichment-common/src/test/java/eu/europeana/enrichment/api/external/impl/ClientEntityResolverTest.java b/metis-enrichment/metis-enrichment-common/src/test/java/eu/europeana/enrichment/api/external/impl/ClientEntityResolverTest.java index 5a8f1973e..07c54a81a 100644 --- a/metis-enrichment/metis-enrichment-common/src/test/java/eu/europeana/enrichment/api/external/impl/ClientEntityResolverTest.java +++ b/metis-enrichment/metis-enrichment-common/src/test/java/eu/europeana/enrichment/api/external/impl/ClientEntityResolverTest.java @@ -23,7 +23,6 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; -import java.net.URL; import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -390,8 +389,10 @@ private void resultAssertions(Map ter } private void parentMatching(EntitiesAndExpectedEnrichmentBases entry, List children) { + final Set childIds = children.stream().map(Entity::getEntityId).collect(Collectors.toSet()); final List parentEntities = entry.getEntitiesWithParents().stream().flatMap(List::stream) - .filter(entity -> !children.contains(entity)).toList(); + .filter(entity -> !childIds.contains(entity.getEntityId())) + .toList(); for (Entity parentEntity : parentEntities) { when(entityClientApi.getEntityById(parentEntity.getEntityId())).thenReturn(parentEntity); }