@Test public void testTransform() throws Exception { CSVRecordInfo<CoLTaxonCsvField> record = mock(CSVRecordInfo.class); when(record.get(CoLTaxonCsvField.taxonID)).thenReturn("6931870"); when(record.get(CoLTaxonCsvField.identifier)).thenReturn( "urn:lsid:catalogueoflife.org:taxon:6703cbb5-e478-11e5-86e7-bc764e092680:col20150315"); when(record.get(CoLTaxonCsvField.datasetID)).thenReturn("67"); when(record.get(CoLTaxonCsvField.datasetName)) .thenReturn("ITIS Bees in Species 2000 & ITIS Catalogue of Life: 23rd March 2016"); when(record.get(CoLTaxonCsvField.acceptedNameUsageID)).thenReturn("6931870"); when(record.get(CoLTaxonCsvField.parentNameUsageID)).thenReturn("27000241"); when(record.get(CoLTaxonCsvField.taxonomicStatus)).thenReturn("accepted name"); when(record.get(CoLTaxonCsvField.taxonRank)).thenReturn("species"); when(record.get(CoLTaxonCsvField.verbatimTaxonRank)).thenReturn("test_verbatimTaxonRank"); when(record.get(CoLTaxonCsvField.scientificName)).thenReturn("Bombus affinis Cresson, 1863"); when(record.get(CoLTaxonCsvField.kingdom)).thenReturn("Animalia"); when(record.get(CoLTaxonCsvField.phylum)).thenReturn("Arthropoda"); when(record.get(CoLTaxonCsvField.classRank)).thenReturn("Insecta"); when(record.get(CoLTaxonCsvField.superfamily)).thenReturn("Apoidea"); when(record.get(CoLTaxonCsvField.genericName)).thenReturn("Bombus"); when(record.get(CoLTaxonCsvField.subgenus)).thenReturn("test_subgenus"); when(record.get(CoLTaxonCsvField.specificEpithet)).thenReturn("affinis"); when(record.get(CoLTaxonCsvField.infraspecificEpithet)).thenReturn(""); when(record.get(CoLTaxonCsvField.scientificNameAuthorship)).thenReturn("Cresson, 1863"); when(record.get(CoLTaxonCsvField.source)).thenReturn("test_source"); when(record.get(CoLTaxonCsvField.namePublishedIn)).thenReturn(""); when(record.get(CoLTaxonCsvField.nameAccordingTo)).thenReturn(""); when(record.get(CoLTaxonCsvField.modified)).thenReturn("30-Sep-2008"); when(record.get(CoLTaxonCsvField.description)).thenReturn("test_desc"); when(record.get(CoLTaxonCsvField.taxonConceptID)).thenReturn(""); when(record.get(CoLTaxonCsvField.scientificNameID)).thenReturn("ITS-714782"); when(record.get(CoLTaxonCsvField.references)).thenReturn( "http: when(record.get(CoLTaxonCsvField.isExtinct)).thenReturn("false"); ArrayList<CSVRecordInfo<CoLTaxonCsvField>> arrayList = new ArrayList<>(); arrayList.add(record); CoLSynonymBatchTransformer coLTaxonTransformer = new CoLSynonymBatchTransformer(); Object returned = ReflectionUtil.call(coLTaxonTransformer, "transform", new Class[] {ArrayList.class}, new Object[] {arrayList}); Collection<Taxon> updates = (Collection<Taxon>) returned; Taxon actual = updates.iterator().next(); String expectedId = "6931870@COL"; String expectedAuthorshipVerbatim = "Cresson, 1863"; String expectedScientificNameGroup = "bombus affinis"; String expectedFullScientificName = "Bombus affinis Cresson, 1863"; String expectedSourceSystemName = "Species 2000 - Catalogue Of Life"; String expectedSpcificEpithet = "affinis"; assertNotNull("01",actual); assertEquals("02",expectedId, actual.getId()); assertNotNull("03",actual.getRecordURI()); assertEquals("04",expectedAuthorshipVerbatim, actual.getValidName().getAuthorshipVerbatim()); assertEquals("05",expectedScientificNameGroup, actual.getValidName().getScientificNameGroup()); assertEquals("06",expectedFullScientificName, actual.getValidName().getFullScientificName()); assertEquals("07",expectedSourceSystemName, actual.getSourceSystem().getName()); assertEquals("08",expectedSpcificEpithet, actual.getDefaultClassification().getSpecificEpithet()); }
Collection<Taxon> transform(ArrayList<CSVRecordInfo<CoLTaxonCsvField>> records) { HashMap<String, Taxon> lookupTable = createLookupTable(records); for (CSVRecordInfo<CoLTaxonCsvField> record : records) { String id = record.get(acceptedNameUsageID); Taxon taxon = lookupTable.get(id); ScientificName synonym = createSynonym(record); if (taxon == null) { if (dry == false && testGenera == null) { ++numOrphans; logger.error("{} | Orphan: {} ", id, synonym.getFullScientificName()); } } else if (taxon.getSynonyms() == null) { ++numCreated; ++numUpdated; taxon.addSynonym(synonym); } else if (!hasSynonym(taxon, synonym)) { ++numCreated; taxon.addSynonym(synonym); } else { ++numDuplicates; logger.error("{} | Duplicate synonym: {}", id, synonym.getScientificNameGroup()); } } return lookupTable.values(); }
CoLSynonymBatchTransformer { Collection<Taxon> transform(ArrayList<CSVRecordInfo<CoLTaxonCsvField>> records) { HashMap<String, Taxon> lookupTable = createLookupTable(records); for (CSVRecordInfo<CoLTaxonCsvField> record : records) { String id = record.get(acceptedNameUsageID); Taxon taxon = lookupTable.get(id); ScientificName synonym = createSynonym(record); if (taxon == null) { if (dry == false && testGenera == null) { ++numOrphans; logger.error("{} | Orphan: {} ", id, synonym.getFullScientificName()); } } else if (taxon.getSynonyms() == null) { ++numCreated; ++numUpdated; taxon.addSynonym(synonym); } else if (!hasSynonym(taxon, synonym)) { ++numCreated; taxon.addSynonym(synonym); } else { ++numDuplicates; logger.error("{} | Duplicate synonym: {}", id, synonym.getScientificNameGroup()); } } return lookupTable.values(); } }
CoLSynonymBatchTransformer { Collection<Taxon> transform(ArrayList<CSVRecordInfo<CoLTaxonCsvField>> records) { HashMap<String, Taxon> lookupTable = createLookupTable(records); for (CSVRecordInfo<CoLTaxonCsvField> record : records) { String id = record.get(acceptedNameUsageID); Taxon taxon = lookupTable.get(id); ScientificName synonym = createSynonym(record); if (taxon == null) { if (dry == false && testGenera == null) { ++numOrphans; logger.error("{} | Orphan: {} ", id, synonym.getFullScientificName()); } } else if (taxon.getSynonyms() == null) { ++numCreated; ++numUpdated; taxon.addSynonym(synonym); } else if (!hasSynonym(taxon, synonym)) { ++numCreated; taxon.addSynonym(synonym); } else { ++numDuplicates; logger.error("{} | Duplicate synonym: {}", id, synonym.getScientificNameGroup()); } } return lookupTable.values(); } CoLSynonymBatchTransformer(); }
CoLSynonymBatchTransformer { Collection<Taxon> transform(ArrayList<CSVRecordInfo<CoLTaxonCsvField>> records) { HashMap<String, Taxon> lookupTable = createLookupTable(records); for (CSVRecordInfo<CoLTaxonCsvField> record : records) { String id = record.get(acceptedNameUsageID); Taxon taxon = lookupTable.get(id); ScientificName synonym = createSynonym(record); if (taxon == null) { if (dry == false && testGenera == null) { ++numOrphans; logger.error("{} | Orphan: {} ", id, synonym.getFullScientificName()); } } else if (taxon.getSynonyms() == null) { ++numCreated; ++numUpdated; taxon.addSynonym(synonym); } else if (!hasSynonym(taxon, synonym)) { ++numCreated; taxon.addSynonym(synonym); } else { ++numDuplicates; logger.error("{} | Duplicate synonym: {}", id, synonym.getScientificNameGroup()); } } return lookupTable.values(); } CoLSynonymBatchTransformer();  }
CoLSynonymBatchTransformer { Collection<Taxon> transform(ArrayList<CSVRecordInfo<CoLTaxonCsvField>> records) { HashMap<String, Taxon> lookupTable = createLookupTable(records); for (CSVRecordInfo<CoLTaxonCsvField> record : records) { String id = record.get(acceptedNameUsageID); Taxon taxon = lookupTable.get(id); ScientificName synonym = createSynonym(record); if (taxon == null) { if (dry == false && testGenera == null) { ++numOrphans; logger.error("{} | Orphan: {} ", id, synonym.getFullScientificName()); } } else if (taxon.getSynonyms() == null) { ++numCreated; ++numUpdated; taxon.addSynonym(synonym); } else if (!hasSynonym(taxon, synonym)) { ++numCreated; taxon.addSynonym(synonym); } else { ++numDuplicates; logger.error("{} | Duplicate synonym: {}", id, synonym.getScientificNameGroup()); } } return lookupTable.values(); } CoLSynonymBatchTransformer();   }