@Test public void testCreateSynonym() 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(""); 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"); Object returned = ReflectionUtil.callStatic(CoLSynonymBatchTransformer.class, "createSynonym", new Class[] {CSVRecordInfo.class}, new Object[] {record}); ScientificName actual = (ScientificName) returned; String expectedGenus = "Bombus"; String expectedScientificNameGroup = "bombus affinis "; String expectedFullScientificName = "Bombus affinis Cresson, 1863"; assertNotNull("01",actual); assertEquals("02",expectedFullScientificName, actual.getFullScientificName()); assertEquals("03",expectedScientificNameGroup, actual.getScientificNameGroup()); assertEquals("04",expectedGenus, actual.getGenusOrMonomial()); }
private static ScientificName createSynonym(CSVRecordInfo<CoLTaxonCsvField> record) { ScientificName sn = new ScientificName(); sn.setFullScientificName(record.get(scientificName)); sn.setGenusOrMonomial(record.get(genericName)); sn.setSpecificEpithet(record.get(specificEpithet)); sn.setInfraspecificEpithet(record.get(infraspecificEpithet)); sn.setAuthorshipVerbatim(record.get(scientificNameAuthorship)); TaxonomicStatus status = null; try { status = statusNormalizer.map(record.get(taxonomicStatus)); } catch (UnmappedValueException e) { String id = record.get(taxonID); logger.warn("{} | {}", id, e.getMessage()); } sn.setTaxonomicStatus(status); TransformUtil.setScientificNameGroup(sn); return sn; }
CoLSynonymBatchTransformer { private static ScientificName createSynonym(CSVRecordInfo<CoLTaxonCsvField> record) { ScientificName sn = new ScientificName(); sn.setFullScientificName(record.get(scientificName)); sn.setGenusOrMonomial(record.get(genericName)); sn.setSpecificEpithet(record.get(specificEpithet)); sn.setInfraspecificEpithet(record.get(infraspecificEpithet)); sn.setAuthorshipVerbatim(record.get(scientificNameAuthorship)); TaxonomicStatus status = null; try { status = statusNormalizer.map(record.get(taxonomicStatus)); } catch (UnmappedValueException e) { String id = record.get(taxonID); logger.warn("{} | {}", id, e.getMessage()); } sn.setTaxonomicStatus(status); TransformUtil.setScientificNameGroup(sn); return sn; } }
CoLSynonymBatchTransformer { private static ScientificName createSynonym(CSVRecordInfo<CoLTaxonCsvField> record) { ScientificName sn = new ScientificName(); sn.setFullScientificName(record.get(scientificName)); sn.setGenusOrMonomial(record.get(genericName)); sn.setSpecificEpithet(record.get(specificEpithet)); sn.setInfraspecificEpithet(record.get(infraspecificEpithet)); sn.setAuthorshipVerbatim(record.get(scientificNameAuthorship)); TaxonomicStatus status = null; try { status = statusNormalizer.map(record.get(taxonomicStatus)); } catch (UnmappedValueException e) { String id = record.get(taxonID); logger.warn("{} | {}", id, e.getMessage()); } sn.setTaxonomicStatus(status); TransformUtil.setScientificNameGroup(sn); return sn; } CoLSynonymBatchTransformer(); }
CoLSynonymBatchTransformer { private static ScientificName createSynonym(CSVRecordInfo<CoLTaxonCsvField> record) { ScientificName sn = new ScientificName(); sn.setFullScientificName(record.get(scientificName)); sn.setGenusOrMonomial(record.get(genericName)); sn.setSpecificEpithet(record.get(specificEpithet)); sn.setInfraspecificEpithet(record.get(infraspecificEpithet)); sn.setAuthorshipVerbatim(record.get(scientificNameAuthorship)); TaxonomicStatus status = null; try { status = statusNormalizer.map(record.get(taxonomicStatus)); } catch (UnmappedValueException e) { String id = record.get(taxonID); logger.warn("{} | {}", id, e.getMessage()); } sn.setTaxonomicStatus(status); TransformUtil.setScientificNameGroup(sn); return sn; } CoLSynonymBatchTransformer();  }
CoLSynonymBatchTransformer { private static ScientificName createSynonym(CSVRecordInfo<CoLTaxonCsvField> record) { ScientificName sn = new ScientificName(); sn.setFullScientificName(record.get(scientificName)); sn.setGenusOrMonomial(record.get(genericName)); sn.setSpecificEpithet(record.get(specificEpithet)); sn.setInfraspecificEpithet(record.get(infraspecificEpithet)); sn.setAuthorshipVerbatim(record.get(scientificNameAuthorship)); TaxonomicStatus status = null; try { status = statusNormalizer.map(record.get(taxonomicStatus)); } catch (UnmappedValueException e) { String id = record.get(taxonID); logger.warn("{} | {}", id, e.getMessage()); } sn.setTaxonomicStatus(status); TransformUtil.setScientificNameGroup(sn); return sn; } CoLSynonymBatchTransformer();   }