This commit is contained in:
Michele Artini 2024-12-10 10:23:53 +01:00
parent 9b286697c2
commit e85333fd7f
2 changed files with 54 additions and 0 deletions

View File

@ -229,4 +229,12 @@ public class CommunityClient implements HasCache {
} }
public String getCommunityApiUrl() {
return communityApiUrl;
}
public void setCommunityApiUrl(final String communityApiUrl) {
this.communityApiUrl = communityApiUrl;
}
} }

View File

@ -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<String, ContextInfo> 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()));
}
}