ResolvedPom { public Map<GAKey,Artifact> getDirectDependencies() { return directDependencies; } ResolvedPom(File pom);  ResolvedPom(File pom, LocalRepository repo);  ResolvedPom(PomWrapper pom, LocalRepository repo); Artifact getGAV(); PomWrapper getPom(int index); Map<GAKey,Artifact> getDirectDependencies(); Collection<ResolvedPom> getImportedPoms(); String resolveProperties(String value);  }
@Test public void testResolveDependencies() throws Exception { ResolvedPom pom = new ResolvedPom(new File("../test-dependency-child/pom.xml")); Collection<Artifact> dependencies = pom.getDirectDependencies().values(); assertEquals("number of dependencies", 7, dependencies.size()); assertTrue("com.kdgregory.bcelx:bcelx:1.0.0", dependencies.contains(new Artifact("com.kdgregory.bcelx", "bcelx", "1.0.0"))); assertTrue("junit:junit:4.10", dependencies.contains(new Artifact("junit", "junit", "4.10"))); assertTrue("commons-lang:commons-lang:2.3", dependencies.contains(new Artifact("commons-lang", "commons-lang", "2.3"))); }
@Test public void testOptionalDependency() throws Exception { PomWrapper wrapper = new PomWrapper(ParseUtil.parseFromClasspath("OptionalDependency.xml")); ResolvedPom pom = new ResolvedPom(wrapper, new LocalRepository()); Artifact a1 = pom.getDirectDependencies().get(new GAKey("net.sf.practicalxml", "practicalxml")); assertFalse("practicalxml: default non-optional", a1.optional); Artifact a2 = pom.getDirectDependencies().get(new GAKey("net.sf.kdgcommons", "kdgcommons")); assertTrue("kdgcommons: explicit optional", a2.optional); Artifact a3 = pom.getDirectDependencies().get(new GAKey("junit", "junit")); assertFalse("junit: explicit non-optional", a3.optional); }