@Test public void testGetAreaClass() throws Exception { ETLStatistics etlStatistics = new ETLStatistics(); CrsSpecimenTransformer crsSpecimenTransformer = new CrsSpecimenTransformer(etlStatistics); CrsExtractor extractor = new CrsExtractor(specimenFile, etlStatistics); List<AreaClass> areaClasses = null; for (XMLRecordInfo extracted : extractor) { CommonReflectionUtil.setField(AbstractTransformer.class, crsSpecimenTransformer, "objectID", "RMNH.MAM.TT.5"); CommonReflectionUtil.setField(AbstractTransformer.class, crsSpecimenTransformer, "input", extracted); Element element = extracted.getRecord(); List<Element> elements = DOMUtil.getDescendants(element, "ncrsNamedAreas"); areaClasses = new ArrayList<>(); for (Element e : elements) { Object returned = CommonReflectionUtil.callMethod(e, Element.class, crsSpecimenTransformer, "getAreaClass"); if (returned != null) { areaClasses.add((AreaClass) returned); } } } assertEquals("01", 2, areaClasses.size()); String[] expectedAreaClasses = {"county", "continent"}; int n = 2; for (AreaClass areaClass: areaClasses) { assertTrue("0" + n++, Arrays.asList(expectedAreaClasses).contains(areaClass.toString())); } }
private AreaClass getAreaClass(Element elem) { String raw = val(elem, "abcd:AreaClass"); try { return areaClassNormalizer.map(raw); } catch (UnmappedValueException e) { if (logger.isDebugEnabled()) { debug(e.getMessage()); } return null; } }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private AreaClass getAreaClass(Element elem) { String raw = val(elem, "abcd:AreaClass"); try { return areaClassNormalizer.map(raw); } catch (UnmappedValueException e) { if (logger.isDebugEnabled()) { debug(e.getMessage()); } return null; } } }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private AreaClass getAreaClass(Element elem) { String raw = val(elem, "abcd:AreaClass"); try { return areaClassNormalizer.map(raw); } catch (UnmappedValueException e) { if (logger.isDebugEnabled()) { debug(e.getMessage()); } return null; } } CrsSpecimenTransformer(ETLStatistics stats); }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private AreaClass getAreaClass(Element elem) { String raw = val(elem, "abcd:AreaClass"); try { return areaClassNormalizer.map(raw); } catch (UnmappedValueException e) { if (logger.isDebugEnabled()) { debug(e.getMessage()); } return null; } } CrsSpecimenTransformer(ETLStatistics stats);  }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private AreaClass getAreaClass(Element elem) { String raw = val(elem, "abcd:AreaClass"); try { return areaClassNormalizer.map(raw); } catch (UnmappedValueException e) { if (logger.isDebugEnabled()) { debug(e.getMessage()); } return null; } } CrsSpecimenTransformer(ETLStatistics stats);   }