@Test public void testDoTransform() throws Exception { CSVRecordInfo<CoLTaxonCsvField> record = mock(CSVRecordInfo.class); ETLStatistics etlStatistics = new ETLStatistics(); when(record.get(CoLTaxonCsvField.taxonID)).thenReturn("6931872"); 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("6931872"); 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("test_infraspecificEpithet"); when(record.get(CoLTaxonCsvField.scientificNameAuthorship)).thenReturn("Cresson, 1863"); when(record.get(CoLTaxonCsvField.source)).thenReturn("test_source"); when(record.get(CoLTaxonCsvField.namePublishedIn)).thenReturn("test_namePublishedIn"); when(record.get(CoLTaxonCsvField.nameAccordingTo)).thenReturn("test_nameAccordingTo"); when(record.get(CoLTaxonCsvField.modified)).thenReturn("30-Sep-2008"); when(record.get(CoLTaxonCsvField.description)).thenReturn("test_desc"); when(record.get(CoLTaxonCsvField.taxonConceptID)).thenReturn("test_taxonConceptID"); when(record.get(CoLTaxonCsvField.scientificNameID)).thenReturn("ITS-714782"); when(record.get(CoLTaxonCsvField.references)).thenReturn("https: CoLTaxonTransformer coLTaxonTransformer = new CoLTaxonTransformer(etlStatistics); CommonReflectionUtil.setField(AbstractTransformer.class, coLTaxonTransformer, "objectID", "6931872"); CommonReflectionUtil.setField(AbstractTransformer.class, coLTaxonTransformer, "input", record); Object returned = ReflectionUtil.call(coLTaxonTransformer, "doTransform", new Class[] {}, new Object[] {}); List<Taxon> list = (List<Taxon>) returned; String expectedId = "6931872@COL"; String expectedRecordURI = "https: String expectedAuthorshipVerbatim = "Cresson, 1863"; String expectedScientificNameGroup = "bombus affinis test_infraspecificepithet"; String expectedFullScientificName = "Bombus affinis Cresson, 1863"; String expectedGenusOrMonomial = "Bombus"; String expectedSpcificEpithet = "affinis"; assertNotNull("01", list); assertTrue("02", list.size() == 1); assertEquals("03", expectedId, list.stream().map(i -> i.getId()).findFirst().get()); assertEquals("04", expectedRecordURI, list.stream().map(i -> i.getRecordURI()).findFirst().get().toString()); assertEquals("05", expectedAuthorshipVerbatim, list.stream().map(i -> i.getAcceptedName().getAuthorshipVerbatim()).findFirst().get().toString()); assertEquals("06", expectedFullScientificName, list.stream().map(i -> i.getAcceptedName().getFullScientificName()).findFirst().get().toString()); assertEquals("07", expectedScientificNameGroup, list.stream().map(i -> i.getAcceptedName().getScientificNameGroup()).findFirst().get().toString()); assertEquals("08", expectedGenusOrMonomial, list.stream().map(i -> i.getAcceptedName().getGenusOrMonomial()).findFirst().get().toString()); assertEquals("09", expectedSpcificEpithet, list.stream().map(i -> i.getAcceptedName().getSpecificEpithet()).findFirst().get().toString()); }
@Override protected List<Taxon> doTransform() { String rank = input.get(taxonRank); if (!allowedTaxonRanks.contains(rank)) { stats.recordsSkipped++; if (logger.isDebugEnabled()) debug("Ignoring taxon with rank \"%s\"", rank); return null; } try { stats.recordsAccepted++; stats.objectsProcessed++; Taxon taxon = new Taxon(); taxon.setId(getElasticsearchId(COL, objectID)); taxon.setSourceSystem(COL); taxon.setSourceSystemId(input.get(taxonID)); taxon.setTaxonRank(input.get(taxonRank)); taxon.setAcceptedName(getScientificName()); taxon.setDefaultClassification(getClassification()); addMonomials(taxon); setRecordURI(taxon); setTaxonDescription(taxon); stats.objectsAccepted++; return Arrays.asList(taxon); } catch (Throwable t) { handleError(t); return null; } }
CoLTaxonTransformer extends AbstractCSVTransformer<CoLTaxonCsvField, Taxon> { @Override protected List<Taxon> doTransform() { String rank = input.get(taxonRank); if (!allowedTaxonRanks.contains(rank)) { stats.recordsSkipped++; if (logger.isDebugEnabled()) debug("Ignoring taxon with rank \"%s\"", rank); return null; } try { stats.recordsAccepted++; stats.objectsProcessed++; Taxon taxon = new Taxon(); taxon.setId(getElasticsearchId(COL, objectID)); taxon.setSourceSystem(COL); taxon.setSourceSystemId(input.get(taxonID)); taxon.setTaxonRank(input.get(taxonRank)); taxon.setAcceptedName(getScientificName()); taxon.setDefaultClassification(getClassification()); addMonomials(taxon); setRecordURI(taxon); setTaxonDescription(taxon); stats.objectsAccepted++; return Arrays.asList(taxon); } catch (Throwable t) { handleError(t); return null; } } }
CoLTaxonTransformer extends AbstractCSVTransformer<CoLTaxonCsvField, Taxon> { @Override protected List<Taxon> doTransform() { String rank = input.get(taxonRank); if (!allowedTaxonRanks.contains(rank)) { stats.recordsSkipped++; if (logger.isDebugEnabled()) debug("Ignoring taxon with rank \"%s\"", rank); return null; } try { stats.recordsAccepted++; stats.objectsProcessed++; Taxon taxon = new Taxon(); taxon.setId(getElasticsearchId(COL, objectID)); taxon.setSourceSystem(COL); taxon.setSourceSystemId(input.get(taxonID)); taxon.setTaxonRank(input.get(taxonRank)); taxon.setAcceptedName(getScientificName()); taxon.setDefaultClassification(getClassification()); addMonomials(taxon); setRecordURI(taxon); setTaxonDescription(taxon); stats.objectsAccepted++; return Arrays.asList(taxon); } catch (Throwable t) { handleError(t); return null; } } CoLTaxonTransformer(ETLStatistics stats); }
CoLTaxonTransformer extends AbstractCSVTransformer<CoLTaxonCsvField, Taxon> { @Override protected List<Taxon> doTransform() { String rank = input.get(taxonRank); if (!allowedTaxonRanks.contains(rank)) { stats.recordsSkipped++; if (logger.isDebugEnabled()) debug("Ignoring taxon with rank \"%s\"", rank); return null; } try { stats.recordsAccepted++; stats.objectsProcessed++; Taxon taxon = new Taxon(); taxon.setId(getElasticsearchId(COL, objectID)); taxon.setSourceSystem(COL); taxon.setSourceSystemId(input.get(taxonID)); taxon.setTaxonRank(input.get(taxonRank)); taxon.setAcceptedName(getScientificName()); taxon.setDefaultClassification(getClassification()); addMonomials(taxon); setRecordURI(taxon); setTaxonDescription(taxon); stats.objectsAccepted++; return Arrays.asList(taxon); } catch (Throwable t) { handleError(t); return null; } } CoLTaxonTransformer(ETLStatistics stats);  }
CoLTaxonTransformer extends AbstractCSVTransformer<CoLTaxonCsvField, Taxon> { @Override protected List<Taxon> doTransform() { String rank = input.get(taxonRank); if (!allowedTaxonRanks.contains(rank)) { stats.recordsSkipped++; if (logger.isDebugEnabled()) debug("Ignoring taxon with rank \"%s\"", rank); return null; } try { stats.recordsAccepted++; stats.objectsProcessed++; Taxon taxon = new Taxon(); taxon.setId(getElasticsearchId(COL, objectID)); taxon.setSourceSystem(COL); taxon.setSourceSystemId(input.get(taxonID)); taxon.setTaxonRank(input.get(taxonRank)); taxon.setAcceptedName(getScientificName()); taxon.setDefaultClassification(getClassification()); addMonomials(taxon); setRecordURI(taxon); setTaxonDescription(taxon); stats.objectsAccepted++; return Arrays.asList(taxon); } catch (Throwable t) { handleError(t); return null; } } CoLTaxonTransformer(ETLStatistics stats);   }