2021-06-10 14:31:06 +02:00
|
|
|
|
2021-06-10 10:52:36 +02:00
|
|
|
package eu.dentlib.dhp.aggregation;
|
2021-06-10 14:31:06 +02:00
|
|
|
|
2021-06-10 10:52:36 +02:00
|
|
|
import static org.mockito.Mockito.lenient;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
|
import org.mockito.Mock;
|
2021-06-10 14:31:06 +02:00
|
|
|
|
|
|
|
import eu.dnetlib.dhp.oa.graph.raw.common.VocabularyGroup;
|
2021-06-10 10:52:36 +02:00
|
|
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
|
|
|
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
|
|
|
|
|
|
|
|
public abstract class AbstractVocabularyTest {
|
|
|
|
|
2021-06-10 14:31:06 +02:00
|
|
|
@Mock
|
|
|
|
protected ISLookUpService isLookUpService;
|
|
|
|
|
|
|
|
protected VocabularyGroup vocabularies;
|
|
|
|
|
|
|
|
public void setUpVocabulary() throws ISLookUpException, IOException {
|
|
|
|
lenient().when(isLookUpService.quickSearchProfile(VocabularyGroup.VOCABULARIES_XQUERY)).thenReturn(vocs());
|
|
|
|
|
|
|
|
lenient()
|
|
|
|
.when(isLookUpService.quickSearchProfile(VocabularyGroup.VOCABULARY_SYNONYMS_XQUERY))
|
|
|
|
.thenReturn(synonyms());
|
|
|
|
vocabularies = VocabularyGroup.loadVocsFromIS(isLookUpService);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static List<String> vocs() throws IOException {
|
|
|
|
return IOUtils
|
|
|
|
.readLines(
|
|
|
|
Objects
|
|
|
|
.requireNonNull(
|
|
|
|
AbstractVocabularyTest.class.getResourceAsStream("/eu/dnetlib/dhp/vocabulary/terms.txt")));
|
|
|
|
}
|
|
|
|
|
|
|
|
private static List<String> synonyms() throws IOException {
|
|
|
|
return IOUtils
|
|
|
|
.readLines(
|
|
|
|
Objects
|
|
|
|
.requireNonNull(
|
|
|
|
AbstractVocabularyTest.class.getResourceAsStream("/eu/dnetlib/dhp/vocabulary/synonyms.txt")));
|
|
|
|
}
|
2021-06-10 10:52:36 +02:00
|
|
|
|
|
|
|
}
|