PomWrapper { public Artifact getParent() { Element parentElem = selectElement(dom, PomPaths.PARENT); if (parentElem == null) return null; String parentGroupId = selectValue(dom, PomPaths.PARENT_GROUP); String parentArtifactId = selectValue(dom, PomPaths.PARENT_ARTIFACT); String parentVersion = selectValue(dom, PomPaths.PARENT_VERSION); return new Artifact(parentGroupId, parentArtifactId, parentVersion, "pom"); } PomWrapper(Document dom);  PomWrapper(File file); Document getDom(); void setDom(Document dom); String selectValue(String xpath); String selectValue(Node node, String xpath); Element selectElement(String xpath); Element selectElement(Node node, String xpath); List<Element> selectElements(String... paths); List<Element> selectElements(Node node, String... paths); Element selectOrCreateElement(String xpath); Element clear(String xpath); Map<String,String> getProperties(); String getProperty(String name); void setProperty(String name, String value); void deleteProperty(String name); String resolveProperties(String src); Artifact getGAV(); Artifact getParent(); @Override String toString(); List<Element> filterByGroupAndArtifact(List<Element> elements, String withGroupId, String withArtifactId);  }
@Test public void testGetParent() throws Exception { PomWrapper wrapper1 = new PomWrapper(ParseUtil.parseFromClasspath("PomWrapper1.xml")); Artifact gav1 = wrapper1.getParent(); assertNull("wrapper 1 has no parent", gav1); PomWrapper wrapper2 = new PomWrapper(ParseUtil.parseFromClasspath("PomWrapper4.xml")); Artifact gav2 = wrapper2.getParent(); assertEquals("parent groupId, wrapper 2", "com.example.pom", gav2.groupId); assertEquals("parent artifactId, wrapper 2", "wrapper1", gav2.artifactId); assertEquals("parent version, wrapper 2", "0.0.0-SNAPSHOT", gav2.version); assertEquals("parent packaging, wrapper 2", "pom", gav2.packaging); }