@Test public void testDoTransform() throws Exception { CSVRecordInfo<BrahmsCsvField> record = mock(CSVRecordInfo.class); ETLStatistics etlStatistics = new ETLStatistics(); when(record.get(BrahmsCsvField.SPECIES)).thenReturn("Rhododendron ferrugineum L."); when(record.get(BrahmsCsvField.AUTHOR2)).thenReturn("L."); when(record.get(BrahmsCsvField.GENUS)).thenReturn("Rhododendron"); when(record.get(BrahmsCsvField.SP1)).thenReturn("ferrugineum"); when(record.get(BrahmsCsvField.RANK2)).thenReturn("testInfraSpecifc"); when(record.get(BrahmsCsvField.SP2)).thenReturn(""); when(record.get(BrahmsCsvField.BARCODE)).thenReturn("L.3355550"); when(record.get(BrahmsCsvField.NOTONLINE)).thenReturn(""); when(record.get(BrahmsCsvField.PLANTDESC)).thenReturn("TestDesc"); when(record.get(BrahmsCsvField.CATEGORY)).thenReturn("L"); when(record.get(BrahmsCsvField.COLLECTOR, false)).thenReturn("Unknown "); when(record.get(BrahmsCsvField.PREFIX, false)).thenReturn(" "); when(record.get(BrahmsCsvField.NUMBER, false)).thenReturn("s.n. "); when(record.get(BrahmsCsvField.SUFFIX, false)).thenReturn(" "); when(record.get(BrahmsCsvField.TYPE)).thenReturn(""); when(record.get(BrahmsCsvField.DETBY)).thenReturn(""); when(record.get(BrahmsCsvField.VERNACULAR)).thenReturn(""); when(record.get(BrahmsCsvField.YEARIDENT)).thenReturn(" 0.000000"); when(record.get(BrahmsCsvField.MONTHIDENT)).thenReturn(" 0.000000"); when(record.get(BrahmsCsvField.DAYIDENT)).thenReturn(" 0.000000"); when(record.get(BrahmsCsvField.IMAGELIST)).thenReturn("http: when(record.get(BrahmsCsvField.CONTINENT)).thenReturn("Europe"); when(record.get(BrahmsCsvField.COUNTRY)).thenReturn("Netherlands"); when(record.get(BrahmsCsvField.MAJORAREA)).thenReturn(""); when(record.get(BrahmsCsvField.LOCNOTES)).thenReturn("Io een rotsachtige rij vochtige berghelling bij het Kolmhans."); when(record.get(BrahmsCsvField.YEAR)).thenReturn(" 0.000000"); when(record.get(BrahmsCsvField.MONTH)).thenReturn(" 8.000000"); when(record.get(BrahmsCsvField.DAY)).thenReturn(" 3.000000"); when(record.get(BrahmsCsvField.LATITUDE)).thenReturn(" 0.000000"); when(record.get(BrahmsCsvField.LONGITUDE)).thenReturn(" 0.000000"); when(record.get(BrahmsCsvField.OLDBARCODE, true)).thenReturn("L 0020601"); when(record.get(BrahmsCsvField.ACCESSION, true)).thenReturn("125784"); BrahmsSpecimenTransformer brahmsSpecimenTransformer = new BrahmsSpecimenTransformer(etlStatistics); CommonReflectionUtil.setField(AbstractTransformer.class, brahmsSpecimenTransformer, "objectID", "L.3355550"); CommonReflectionUtil.setField(AbstractTransformer.class, brahmsSpecimenTransformer, "input", record); Object returned = CommonReflectionUtil.callMethod(null, CSVRecordInfo.class, brahmsSpecimenTransformer, "doTransform"); List<Specimen> list = (List<Specimen>) returned; String expectedId = "L.3355550@BRAHMS"; String expectedGUID = "https: String expectedFullScientificName = "Rhododendron ferrugineum L."; String expectedScientificNameGroup = "rhododendron ferrugineum "; String expectedGenusMonomial = "Rhododendron"; String expectedPreviousUnitsTexts = "L 0020601 | 125784"; assertNotNull("01",list); assertTrue("02",list.size() == 1); assertEquals("03",expectedId, list.stream().map(i -> i.getId()).findFirst().get()); assertEquals("04",expectedGUID, list.stream().map(i -> i.getUnitGUID()).findFirst().get()); assertEquals("05",expectedFullScientificName,list.stream().map(i -> i.getIdentifications().get(0).getScientificName().getFullScientificName()).findFirst().get()); assertEquals("06",expectedScientificNameGroup,list.stream().map(i -> i.getIdentifications().get(0).getScientificName().getScientificNameGroup()).findFirst().get()); assertEquals("07",expectedGenusMonomial, list.stream().map(i -> i.getIdentifications().get(0).getScientificName().getGenusOrMonomial()).findFirst().get()); assertEquals("08", expectedPreviousUnitsTexts, list.stream().map(i -> i.getPreviousUnitsText()).findFirst().get()); }
@Override protected List<Specimen> doTransform() { stats.recordsAccepted++; stats.objectsProcessed++; try { Specimen specimen = new Specimen(); specimen.setId(getElasticsearchId(BRAHMS, objectID)); specimen.setSourceSystemId(objectID); specimen.setUnitID(objectID); specimen.setUnitGUID(getSpecimenPurl(objectID)); setConstants(specimen); List<String> themes = themeCache.lookup(objectID, SPECIMEN, BRAHMS); specimen.setTheme(themes); String s = input.get(CATEGORY); if (s == null) specimen.setRecordBasis("Preserved Specimen"); else specimen.setRecordBasis(s); specimen.setAssemblageID(getAssemblageID()); String notes = input.get(PLANTDESC, true); if (notes != null) specimen.setNotes(notes.replaceAll("\u00001", "")); specimen.setPreviousUnitsText(getPreviousUnitsText()); s = input.get(NOTONLINE); if (s == null || s.equals("0")) specimen.setObjectPublic(true); else specimen.setObjectPublic(false); specimen.setCollectorsFieldNumber(getCollectorsFieldNumber()); specimen.setGatheringEvent(getGatheringEvent(input)); specimen.addIndentification(getSpecimenIdentification(input)); if (doEnrich()) { enrichIdentification(specimen); } specimen.setAssociatedMultiMediaUris(getServiceAccessPoints()); stats.objectsAccepted++; return Arrays.asList(specimen); } catch (Throwable t) { stats.objectsRejected++; if (!suppressErrors) { error(t.getMessage()); error(input.getLine()); } return null; } }
BrahmsSpecimenTransformer extends BrahmsTransformer<Specimen> { @Override protected List<Specimen> doTransform() { stats.recordsAccepted++; stats.objectsProcessed++; try { Specimen specimen = new Specimen(); specimen.setId(getElasticsearchId(BRAHMS, objectID)); specimen.setSourceSystemId(objectID); specimen.setUnitID(objectID); specimen.setUnitGUID(getSpecimenPurl(objectID)); setConstants(specimen); List<String> themes = themeCache.lookup(objectID, SPECIMEN, BRAHMS); specimen.setTheme(themes); String s = input.get(CATEGORY); if (s == null) specimen.setRecordBasis("Preserved Specimen"); else specimen.setRecordBasis(s); specimen.setAssemblageID(getAssemblageID()); String notes = input.get(PLANTDESC, true); if (notes != null) specimen.setNotes(notes.replaceAll("\u00001", "")); specimen.setPreviousUnitsText(getPreviousUnitsText()); s = input.get(NOTONLINE); if (s == null || s.equals("0")) specimen.setObjectPublic(true); else specimen.setObjectPublic(false); specimen.setCollectorsFieldNumber(getCollectorsFieldNumber()); specimen.setGatheringEvent(getGatheringEvent(input)); specimen.addIndentification(getSpecimenIdentification(input)); if (doEnrich()) { enrichIdentification(specimen); } specimen.setAssociatedMultiMediaUris(getServiceAccessPoints()); stats.objectsAccepted++; return Arrays.asList(specimen); } catch (Throwable t) { stats.objectsRejected++; if (!suppressErrors) { error(t.getMessage()); error(input.getLine()); } return null; } } }
BrahmsSpecimenTransformer extends BrahmsTransformer<Specimen> { @Override protected List<Specimen> doTransform() { stats.recordsAccepted++; stats.objectsProcessed++; try { Specimen specimen = new Specimen(); specimen.setId(getElasticsearchId(BRAHMS, objectID)); specimen.setSourceSystemId(objectID); specimen.setUnitID(objectID); specimen.setUnitGUID(getSpecimenPurl(objectID)); setConstants(specimen); List<String> themes = themeCache.lookup(objectID, SPECIMEN, BRAHMS); specimen.setTheme(themes); String s = input.get(CATEGORY); if (s == null) specimen.setRecordBasis("Preserved Specimen"); else specimen.setRecordBasis(s); specimen.setAssemblageID(getAssemblageID()); String notes = input.get(PLANTDESC, true); if (notes != null) specimen.setNotes(notes.replaceAll("\u00001", "")); specimen.setPreviousUnitsText(getPreviousUnitsText()); s = input.get(NOTONLINE); if (s == null || s.equals("0")) specimen.setObjectPublic(true); else specimen.setObjectPublic(false); specimen.setCollectorsFieldNumber(getCollectorsFieldNumber()); specimen.setGatheringEvent(getGatheringEvent(input)); specimen.addIndentification(getSpecimenIdentification(input)); if (doEnrich()) { enrichIdentification(specimen); } specimen.setAssociatedMultiMediaUris(getServiceAccessPoints()); stats.objectsAccepted++; return Arrays.asList(specimen); } catch (Throwable t) { stats.objectsRejected++; if (!suppressErrors) { error(t.getMessage()); error(input.getLine()); } return null; } } BrahmsSpecimenTransformer(ETLStatistics stats); }
BrahmsSpecimenTransformer extends BrahmsTransformer<Specimen> { @Override protected List<Specimen> doTransform() { stats.recordsAccepted++; stats.objectsProcessed++; try { Specimen specimen = new Specimen(); specimen.setId(getElasticsearchId(BRAHMS, objectID)); specimen.setSourceSystemId(objectID); specimen.setUnitID(objectID); specimen.setUnitGUID(getSpecimenPurl(objectID)); setConstants(specimen); List<String> themes = themeCache.lookup(objectID, SPECIMEN, BRAHMS); specimen.setTheme(themes); String s = input.get(CATEGORY); if (s == null) specimen.setRecordBasis("Preserved Specimen"); else specimen.setRecordBasis(s); specimen.setAssemblageID(getAssemblageID()); String notes = input.get(PLANTDESC, true); if (notes != null) specimen.setNotes(notes.replaceAll("\u00001", "")); specimen.setPreviousUnitsText(getPreviousUnitsText()); s = input.get(NOTONLINE); if (s == null || s.equals("0")) specimen.setObjectPublic(true); else specimen.setObjectPublic(false); specimen.setCollectorsFieldNumber(getCollectorsFieldNumber()); specimen.setGatheringEvent(getGatheringEvent(input)); specimen.addIndentification(getSpecimenIdentification(input)); if (doEnrich()) { enrichIdentification(specimen); } specimen.setAssociatedMultiMediaUris(getServiceAccessPoints()); stats.objectsAccepted++; return Arrays.asList(specimen); } catch (Throwable t) { stats.objectsRejected++; if (!suppressErrors) { error(t.getMessage()); error(input.getLine()); } return null; } } BrahmsSpecimenTransformer(ETLStatistics stats);  }
BrahmsSpecimenTransformer extends BrahmsTransformer<Specimen> { @Override protected List<Specimen> doTransform() { stats.recordsAccepted++; stats.objectsProcessed++; try { Specimen specimen = new Specimen(); specimen.setId(getElasticsearchId(BRAHMS, objectID)); specimen.setSourceSystemId(objectID); specimen.setUnitID(objectID); specimen.setUnitGUID(getSpecimenPurl(objectID)); setConstants(specimen); List<String> themes = themeCache.lookup(objectID, SPECIMEN, BRAHMS); specimen.setTheme(themes); String s = input.get(CATEGORY); if (s == null) specimen.setRecordBasis("Preserved Specimen"); else specimen.setRecordBasis(s); specimen.setAssemblageID(getAssemblageID()); String notes = input.get(PLANTDESC, true); if (notes != null) specimen.setNotes(notes.replaceAll("\u00001", "")); specimen.setPreviousUnitsText(getPreviousUnitsText()); s = input.get(NOTONLINE); if (s == null || s.equals("0")) specimen.setObjectPublic(true); else specimen.setObjectPublic(false); specimen.setCollectorsFieldNumber(getCollectorsFieldNumber()); specimen.setGatheringEvent(getGatheringEvent(input)); specimen.addIndentification(getSpecimenIdentification(input)); if (doEnrich()) { enrichIdentification(specimen); } specimen.setAssociatedMultiMediaUris(getServiceAccessPoints()); stats.objectsAccepted++; return Arrays.asList(specimen); } catch (Throwable t) { stats.objectsRejected++; if (!suppressErrors) { error(t.getMessage()); error(input.getLine()); } return null; } } BrahmsSpecimenTransformer(ETLStatistics stats);   }