Search in sources :

Example 51 with InteractionListener

use of org.eol.globi.process.InteractionListener in project eol-globi-data by jhpoelen.

the class InteractionListenerIndexingTest method indexOnSourceOccurrenceIdTargetOccurrenceIdPairs.

@Test
public void indexOnSourceOccurrenceIdTargetOccurrenceIdPairs() throws StudyImporterException {
    TreeMap<Pair<String, String>, Map<String, String>> interactionsWithUnresolvedOccurrenceIds = new TreeMap<>();
    interactionsWithUnresolvedOccurrenceIds.put(Pair.of(DatasetImporterForTSV.SOURCE_OCCURRENCE_ID, "source123"), Collections.emptyMap());
    InteractionListener listener = new InteractionListenerIndexing(interactionsWithUnresolvedOccurrenceIds);
    listener.on(new TreeMap<String, String>() {

        {
            put(DatasetImporterForTSV.TARGET_OCCURRENCE_ID, "target123");
            put(DatasetImporterForTSV.SOURCE_OCCURRENCE_ID, "source123");
            put(TaxonUtil.SOURCE_TAXON_NAME, "sourceName123");
        }
    });
    assertThat(interactionsWithUnresolvedOccurrenceIds.size(), Is.is(1));
    Map<String, String> props = interactionsWithUnresolvedOccurrenceIds.get(Pair.of(DatasetImporterForTSV.SOURCE_OCCURRENCE_ID, "source123"));
    assertThat(props.get(DatasetImporterForTSV.SOURCE_OCCURRENCE_ID), Is.is("source123"));
    assertThat(props.get(TaxonUtil.SOURCE_TAXON_NAME), Is.is("sourceName123"));
}
Also used : InteractionListener(org.eol.globi.process.InteractionListener) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map) Pair(org.apache.commons.lang3.tuple.Pair) Test(org.junit.Test)

Example 52 with InteractionListener

use of org.eol.globi.process.InteractionListener in project eol-globi-data by jhpoelen.

the class InteractionListenerIndexingTest method indexOnSourceOcccurenceIdTargetCatalogNumberIdPairs.

@Test
public void indexOnSourceOcccurenceIdTargetCatalogNumberIdPairs() throws StudyImporterException {
    TreeMap<Pair<String, String>, Map<String, String>> interactionsWithUnresolvedOccurrenceIds = new TreeMap<>();
    String targetOccurrenceId = "United States National Parasite Collection 81321";
    interactionsWithUnresolvedOccurrenceIds.put(Pair.of(DatasetImporterForTSV.SOURCE_OCCURRENCE_ID, targetOccurrenceId), Collections.emptyMap());
    InteractionListener listener = new InteractionListenerIndexing(interactionsWithUnresolvedOccurrenceIds);
    listener.on(new TreeMap<String, String>() {

        {
            put(DatasetImporterForTSV.TARGET_OCCURRENCE_ID, "http://n2t.net/ark:/65665/3326e7c2d-d8fa-4e5d-b01f-20d6f4150356");
            put(DatasetImporterForTSV.TARGET_CATALOG_NUMBER, "USNPC # 081321");
            put(TaxonUtil.TARGET_TAXON_NAME, "sourceName123");
        }
    });
    assertThat(interactionsWithUnresolvedOccurrenceIds.size(), Is.is(1));
    Map<String, String> props = interactionsWithUnresolvedOccurrenceIds.get(Pair.of(DatasetImporterForTSV.SOURCE_OCCURRENCE_ID, targetOccurrenceId));
    assertNotNull(props);
    assertThat(props.get(DatasetImporterForTSV.SOURCE_OCCURRENCE_ID), Is.is("http://n2t.net/ark:/65665/3326e7c2d-d8fa-4e5d-b01f-20d6f4150356"));
    assertThat(props.get(DatasetImporterForTSV.SOURCE_CATALOG_NUMBER), Is.is("USNPC # 081321"));
    assertThat(props.get(TaxonUtil.SOURCE_TAXON_NAME), Is.is("sourceName123"));
}
Also used : InteractionListener(org.eol.globi.process.InteractionListener) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map) Pair(org.apache.commons.lang3.tuple.Pair) Test(org.junit.Test)

Example 53 with InteractionListener

use of org.eol.globi.process.InteractionListener in project eol-globi-data by jhpoelen.

the class InteractionListenerIndexingTest method indexOnSourceOccurrenceIdTargetOccurrenceIdPairs3.

@Test
public void indexOnSourceOccurrenceIdTargetOccurrenceIdPairs3() throws StudyImporterException {
    TreeMap<Pair<String, String>, Map<String, String>> interactionsWithUnresolvedOccurrenceIds = new TreeMap<>();
    interactionsWithUnresolvedOccurrenceIds.put(Pair.of(DatasetImporterForTSV.SOURCE_OCCURRENCE_ID, "occurrence123"), Collections.emptyMap());
    InteractionListener listener = new InteractionListenerIndexing(interactionsWithUnresolvedOccurrenceIds);
    listener.on(new TreeMap<String, String>() {

        {
            put(DatasetImporterForTSV.TARGET_OCCURRENCE_ID, "occurrence123");
            put(TaxonUtil.TARGET_TAXON_NAME, "occurrenceName123");
            put(DatasetImporterForTSV.SOURCE_OCCURRENCE_ID, "occurrence456");
        }
    });
    assertThat(interactionsWithUnresolvedOccurrenceIds.size(), Is.is(1));
    Map<String, String> props = interactionsWithUnresolvedOccurrenceIds.get(Pair.of(DatasetImporterForTSV.SOURCE_OCCURRENCE_ID, "occurrence123"));
    assertThat(props.get(TaxonUtil.SOURCE_TAXON_NAME), Is.is("occurrenceName123"));
    assertThat(props.get(DatasetImporterForTSV.SOURCE_OCCURRENCE_ID), Is.is("occurrence123"));
}
Also used : InteractionListener(org.eol.globi.process.InteractionListener) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map) Pair(org.apache.commons.lang3.tuple.Pair) Test(org.junit.Test)

