@SuppressWarnings("unchecked") @Test public void testNewMediaObject() throws Exception { ETLStatistics etlStatistics = new ETLStatistics(); List<Taxon> list = null; 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, "newMediaObject"); actual = (MultiMediaObject) returned; } String expectedAssociatedTaxRef = "D3KF0JNQ0UA@NSR"; String expectedCollectionType = null; String expectedOwner = "Naturalis Biodiversity Center"; String expectedSourceId = "LNG NSR"; assertEquals("01",expectedAssociatedTaxRef, actual.getAssociatedTaxonReference()); assertEquals("02",expectedCollectionType, actual.getCollectionType()); assertEquals("03",expectedOwner, actual.getOwner()); assertEquals("04",expectedSourceId, actual.getSourceID()); }
private MultiMediaObject newMediaObject() throws NameMismatchException { MultiMediaObject mmo = new MultiMediaObject(); mmo.setSourceSystem(NSR); mmo.setSourceInstitutionID(SOURCE_INSTITUTION_ID); mmo.setOwner(SOURCE_INSTITUTION_ID); mmo.setSourceID("LNG NSR"); String taxonId = getElasticsearchId(NSR, taxon.getSourceSystemId()); mmo.setAssociatedTaxonReference(taxonId); mmo.setIdentifications(Arrays.asList(getIdentification())); equalizeNameComponents(mmo); return mmo; }
NsrMultiMediaTransformer extends AbstractJSONTransformer<MultiMediaObject> { private MultiMediaObject newMediaObject() throws NameMismatchException { MultiMediaObject mmo = new MultiMediaObject(); mmo.setSourceSystem(NSR); mmo.setSourceInstitutionID(SOURCE_INSTITUTION_ID); mmo.setOwner(SOURCE_INSTITUTION_ID); mmo.setSourceID("LNG NSR"); String taxonId = getElasticsearchId(NSR, taxon.getSourceSystemId()); mmo.setAssociatedTaxonReference(taxonId); mmo.setIdentifications(Arrays.asList(getIdentification())); equalizeNameComponents(mmo); return mmo; } }
NsrMultiMediaTransformer extends AbstractJSONTransformer<MultiMediaObject> { private MultiMediaObject newMediaObject() throws NameMismatchException { MultiMediaObject mmo = new MultiMediaObject(); mmo.setSourceSystem(NSR); mmo.setSourceInstitutionID(SOURCE_INSTITUTION_ID); mmo.setOwner(SOURCE_INSTITUTION_ID); mmo.setSourceID("LNG NSR"); String taxonId = getElasticsearchId(NSR, taxon.getSourceSystemId()); mmo.setAssociatedTaxonReference(taxonId); mmo.setIdentifications(Arrays.asList(getIdentification())); equalizeNameComponents(mmo); return mmo; } NsrMultiMediaTransformer(ETLStatistics stats); }
NsrMultiMediaTransformer extends AbstractJSONTransformer<MultiMediaObject> { private MultiMediaObject newMediaObject() throws NameMismatchException { MultiMediaObject mmo = new MultiMediaObject(); mmo.setSourceSystem(NSR); mmo.setSourceInstitutionID(SOURCE_INSTITUTION_ID); mmo.setOwner(SOURCE_INSTITUTION_ID); mmo.setSourceID("LNG NSR"); String taxonId = getElasticsearchId(NSR, taxon.getSourceSystemId()); mmo.setAssociatedTaxonReference(taxonId); mmo.setIdentifications(Arrays.asList(getIdentification())); equalizeNameComponents(mmo); return mmo; } NsrMultiMediaTransformer(ETLStatistics stats); void setTaxon(Taxon taxon); }
NsrMultiMediaTransformer extends AbstractJSONTransformer<MultiMediaObject> { private MultiMediaObject newMediaObject() throws NameMismatchException { MultiMediaObject mmo = new MultiMediaObject(); mmo.setSourceSystem(NSR); mmo.setSourceInstitutionID(SOURCE_INSTITUTION_ID); mmo.setOwner(SOURCE_INSTITUTION_ID); mmo.setSourceID("LNG NSR"); String taxonId = getElasticsearchId(NSR, taxon.getSourceSystemId()); mmo.setAssociatedTaxonReference(taxonId); mmo.setIdentifications(Arrays.asList(getIdentification())); equalizeNameComponents(mmo); return mmo; } NsrMultiMediaTransformer(ETLStatistics stats); void setTaxon(Taxon taxon);  }