XMLParser implements MappingsSource<Document> { public MappingFileData read(Document document) { DozerBuilder builder = new DozerBuilder(beanContainer, destBeanCreator, propertyDescriptorFactory); Element theRoot = document.getDocumentElement(); NodeList nl = theRoot.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element) { Element ele = (Element)node; log.debug("name: {}", ele.getNodeName()); if (CONFIGURATION_ELEMENT.equals(ele.getNodeName())) { parseConfiguration(ele, builder); } else if (MAPPING_ELEMENT.equals(ele.getNodeName())) { parseMapping(ele, builder); } } } return builder.build(); } XMLParser(BeanContainer beanContainer, DestBeanCreator destBeanCreator, PropertyDescriptorFactory propertyDescriptorFactory); MappingFileData read(Document document);  }
@Test public void testParse() throws Exception { URL url = loader.getResource("mappings/testDozerBeanMapping.xml"); Document document = new XMLParserFactory(beanContainer).createParser().parse(url.openStream()); parser = new XMLParser(beanContainer, destBeanCreator, propertyDescriptorFactory); MappingFileData mappings = parser.read(document); assertNotNull(mappings); }
@Test public void testParseCustomConverterParam() throws Exception { URL url = loader.getResource("mappings/fieldCustomConverterParam.xml"); Document document = new XMLParserFactory(beanContainer).createParser().parse(url.openStream()); parser = new XMLParser(beanContainer, destBeanCreator, propertyDescriptorFactory); MappingFileData mappings = parser.read(document); assertNotNull("The mappings should not be null", mappings); List<ClassMap> mapping = mappings.getClassMaps(); assertNotNull("The list of mappings should not be null", mapping); assertEquals("There should be one mapping", 3, mapping.size()); ClassMap classMap = mapping.get(0); assertNotNull("The classmap should not be null", classMap); List<FieldMap> fieldMaps = classMap.getFieldMaps(); assertNotNull("The fieldmaps should not be null", fieldMaps); assertEquals("The fieldmap should have one mapping", 1, fieldMaps.size()); FieldMap fieldMap = fieldMaps.get(0); assertNotNull("The fieldmap should not be null", fieldMap); assertEquals("The customconverterparam should be correct", "CustomConverterParamTest", fieldMap.getCustomConverterParam()); }