### Question:
PackageNameSearchProvider { public PackageNameSearch newTopLevelPackageNamesSearch( final POM pom ) { return new PackageNameSearch( pom ); } PackageNameSearchProvider(); @Inject  PackageNameSearchProvider( final DependencyService dependencyService ); PackageNameSearch newTopLevelPackageNamesSearch( final POM pom );  }### Answer:
@Test public void testLoadTopLevelDependencies() throws Exception { POM pom = new POM( new GAV( "artifactID", "groupID", "version" ) ); pom.getDependencies().add( getDependency( "drools-core", "org.drools", "6.3.0" ) ); pom.getDependencies().add( getDependency( "junit", "org.junit", "4.11" ) ); HashMap<Dependency, Set<String>> map = setUpDependencyService( pom ); map.put( getGAV( "drools-core", "org.drools", "6.3.0" ), toSet( "org.drools.a", "org.drools.b", "org.drools.c" ) ); map.put( getGAV( "junit", "org.junit", "4.11" ), toSet( "junit.a", "junit.b" ) ); Set<String> packageNames = packageNameSearchProvider.newTopLevelPackageNamesSearch( pom ).search(); assertEquals( 5, packageNames.size() ); assertTrue( packageNames.contains( "org.drools.a" ) ); assertTrue( packageNames.contains( "org.drools.b" ) ); assertTrue( packageNames.contains( "org.drools.c" ) ); assertTrue( packageNames.contains( "junit.a" ) ); assertTrue( packageNames.contains( "junit.b" ) ); }
@Test public void testLoadTopLevelDependenciesWhenIncompleteDependenciesInPOM() throws Exception { POM pom = new POM( new GAV( "artifactID", "groupID", "version" ) ); pom.getDependencies().add( getDependency( "drools-core", "org.drools", null ) ); pom.getDependencies().add( getDependency( null, null, null ) ); HashMap<Dependency, Set<String>> map = setUpDependencyService( pom ); map.put( getGAV( "drools-core", "org.drools", "6.3.0" ), toSet( "org.drools.a", "org.drools.b", "org.drools.c" ) ); Set<String> packageNames = packageNameSearchProvider.newTopLevelPackageNamesSearch( pom ).search(); assertEquals( 3, packageNames.size() ); assertTrue( packageNames.contains( "org.drools.a" ) ); assertTrue( packageNames.contains( "org.drools.b" ) ); assertTrue( packageNames.contains( "org.drools.c" ) ); }