This commit is contained in:
Michele Artini 2024-12-10 09:35:14 +01:00
parent db7fa53ecd
commit 348aa41058
5 changed files with 69 additions and 11 deletions

View File

@ -6,27 +6,27 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>

View File

@ -188,7 +188,7 @@
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>9.7.0</version>
<version>9.7.0</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<!-- Swagger -->

View File

@ -45,7 +45,7 @@ public class VocabularyClient implements HasCache {
public String findTermLabel(final String vocabulary, final String code) {
try {
final String label = findVocabulary("dnet:pid_types").get(code);
final String label = findVocabulary(vocabulary).get(code);
return StringUtils.firstNonBlank(label, code);
} catch (final DirectIndexApiException e) {
log.warn("Problem accessing vocabulary: " + vocabulary, e);
@ -159,4 +159,12 @@ public class VocabularyClient implements HasCache {
}
}
public String getVocApiUrl() {
return vocApiUrl;
}
public void setVocApiUrl(final String vocApiUrl) {
this.vocApiUrl = vocApiUrl;
}
}

View File

@ -0,0 +1,48 @@
package eu.dnetlib.app.directindex.clients;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import eu.dnetlib.app.directindex.errors.DirectIndexApiException;
@Disabled
class VocabularyClientTest {
// Class Under test
private VocabularyClient vocabularyClient;
private static final String VOCABULARY_URL = "https://services.openaire.eu/provision/mvc/vocabularies";
@BeforeEach
public void initEach() throws DirectIndexApiException {
vocabularyClient = new VocabularyClient();
vocabularyClient.setVocApiUrl(VOCABULARY_URL);
}
@Test
void testFindVocabulary() throws DirectIndexApiException {
assertFalse(vocabularyClient.findVocabulary("dnet:countries").isEmpty());
assertFalse(vocabularyClient.findVocabulary("dnet:languages").isEmpty());
assertFalse(vocabularyClient.findVocabulary("dnet:access_modes").isEmpty());
assertFalse(vocabularyClient.findVocabulary("dnet:publication_resource").isEmpty());
assertThrows(DirectIndexApiException.class, () -> vocabularyClient.findVocabulary("INVALID_VOC"));
}
@Test
void testFindTermLabel() {
assertEquals("Italy", vocabularyClient.findTermLabel("dnet:countries", "IT"));
assertEquals("English", vocabularyClient.findTermLabel("dnet:languages", "eng"));
assertEquals("Open Access", vocabularyClient.findTermLabel("dnet:access_modes", "OPEN"));
assertEquals("Article", vocabularyClient.findTermLabel("dnet:publication_resource", "0001"));
assertEquals("test", vocabularyClient.findTermLabel("INVALID_VOC", "test"));
assertEquals("test-lang", vocabularyClient.findTermLabel("dnet:languages", "test-lang"));
}
}

View File

@ -10,6 +10,7 @@ import static org.mockito.Mockito.verify;
import org.apache.commons.lang3.StringUtils;
import org.apache.solr.common.SolrInputDocument;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
@ -28,6 +29,7 @@ import eu.dnetlib.app.directindex.input.ResultEntry;
import eu.dnetlib.dhp.schema.solr.SolrRecord;
import eu.dnetlib.dhp.solr.mapping.SolrInputDocumentMapper;
@Disabled
@ExtendWith(MockitoExtension.class)
class SolrRecordMapperTest {