From e8ee889a3974c695a9e33f1d8ff10c87910b3440 Mon Sep 17 00:00:00 2001 From: Sam Leeflang Date: Tue, 19 Nov 2024 14:44:18 +0100 Subject: [PATCH] Code review --- .../eu/dissco/core/translator/terms/utils/AgentsUtils.java | 6 +++--- .../translator/terms/utils/EntityRelationshipUtilsTest.java | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/dissco/core/translator/terms/utils/AgentsUtils.java b/src/main/java/eu/dissco/core/translator/terms/utils/AgentsUtils.java index b89e42e..44b6081 100644 --- a/src/main/java/eu/dissco/core/translator/terms/utils/AgentsUtils.java +++ b/src/main/java/eu/dissco/core/translator/terms/utils/AgentsUtils.java @@ -65,11 +65,11 @@ private static void handleMultipleAgents( List agents, String agentValue, String agentId, AgentRoleType role, Type type) { var ids = new String[0]; var agentValues = new String[0]; - if (checkIfNeedsParsing(agentValue)) { + if (needsParsing(agentValue)) { agentValues = Arrays.stream(agentValue.split("[&|]")).map(String::trim) .toArray(String[]::new); } - if (checkIfNeedsParsing(agentId)) { + if (needsParsing(agentId)) { ids = Arrays.stream(agentId.split("[&|]")).map(String::trim).toArray(String[]::new); } if (agentValues.length == ids.length) { @@ -97,7 +97,7 @@ private static void handleMultipleAgents( } } - private static boolean checkIfNeedsParsing(String value) { + private static boolean needsParsing(String value) { return value != null && (value.contains("&") || value.contains("|")); } } diff --git a/src/test/java/eu/dissco/core/translator/terms/utils/EntityRelationshipUtilsTest.java b/src/test/java/eu/dissco/core/translator/terms/utils/EntityRelationshipUtilsTest.java index a270e1a..c5a2c59 100644 --- a/src/test/java/eu/dissco/core/translator/terms/utils/EntityRelationshipUtilsTest.java +++ b/src/test/java/eu/dissco/core/translator/terms/utils/EntityRelationshipUtilsTest.java @@ -4,6 +4,7 @@ import static eu.dissco.core.translator.domain.RelationshipType.HAS_FDO_TYPE; import static eu.dissco.core.translator.domain.RelationshipType.HAS_ORGANISATION_ID; import static eu.dissco.core.translator.schema.Agent.Type.SCHEMA_SOFTWARE_APPLICATION; +import static eu.dissco.core.translator.terms.utils.AgentsUtils.addAgent; import static org.assertj.core.api.Assertions.assertThat; import eu.dissco.core.translator.domain.RelationshipType; @@ -73,7 +74,7 @@ private EntityRelationship createEntityRelationship(RelationshipType relationshi .withDwcRelatedResourceID(relatedResource) .withOdsRelatedResourceURI(relatedResourceURI) .withDwcRelationshipEstablishedDate(Date.from(Instant.now())) - .withOdsHasAgents(AgentsUtils.addAgent(List.of(), APP_NAME, APP_PID, + .withOdsHasAgents(addAgent(List.of(), APP_NAME, APP_PID, DATA_TRANSLATOR, SCHEMA_SOFTWARE_APPLICATION)); }