use of org.eol.globi.tool.NullImportLogger in project eol-globi-data by jhpoelen.
the class InteractionImporterTest method malformedDateRange.
@Test
public void malformedDateRange() {
final List<String> msgs = new ArrayList<>();
InteractionListener interactionListener = new InteractionImporter(nodeFactory, new GeoNamesService() {
@Override
public boolean hasTermForLocale(String locality) {
return true;
}
@Override
public LatLng findLatLng(String locality) throws IOException {
throw new IOException("kaboom!");
}
}, new NullImportLogger() {
@Override
public void warn(LogContext ctx, String message) {
msgs.add(message);
}
});
final TreeMap<String, String> link = new TreeMap<>();
link.put(SOURCE_TAXON_NAME, "donald");
link.put(DatasetImporterForTSV.INTERACTION_TYPE_ID, "http://purl.obolibrary.org/obo/RO_0002470");
link.put(TARGET_TAXON_NAME, "mini");
link.put(REFERENCE_ID, "123");
link.put(DATASET_CITATION, "some source ref");
link.put(REFERENCE_CITATION, "");
link.put(REFERENCE_DOI, "10.12/123");
link.put(DatasetImporterForMetaTable.EVENT_DATE, "2009-09/2003-09");
try {
interactionListener.on(link);
assertThat(msgs.size(), is(2));
assertThat(msgs.get(0), startsWith("issue handling date range [2009-09/2003-09]: The end instant must be greater than the start instant"));
assertThat(msgs.get(1), startsWith("issue handling date range [2009-09/2003-09]: The end instant must be greater than the start instant"));
} catch (StudyImporterException ex) {
fail("should not throw on failing geoname lookup");
}
}
use of org.eol.globi.tool.NullImportLogger in project eol-globi-data by jhpoelen.
the class InteractionImporterTest method throwingGeoNamesService.
@Test
public void throwingGeoNamesService() {
final List<String> msgs = new ArrayList<>();
InteractionListener interactionListener = new InteractionImporter(nodeFactory, new GeoNamesService() {
@Override
public boolean hasTermForLocale(String locality) {
return true;
}
@Override
public LatLng findLatLng(String locality) throws IOException {
throw new IOException("kaboom!");
}
}, new NullImportLogger() {
@Override
public void warn(LogContext ctx, String message) {
msgs.add(message);
}
});
final TreeMap<String, String> link = new TreeMap<>();
link.put(SOURCE_TAXON_NAME, "donald");
link.put(DatasetImporterForTSV.INTERACTION_TYPE_ID, "http://purl.obolibrary.org/obo/RO_0002470");
link.put(TARGET_TAXON_NAME, "mini");
link.put(LOCALITY_ID, "bla:123");
link.put(LOCALITY_NAME, "my back yard");
link.put(REFERENCE_ID, "123");
link.put(DATASET_CITATION, "some source ref");
link.put(REFERENCE_CITATION, "");
try {
interactionListener.on(link);
assertThat(msgs.size(), is(1));
assertThat(msgs.get(0), startsWith("failed to lookup [bla:123]"));
} catch (StudyImporterException ex) {
fail("should not throw on failing geoname lookup");
}
}
use of org.eol.globi.tool.NullImportLogger in project eol-globi-data by jhpoelen.
the class DatasetImporterForPlanqueIT method importAll.
@Test
public void importAll() throws StudyImporterException, IOException {
final List<String> errorMessages = new ArrayList<String>();
BaseDatasetImporter importer = new DatasetImporterForPlanque(new ParserFactoryLocal(), nodeFactory);
JsonNode config = new ObjectMapper().readTree("{ \"citation\": \"Benjamin Planque, Raul Primicerio, Kathrine Michalsen, Michaela Aschan, Grégoire Certain, Padmini Dalpadado, Harald Gjøsæater, Cecilie Hansen, Edda Johannesen, Lis Lindal Jørgensen, Ina Kolsum, Susanne Kortsch, Lise-Marie Leclerc, Lena Omli, Mette Skern-Mauritzen, and Magnus Wiedmann 2014. Who eats whom in the Barents Sea: a food web topology from plankton to whales. Ecology 95:1430–1430. https://doi.org/10.1890/13-1062.1\",\n" + " \"doi\": \"https://doi.org/10.1890/13-1062.1\",\n" + " \"format\": \"planque\",\n" + " \"resources\": {\n" + " \"links\": \"http://www.esapubs.org/archive/ecol/E095/124/revised/PairwiseList.txt\",\n" + " \"references\": \"http://www.esapubs.org/archive/ecol/E095/124/revised/References.txt\",\n" + " \"referencesForLinks\": \"http://www.esapubs.org/archive/ecol/E095/124/revised/PairWise2References.txt\"\n" + " }\n" + "}");
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"), inStream -> inStream);
dataset.setConfig(config);
importer.setDataset(dataset);
importer.setLogger(new NullImportLogger() {
@Override
public void warn(LogContext ctx, String message) {
errorMessages.add(message);
}
});
importStudy(importer);
int interactionCount = 0;
List<StudyNode> studies = NodeUtil.findAllStudies(getGraphDb());
for (StudyNode study : studies) {
interactionCount += getSpecimenCount(study);
}
assertThat(interactionCount, is(4900));
int uniqueReference = 236;
// note that the +1 is for all links that had no reference associated to it
assertThat(studies.size(), is(uniqueReference + 1));
assertThat(taxonIndex.findTaxonByName("Trisopterus esmarkii"), is(notNullValue()));
assertThat(errorMessages.size(), is(0));
}
use of org.eol.globi.tool.NullImportLogger in project eol-globi-data by jhpoelen.
the class DatasetImporterForMangalIT method importAll.
@Test
public void importAll() throws StudyImporterException {
AtomicInteger counter = new AtomicInteger(0);
DatasetImporterForMangal importer = new DatasetImporterForMangal(null, null);
importer.setDataset(new DatasetLocal(inStream -> inStream));
importer.setInteractionListener(new InteractionValidator(new InteractionListener() {
@Override
public void on(Map<String, String> interaction) throws StudyImporterException {
counter.incrementAndGet();
}
}, new NullImportLogger() {
@Override
public void warn(LogContext ctx, String message) {
fail("unexpected warning: [" + message + "]");
}
}));
importer.importStudy();
assertThat(counter.get() > 0, Is.is(true));
}
use of org.eol.globi.tool.NullImportLogger in project eol-globi-data by jhpoelen.
the class DatasetImporterForBatBaseIT method importAll.
@Test
public void importAll() throws StudyImporterException {
AtomicInteger counter = new AtomicInteger(0);
DatasetImporterForBatBase importer = new DatasetImporterForBatBase(null, null);
DatasetImpl dataset = new DatasetImpl("test/batplant", URI.create("classpath:/org/eol/globi/data/batplant/"), is -> is);
importer.setDataset(dataset);
importer.setInteractionListener(new InteractionValidator(new InteractionListener() {
@Override
public void on(Map<String, String> interaction) throws StudyImporterException {
counter.incrementAndGet();
}
}, new NullImportLogger() {
@Override
public void warn(LogContext ctx, String message) {
fail("unexpected warning: [" + message + "]");
}
}));
importer.importStudy();
assertThat(counter.get() > 0, Is.is(true));
}
Aggregations