Search in sources :

Example 16 with NullImportLogger

use of org.eol.globi.tool.NullImportLogger in project eol-globi-data by jhpoelen.

the class TaxonNameEnricherTest method detectHigherOrderTaxa.

@Test
public void detectHigherOrderTaxa() throws StudyImporterException {
    List<String> msgs = new ArrayList<>();
    List<Map<String, String>> received = new ArrayList<>();
    final InteractionListener listener = new TaxonNameEnricher(interaction -> received.add(interaction), new NullImportLogger() {

        @Override
        public void info(LogContext ctx, String message) {
            msgs.add(message);
        }

        @Override
        public void warn(LogContext ctx, String message) {
            msgs.add(message);
        }

        @Override
        public void severe(LogContext ctx, String message) {
            msgs.add(message);
        }
    });
    final TreeMap<String, String> link = new TreeMap<>();
    link.put(SOURCE_TAXON_SPECIES, "Donald duck");
    link.put(DatasetImporterForTSV.INTERACTION_TYPE_ID, InteractType.ATE.getIRI());
    link.put(DATASET_CITATION, "some source ref");
    link.put(REFERENCE_ID, "123");
    link.put(REFERENCE_CITATION, "");
    listener.on(link);
    assertThat(received.size(), is(1));
    Map<String, String> receivedInteraction = received.get(0);
    assertThat(receivedInteraction.get(SOURCE_TAXON_NAME), is("Donald duck"));
}
Also used : NullImportLogger(org.eol.globi.tool.NullImportLogger) ArrayList(java.util.ArrayList) LogContext(org.eol.globi.domain.LogContext) TreeMap(java.util.TreeMap) Map(java.util.Map) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Aggregations

NullImportLogger (org.eol.globi.tool.NullImportLogger)16 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)13 Map (java.util.Map)11 LogContext (org.eol.globi.domain.LogContext)11 TreeMap (java.util.TreeMap)8 HashMap (java.util.HashMap)6 InteractType (org.eol.globi.domain.InteractType)6 IOException (java.io.IOException)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 DatasetImpl (org.globalbioticinteractions.dataset.DatasetImpl)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 StudyImporterException (org.eol.globi.data.StudyImporterException)3 LatLng (org.eol.globi.geo.LatLng)3 InteractionListener (org.eol.globi.process.InteractionListener)3 GeoNamesService (org.eol.globi.service.GeoNamesService)3 InteractTypeMapper (org.eol.globi.util.InteractTypeMapper)3 File (java.io.File)2 URI (java.net.URI)2