test
This commit is contained in:
parent
db7fa53ecd
commit
348aa41058
18
.classpath
18
.classpath
|
@ -6,27 +6,27 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</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">
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</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">
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="test" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</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>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -188,7 +188,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.solr</groupId>
|
<groupId>org.apache.solr</groupId>
|
||||||
<artifactId>solr-solrj</artifactId>
|
<artifactId>solr-solrj</artifactId>
|
||||||
<version>9.7.0</version>
|
<version>9.7.0</version><!--$NO-MVN-MAN-VER$-->
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Swagger -->
|
<!-- Swagger -->
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class VocabularyClient implements HasCache {
|
||||||
|
|
||||||
public String findTermLabel(final String vocabulary, final String code) {
|
public String findTermLabel(final String vocabulary, final String code) {
|
||||||
try {
|
try {
|
||||||
final String label = findVocabulary("dnet:pid_types").get(code);
|
final String label = findVocabulary(vocabulary).get(code);
|
||||||
return StringUtils.firstNonBlank(label, code);
|
return StringUtils.firstNonBlank(label, code);
|
||||||
} catch (final DirectIndexApiException e) {
|
} catch (final DirectIndexApiException e) {
|
||||||
log.warn("Problem accessing vocabulary: " + vocabulary, 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ import static org.mockito.Mockito.verify;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.mockito.Mock;
|
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.schema.solr.SolrRecord;
|
||||||
import eu.dnetlib.dhp.solr.mapping.SolrInputDocumentMapper;
|
import eu.dnetlib.dhp.solr.mapping.SolrInputDocumentMapper;
|
||||||
|
|
||||||
|
@Disabled
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
class SolrRecordMapperTest {
|
class SolrRecordMapperTest {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue