@Test public void testGetNamedAreas() throws Exception { ETLStatistics etlStatistics = new ETLStatistics(); CrsSpecimenTransformer crsSpecimenTransformer = new CrsSpecimenTransformer(etlStatistics); CrsExtractor extractor = new CrsExtractor(specimenFile, etlStatistics); List<NamedArea> namedAreas = new ArrayList<>(); for (XMLRecordInfo extracted : extractor) { CommonReflectionUtil.setField(AbstractTransformer.class, crsSpecimenTransformer, "objectID", "RMNH.MAM.TT.5"); CommonReflectionUtil.setField(AbstractTransformer.class, crsSpecimenTransformer, "input", extracted); Object obj = CommonReflectionUtil.callMethod(null, null, crsSpecimenTransformer, "getNamedAreas"); namedAreas = (List<NamedArea>) obj; } NamedArea expectedNamedArea_01 = new NamedArea(AreaClass.parse("CONTINENT"), "Africa"); NamedArea expectedNamedArea_02 = new NamedArea(AreaClass.parse("county"), "Atewa Range FR"); assertEquals("01", 2, namedAreas.size()); assertTrue("02", namedAreas.contains(expectedNamedArea_01)); assertTrue("02", namedAreas.contains(expectedNamedArea_02)); }
private List<NamedArea> getNamedAreas() { Element record = input.getRecord(); List<Element> elements = DOMUtil.getDescendants(record, "ncrsNamedAreas"); if (elements == null) { return null; } List<NamedArea> namedAreas = new ArrayList<>(); for (Element element : elements) { AreaClass areaClass; try { areaClass = getAreaClass(element); } catch (IllegalArgumentException ex) { if (!suppressErrors) { warn(ex.getMessage()); } continue; } String areaName = val(element, "abcd:AreaName"); if (areaClass != null && areaName != null) { namedAreas.add(new NamedArea(areaClass, areaName)); } } return (namedAreas.size() == 0) ? null : namedAreas; }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private List<NamedArea> getNamedAreas() { Element record = input.getRecord(); List<Element> elements = DOMUtil.getDescendants(record, "ncrsNamedAreas"); if (elements == null) { return null; } List<NamedArea> namedAreas = new ArrayList<>(); for (Element element : elements) { AreaClass areaClass; try { areaClass = getAreaClass(element); } catch (IllegalArgumentException ex) { if (!suppressErrors) { warn(ex.getMessage()); } continue; } String areaName = val(element, "abcd:AreaName"); if (areaClass != null && areaName != null) { namedAreas.add(new NamedArea(areaClass, areaName)); } } return (namedAreas.size() == 0) ? null : namedAreas; } }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private List<NamedArea> getNamedAreas() { Element record = input.getRecord(); List<Element> elements = DOMUtil.getDescendants(record, "ncrsNamedAreas"); if (elements == null) { return null; } List<NamedArea> namedAreas = new ArrayList<>(); for (Element element : elements) { AreaClass areaClass; try { areaClass = getAreaClass(element); } catch (IllegalArgumentException ex) { if (!suppressErrors) { warn(ex.getMessage()); } continue; } String areaName = val(element, "abcd:AreaName"); if (areaClass != null && areaName != null) { namedAreas.add(new NamedArea(areaClass, areaName)); } } return (namedAreas.size() == 0) ? null : namedAreas; } CrsSpecimenTransformer(ETLStatistics stats); }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private List<NamedArea> getNamedAreas() { Element record = input.getRecord(); List<Element> elements = DOMUtil.getDescendants(record, "ncrsNamedAreas"); if (elements == null) { return null; } List<NamedArea> namedAreas = new ArrayList<>(); for (Element element : elements) { AreaClass areaClass; try { areaClass = getAreaClass(element); } catch (IllegalArgumentException ex) { if (!suppressErrors) { warn(ex.getMessage()); } continue; } String areaName = val(element, "abcd:AreaName"); if (areaClass != null && areaName != null) { namedAreas.add(new NamedArea(areaClass, areaName)); } } return (namedAreas.size() == 0) ? null : namedAreas; } CrsSpecimenTransformer(ETLStatistics stats);  }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private List<NamedArea> getNamedAreas() { Element record = input.getRecord(); List<Element> elements = DOMUtil.getDescendants(record, "ncrsNamedAreas"); if (elements == null) { return null; } List<NamedArea> namedAreas = new ArrayList<>(); for (Element element : elements) { AreaClass areaClass; try { areaClass = getAreaClass(element); } catch (IllegalArgumentException ex) { if (!suppressErrors) { warn(ex.getMessage()); } continue; } String areaName = val(element, "abcd:AreaName"); if (areaClass != null && areaName != null) { namedAreas.add(new NamedArea(areaClass, areaName)); } } return (namedAreas.size() == 0) ? null : namedAreas; } CrsSpecimenTransformer(ETLStatistics stats);   }