@SuppressWarnings("unchecked") @Test public void testDoTransform() throws Exception { ETLStatistics etlStatistics = new ETLStatistics(); List<Taxon> list = null; List<MultiMediaObject> actual = null; NsrExtractor extractor = new NsrExtractor(nsrFile, etlStatistics); NsrTaxonTransformer nsrTaxonTransformer = new NsrTaxonTransformer(etlStatistics); NsrMultiMediaTransformer mediaTransformer = new NsrMultiMediaTransformer(etlStatistics); for (XMLRecordInfo extracted : extractor) { CommonReflectionUtil.setField(AbstractTransformer.class, nsrTaxonTransformer, "objectID", "D3KF0JNQ0UA"); CommonReflectionUtil.setField(AbstractTransformer.class, nsrTaxonTransformer, "input", extracted); Object taxonObject = CommonReflectionUtil.callMethod(null, null, nsrTaxonTransformer, "doTransform"); CommonReflectionUtil.setField(AbstractTransformer.class, mediaTransformer, "objectID", "D3KF0JNQ0UA"); CommonReflectionUtil.setField(AbstractTransformer.class, mediaTransformer, "input", extracted); list = (List<Taxon>) taxonObject; mediaTransformer.setTaxon(list.get(0)); Object returned = CommonReflectionUtil.callMethod(null, null, mediaTransformer, "doTransform"); actual = (List<MultiMediaObject>) returned; } String expectedAssociatedTaxRef = "D3KF0JNQ0UA@NSR"; String expectedCreator = "Arnold Wijker"; String expectedCollectionType = null; String expectedCaption = "Adult winter"; String expectedDescription = "Adult winter"; String expectedId = "D3KF0JNQ0UA_1011552535@NSR"; String expectedLicenseType = "Copyright"; String expectedLicense = "CC BY-NC-ND"; String expectedOwner = "Naturalis Biodiversity Center"; String expectedSourceId = "LNG NSR"; String expectedSourceSystemId = "D3KF0JNQ0UA_1011552535"; String expectedUnitId = "D3KF0JNQ0UA_1011552535"; assertEquals("01",expectedAssociatedTaxRef, actual.get(0).getAssociatedTaxonReference()); assertEquals("02",expectedCreator, actual.get(0).getCreator()); assertEquals("03",expectedCollectionType, actual.get(0).getCollectionType()); assertEquals("04",expectedCaption, actual.get(0).getCaption()); assertEquals("05",expectedDescription, actual.get(0).getDescription()); assertEquals("06",expectedId, actual.get(0).getId()); assertEquals("07",expectedLicenseType, actual.get(0).getLicenseType().toString()); assertEquals("08",expectedLicense, actual.get(0).getLicense().toString()); assertEquals("09",expectedOwner, actual.get(0).getOwner()); assertEquals("10",expectedSourceId, actual.get(0).getSourceID()); assertEquals("12",expectedSourceSystemId, actual.get(0).getSourceSystemId()); assertEquals("13",expectedUnitId, actual.get(0).getUnitID()); }
@Override protected List<MultiMediaObject> doTransform() { if (taxon == null) { stats.recordsSkipped++; if (logger.isDebugEnabled() && testGenera == null) { debug("Ignoring images for skipped or invalid taxon"); } return null; } Image[] images = nsrTaxon.getImages(); if (images == null) { if (logger.isDebugEnabled()) debug("Skipping taxon without images"); stats.recordsSkipped++; return null; } stats.recordsAccepted++; List<MultiMediaObject> mmos = new ArrayList<>(images.length); for (Image image : images) { MultiMediaObject mmo = transformOne(image); if (mmo != null) mmos.add(mmo); } return mmos.size() == 0 ? null : mmos; }
NsrMultiMediaTransformer extends AbstractJSONTransformer<MultiMediaObject> { @Override protected List<MultiMediaObject> doTransform() { if (taxon == null) { stats.recordsSkipped++; if (logger.isDebugEnabled() && testGenera == null) { debug("Ignoring images for skipped or invalid taxon"); } return null; } Image[] images = nsrTaxon.getImages(); if (images == null) { if (logger.isDebugEnabled()) debug("Skipping taxon without images"); stats.recordsSkipped++; return null; } stats.recordsAccepted++; List<MultiMediaObject> mmos = new ArrayList<>(images.length); for (Image image : images) { MultiMediaObject mmo = transformOne(image); if (mmo != null) mmos.add(mmo); } return mmos.size() == 0 ? null : mmos; } }
NsrMultiMediaTransformer extends AbstractJSONTransformer<MultiMediaObject> { @Override protected List<MultiMediaObject> doTransform() { if (taxon == null) { stats.recordsSkipped++; if (logger.isDebugEnabled() && testGenera == null) { debug("Ignoring images for skipped or invalid taxon"); } return null; } Image[] images = nsrTaxon.getImages(); if (images == null) { if (logger.isDebugEnabled()) debug("Skipping taxon without images"); stats.recordsSkipped++; return null; } stats.recordsAccepted++; List<MultiMediaObject> mmos = new ArrayList<>(images.length); for (Image image : images) { MultiMediaObject mmo = transformOne(image); if (mmo != null) mmos.add(mmo); } return mmos.size() == 0 ? null : mmos; } NsrMultiMediaTransformer(ETLStatistics stats); }
NsrMultiMediaTransformer extends AbstractJSONTransformer<MultiMediaObject> { @Override protected List<MultiMediaObject> doTransform() { if (taxon == null) { stats.recordsSkipped++; if (logger.isDebugEnabled() && testGenera == null) { debug("Ignoring images for skipped or invalid taxon"); } return null; } Image[] images = nsrTaxon.getImages(); if (images == null) { if (logger.isDebugEnabled()) debug("Skipping taxon without images"); stats.recordsSkipped++; return null; } stats.recordsAccepted++; List<MultiMediaObject> mmos = new ArrayList<>(images.length); for (Image image : images) { MultiMediaObject mmo = transformOne(image); if (mmo != null) mmos.add(mmo); } return mmos.size() == 0 ? null : mmos; } NsrMultiMediaTransformer(ETLStatistics stats); void setTaxon(Taxon taxon); }
NsrMultiMediaTransformer extends AbstractJSONTransformer<MultiMediaObject> { @Override protected List<MultiMediaObject> doTransform() { if (taxon == null) { stats.recordsSkipped++; if (logger.isDebugEnabled() && testGenera == null) { debug("Ignoring images for skipped or invalid taxon"); } return null; } Image[] images = nsrTaxon.getImages(); if (images == null) { if (logger.isDebugEnabled()) debug("Skipping taxon without images"); stats.recordsSkipped++; return null; } stats.recordsAccepted++; List<MultiMediaObject> mmos = new ArrayList<>(images.length); for (Image image : images) { MultiMediaObject mmo = transformOne(image); if (mmo != null) mmos.add(mmo); } return mmos.size() == 0 ? null : mmos; } NsrMultiMediaTransformer(ETLStatistics stats); void setTaxon(Taxon taxon);  }