PomWrapper { public Artifact getGAV() { return new Artifact(groupId, artifactId, version, packaging); } 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 testGetGAV() throws Exception { PomWrapper wrapper1 = new PomWrapper(ParseUtil.parseFromClasspath("PomWrapper1.xml")); Artifact gav1 = wrapper1.getGAV(); assertEquals("groupId, wrapper 1", "com.example.pom", gav1.groupId); assertEquals("artifactId, wrapper 1", "wrapper1", gav1.artifactId); assertEquals("version, wrapper 1", "0.0.0-SNAPSHOT", gav1.version); assertEquals("packaging, wrapper 1", "jar", gav1.packaging); PomWrapper wrapper2 = new PomWrapper(ParseUtil.parseFromClasspath("PomWrapper4.xml")); Artifact gav2 = wrapper2.getGAV(); assertEquals("groupId, wrapper 2", "com.example.pom", gav2.groupId); assertEquals("artifactId, wrapper 2", "wrapper4", gav2.artifactId); assertEquals("version, wrapper 2", "0.0.0-SNAPSHOT", gav2.version); assertEquals("packaging, wrapper 2", "jar", gav2.packaging); }
@Test public void testPomWithoutNamespace() throws Exception { PomWrapper wrapper = new PomWrapper(ParseUtil.parseFromClasspath("PomWrapper6.xml")); Artifact gav = wrapper.getGAV(); assertEquals("groupId", "com.example.pom", gav.groupId); assertEquals("artifactId", "wrapper6", gav.artifactId); assertEquals("version", "0.0.0-SNAPSHOT", gav.version); assertEquals("packaging", "jar", gav.packaging); }