From e85333fd7f2e7aae8bd1aac7c30943656724f58c Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Tue, 10 Dec 2024 10:23:53 +0100 Subject: [PATCH] test --- .../directindex/clients/CommunityClient.java | 8 ++++ .../clients/CommunityClientTest.java | 46 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/test/java/eu/dnetlib/app/directindex/clients/CommunityClientTest.java diff --git a/src/main/java/eu/dnetlib/app/directindex/clients/CommunityClient.java b/src/main/java/eu/dnetlib/app/directindex/clients/CommunityClient.java index b2445d6..663e1e0 100644 --- a/src/main/java/eu/dnetlib/app/directindex/clients/CommunityClient.java +++ b/src/main/java/eu/dnetlib/app/directindex/clients/CommunityClient.java @@ -229,4 +229,12 @@ public class CommunityClient implements HasCache { } + public String getCommunityApiUrl() { + return communityApiUrl; + } + + public void setCommunityApiUrl(final String communityApiUrl) { + this.communityApiUrl = communityApiUrl; + } + } diff --git a/src/test/java/eu/dnetlib/app/directindex/clients/CommunityClientTest.java b/src/test/java/eu/dnetlib/app/directindex/clients/CommunityClientTest.java new file mode 100644 index 0000000..7caf53c --- /dev/null +++ b/src/test/java/eu/dnetlib/app/directindex/clients/CommunityClientTest.java @@ -0,0 +1,46 @@ +package eu.dnetlib.app.directindex.clients; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Arrays; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import eu.dnetlib.app.directindex.clients.CommunityClient.ContextInfo; + +@Disabled +class CommunityClientTest { + + // Class Under test + private CommunityClient communityClient; + + private static final String COMMUNITY_URL = "https://services.openaire.eu/openaire/community"; + + @BeforeEach + public void initEach() { + communityClient = new CommunityClient(); + communityClient.setCommunityApiUrl(COMMUNITY_URL); + } + + @Test + public void testFindContexts() { + final Map ctx = communityClient.findContexts(Arrays.asList("sobigdata", "clarin::subcommunity::3", "clarin::subcommunity::4")); + + assertEquals(5, ctx.size()); + + assertTrue(StringUtils.isNotBlank(ctx.get("clarin").getLabel())); + assertTrue(StringUtils.isNotBlank(ctx.get("clarin").getType())); + assertTrue(StringUtils.isNotBlank(ctx.get("clarin::subcommunity").getLabel())); + assertTrue(StringUtils.isNotBlank(ctx.get("clarin::subcommunity::3").getLabel())); + assertTrue(StringUtils.isNotBlank(ctx.get("clarin::subcommunity::4").getLabel())); + + assertTrue(StringUtils.isNotBlank(ctx.get("sobigdata").getLabel())); + assertTrue(StringUtils.isNotBlank(ctx.get("sobigdata").getType())); + } + +}