FlowParser { public static List<Element> getChildrenByTagName(final Element element, final String tagName) { final List<Element> matches = new ArrayList<>(); final NodeList nodeList = element.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { final Node node = nodeList.item(i); if (!(node instanceof Element)) { continue; } final Element child = (Element) nodeList.item(i); if (child.getNodeName().equals(tagName)) { matches.add(child); } } return matches; }  Document parse(final File flowConfigurationFile); void writeFlow(final Document flowDocument, final Path flowXmlPath); static List<Element> getChildrenByTagName(final Element element, final String tagName);  }
@Test public void testGetChildrenByTagName() { FlowParser flowParser = new FlowParser(); Document parsedFlow = flowParser.parse(new File(TEST_FLOW_XML_PATH)); NodeList processors = parsedFlow.getElementsByTagName(FlowEnricher.PROCESSOR_TAG_NAME); for (int i = 0; i < processors.getLength(); i++) { Element processor = (Element) processors.item(i); List<Element> classElements = FlowParser.getChildrenByTagName(processor, "class"); Assert.assertEquals(1, classElements.size()); List<Element> propertyElements = FlowParser.getChildrenByTagName(processor, "property"); Assert.assertTrue(propertyElements.size() > 1); } }