@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"); BrahmsMultiMediaTransformer brahmsMultiMediaTransformer = new BrahmsMultiMediaTransformer(etlStatistics); CommonReflectionUtil.setField(AbstractTransformer.class, brahmsMultiMediaTransformer, "objectID", "L.3355550"); CommonReflectionUtil.setField(AbstractTransformer.class, brahmsMultiMediaTransformer, "input", record); Object obj = CommonReflectionUtil.callMethod(null, CSVRecordInfo.class, brahmsMultiMediaTransformer, "doTransform"); String expectedAssociatedSpecimenRef = "L.3355550@BRAHMS"; String expectedSourceID = "Brahms"; List<MultiMediaObject> list = (List<MultiMediaObject>) obj; assertNotNull("01", list); assertTrue("02", list.size() == 1); assertEquals("03", expectedAssociatedSpecimenRef, list.stream().map(i -> i.getAssociatedSpecimenReference()).findFirst().get()); assertEquals("04", expectedSourceID, list.stream().map(i -> i.getSourceID()).findFirst().get()); }
@Override protected List<MultiMediaObject> doTransform() { stats.recordsAccepted++; try { ArrayList<MultiMediaObject> result = new ArrayList<>(3); String images = input.get(IMAGELIST); if (images != null) { String[] urls = images.split(","); for (int i = 0; i < urls.length; ++i) { MultiMediaObject mmo = transformOne(urls[i]); if (mmo != null) { result.add(mmo); } } } return result; } catch (Throwable t) { stats.objectsRejected++; if (!suppressErrors) { error(t.getMessage()); error(input.getLine()); } return null; } }
BrahmsMultiMediaTransformer extends BrahmsTransformer<MultiMediaObject> { @Override protected List<MultiMediaObject> doTransform() { stats.recordsAccepted++; try { ArrayList<MultiMediaObject> result = new ArrayList<>(3); String images = input.get(IMAGELIST); if (images != null) { String[] urls = images.split(","); for (int i = 0; i < urls.length; ++i) { MultiMediaObject mmo = transformOne(urls[i]); if (mmo != null) { result.add(mmo); } } } return result; } catch (Throwable t) { stats.objectsRejected++; if (!suppressErrors) { error(t.getMessage()); error(input.getLine()); } return null; } } }
BrahmsMultiMediaTransformer extends BrahmsTransformer<MultiMediaObject> { @Override protected List<MultiMediaObject> doTransform() { stats.recordsAccepted++; try { ArrayList<MultiMediaObject> result = new ArrayList<>(3); String images = input.get(IMAGELIST); if (images != null) { String[] urls = images.split(","); for (int i = 0; i < urls.length; ++i) { MultiMediaObject mmo = transformOne(urls[i]); if (mmo != null) { result.add(mmo); } } } return result; } catch (Throwable t) { stats.objectsRejected++; if (!suppressErrors) { error(t.getMessage()); error(input.getLine()); } return null; } } BrahmsMultiMediaTransformer(ETLStatistics stats); }
BrahmsMultiMediaTransformer extends BrahmsTransformer<MultiMediaObject> { @Override protected List<MultiMediaObject> doTransform() { stats.recordsAccepted++; try { ArrayList<MultiMediaObject> result = new ArrayList<>(3); String images = input.get(IMAGELIST); if (images != null) { String[] urls = images.split(","); for (int i = 0; i < urls.length; ++i) { MultiMediaObject mmo = transformOne(urls[i]); if (mmo != null) { result.add(mmo); } } } return result; } catch (Throwable t) { stats.objectsRejected++; if (!suppressErrors) { error(t.getMessage()); error(input.getLine()); } return null; } } BrahmsMultiMediaTransformer(ETLStatistics stats);  }
BrahmsMultiMediaTransformer extends BrahmsTransformer<MultiMediaObject> { @Override protected List<MultiMediaObject> doTransform() { stats.recordsAccepted++; try { ArrayList<MultiMediaObject> result = new ArrayList<>(3); String images = input.get(IMAGELIST); if (images != null) { String[] urls = images.split(","); for (int i = 0; i < urls.length; ++i) { MultiMediaObject mmo = transformOne(urls[i]); if (mmo != null) { result.add(mmo); } } } return result; } catch (Throwable t) { stats.objectsRejected++; if (!suppressErrors) { error(t.getMessage()); error(input.getLine()); } return null; } } BrahmsMultiMediaTransformer(ETLStatistics stats);   }