Example 54 with InteractionListener

use of org.eol.globi.process.InteractionListener in project eol-globi-data by jhpoelen.

the class InteractionListenerIndexingTest method indexOnSourceOccurrenceIdTargetOccurrenceIdPairs2.

@Test
public void indexOnSourceOccurrenceIdTargetOccurrenceIdPairs2() throws StudyImporterException {
    TreeMap<Pair<String, String>, Map<String, String>> interactionsWithUnresolvedOccurrenceIds = new TreeMap<>();
    interactionsWithUnresolvedOccurrenceIds.put(Pair.of(DatasetImporterForTSV.TARGET_OCCURRENCE_ID, "target123"), Collections.emptyMap());
    InteractionListener listener = new InteractionListenerIndexing(interactionsWithUnresolvedOccurrenceIds);
    listener.on(new TreeMap<String, String>() {

        {
            put(DatasetImporterForTSV.TARGET_OCCURRENCE_ID, "target123");
            put(TaxonUtil.TARGET_TAXON_NAME, "targetName123");
        }
    });
    assertThat(interactionsWithUnresolvedOccurrenceIds.size(), Is.is(1));
    Map<String, String> props = interactionsWithUnresolvedOccurrenceIds.get(Pair.of(DatasetImporterForTSV.TARGET_OCCURRENCE_ID, "target123"));
    assertThat(props.get(DatasetImporterForTSV.TARGET_OCCURRENCE_ID), Is.is("target123"));
    assertThat(props.get(TaxonUtil.TARGET_TAXON_NAME), Is.is("targetName123"));
}
Also used : InteractionListener(org.eol.globi.process.InteractionListener) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map) Pair(org.apache.commons.lang3.tuple.Pair) Test(org.junit.Test)

Example 55 with InteractionListener

use of org.eol.globi.process.InteractionListener in project eol-globi-data by jhpoelen.

the class InteractionListenerIndexingTest method indexOnTargetOcccurenceIdSourceCatalogNumberIdPairs.

@Test
public void indexOnTargetOcccurenceIdSourceCatalogNumberIdPairs() throws StudyImporterException {
    TreeMap<Pair<String, String>, Map<String, String>> interactionsWithUnresolvedOccurrenceIds = new TreeMap<>();
    String targetOccurrenceId = "United States National Parasite Collection 81321";
    interactionsWithUnresolvedOccurrenceIds.put(Pair.of(DatasetImporterForTSV.TARGET_OCCURRENCE_ID, targetOccurrenceId), Collections.emptyMap());
    InteractionListener listener = new InteractionListenerIndexing(interactionsWithUnresolvedOccurrenceIds);
    listener.on(new TreeMap<String, String>() {

        {
            put(DatasetImporterForTSV.SOURCE_OCCURRENCE_ID, "http://n2t.net/ark:/65665/3326e7c2d-d8fa-4e5d-b01f-20d6f4150356");
            put(DatasetImporterForTSV.SOURCE_CATALOG_NUMBER, "USNPC # 081321");
            put(TaxonUtil.SOURCE_TAXON_NAME, "sourceName123");
        }
    });
    assertThat(interactionsWithUnresolvedOccurrenceIds.size(), Is.is(1));
    Map<String, String> props = interactionsWithUnresolvedOccurrenceIds.get(Pair.of(DatasetImporterForTSV.TARGET_OCCURRENCE_ID, targetOccurrenceId));
    assertNotNull(props);
    assertThat(props.get(DatasetImporterForTSV.TARGET_OCCURRENCE_ID), Is.is("http://n2t.net/ark:/65665/3326e7c2d-d8fa-4e5d-b01f-20d6f4150356"));
    assertThat(props.get(DatasetImporterForTSV.TARGET_CATALOG_NUMBER), Is.is("USNPC # 081321"));
    assertThat(props.get(TaxonUtil.TARGET_TAXON_NAME), Is.is("sourceName123"));
}
Also used : InteractionListener(org.eol.globi.process.InteractionListener) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map) Pair(org.apache.commons.lang3.tuple.Pair) Test(org.junit.Test)

Aggregations

InteractionListener (org.eol.globi.process.InteractionListener)58 Test (org.junit.Test)51 Map (java.util.Map)46 ArrayList (java.util.ArrayList)36 TreeMap (java.util.TreeMap)26 URI (java.net.URI)24 IOException (java.io.IOException)22 JsonNode (com.fasterxml.jackson.databind.JsonNode)20 DatasetImpl (org.globalbioticinteractions.dataset.DatasetImpl)20 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)19 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)16 URL (java.net.URL)15 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)14 InputStream (java.io.InputStream)13 List (java.util.List)13 TaxonUtil (org.eol.globi.service.TaxonUtil)13 Archive (org.gbif.dwc.Archive)13 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)13 HashMap (java.util.HashMap)11 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)10