use of org.eol.globi.data.DatasetImporterForTSV.RESOURCE_TYPES in project eol-globi-data by jhpoelen.
the class DatasetImporterForDwCATest method importTaxonDescriptionsFromDir.
@Test
public void importTaxonDescriptionsFromDir() throws StudyImporterException, URISyntaxException {
URL resource = getClass().getResource("/org/globalbioticinteractions/dataset/coetzer/meta.xml");
URI archiveRoot = new File(resource.toURI()).getParentFile().toURI();
List<Map<String, String>> links = new ArrayList<>();
DatasetImporterForDwCA studyImporterForDwCA = new DatasetImporterForDwCA(null, null);
studyImporterForDwCA.setDataset(new DatasetImpl("some/namespace", archiveRoot, inStream -> inStream));
studyImporterForDwCA.setInteractionListener(new InteractionListener() {
@Override
public void on(Map<String, String> interaction) throws StudyImporterException {
links.add(interaction);
}
});
studyImporterForDwCA.importStudy();
assertThat(links.size() > 0, is(true));
assertThat(links.get(0).get(DATASET_CITATION), containsString("org/globalbioticinteractions/dataset/coetzer/"));
assertThat(links.get(0).get(REFERENCE_CITATION), is("Cockerell, T.D.A. 1937. African bees of the genera Ceratina, Halictus and Megachile. 254 pp. William Clowes and Sons, London"));
assertThat(links.get(0).get(TARGET_TAXON_NAME), is("Chaetodactylus leleupi"));
assertThat(links.get(0).get(SOURCE_TAXON_NAME), is("Ceratina ruwenzorica Cockerell, 1937"));
assertThat(links.get(0).get(INTERACTION_TYPE_NAME), is("Parasite"));
assertThat(links.get(0).get(RESOURCE_TYPES), is("http://rs.gbif.org/terms/1.0/Reference"));
}
use of org.eol.globi.data.DatasetImporterForTSV.RESOURCE_TYPES in project eol-globi-data by jhpoelen.
the class DatasetImporterForDwCATest method assertImportsSomethingOfType.
private void assertImportsSomethingOfType(URI archiveRoot, AtomicInteger recordCounter, String defaultResourceType, String... expectedProperties) throws StudyImporterException {
final Set<String> resourceTypes = new TreeSet<>();
DatasetImporterForDwCA studyImporterForDwCA = new DatasetImporterForDwCA(null, null);
studyImporterForDwCA.setDataset(new DatasetImpl("some/namespace", archiveRoot, inStream -> inStream));
studyImporterForDwCA.setInteractionListener(new InteractionListener() {
@Override
public void on(Map<String, String> interaction) throws StudyImporterException {
for (String expectedProperty : expectedProperties) {
assertThat("no [" + expectedProperty + "] found in " + interaction, interaction.containsKey(expectedProperty), is(true));
assertThat("no value of [" + expectedProperty + "] found in " + interaction, interaction.get(expectedProperty), is(notNullValue()));
}
assertThat(interaction.get(RESOURCE_TYPES), is(notNullValue()));
String[] types = splitByPipes(interaction.get(RESOURCE_TYPES));
resourceTypes.addAll(Arrays.asList(types));
recordCounter.incrementAndGet();
}
});
studyImporterForDwCA.importStudy();
assertThat(recordCounter.get(), greaterThan(0));
String[] items = splitByPipes(defaultResourceType);
assertThat(resourceTypes, containsInAnyOrder(items));
assertThat(recordCounter.get(), greaterThan(0));
}
Aggregations