### Question:
MetadataReader { public List<PackageMetadata> readMetadata( List<String> metadataLocations ) { Map<Path, Future<PackageMetadata>> futures = new LinkedHashMap<>(); for ( String pathString : metadataLocations ) { Path path = Paths.get( pathString ); if ( Files.isDirectory( path ) ) { String flist[] = path.toFile().list(); if ( flist != null ) { Arrays.sort( flist ); for ( String fragFilename : flist ) { Path xmlPath = path.resolve( fragFilename ); futures.put( xmlPath, executor.submit( ( ) -> readMetadata( xmlPath ) ) ); } } } else { futures.put( path, executor.submit( ( ) -> readMetadata( path ) ) ); } } try { List<PackageMetadata> result = new ArrayList<>(); for ( Entry<Path, Future<PackageMetadata>> entry : futures.entrySet() ) { Path path = entry.getKey(); Future<PackageMetadata> future = entry.getValue(); try { PackageMetadata metadata = future.get(); result.add( metadata ); if ( logger.isDebugEnabled() ) { logger.debug( "Adding metadata from file {}", path ); for ( ArtifactMetadata artifact : metadata.getArtifacts() ) logger.debug( "Added metadata for {}", artifact ); } } catch ( ExecutionException e ) { logger.debug( "Skipping metadata file {}", path, e ); } } return result; } catch ( InterruptedException e ) { logger.debug( "Metadata reader thread was interrupted" ); throw new RuntimeException( e ); } } MetadataReader(); List<PackageMetadata> readMetadata( List<String> metadataLocations );  }### Answer:
@Test public void testReadingEmptyList() throws Exception { List<String> pathList = Collections.<String> emptyList(); List<PackageMetadata> list = reader.readMetadata( pathList ); assertNotNull( list ); assertTrue( list.isEmpty() ); }
@Test public void testReadingEmptyDirectory() throws Exception { Path dir = Files.createTempDirectory( "xmvn-test" ); List<String> pathList = Collections.singletonList( dir.toString() ); List<PackageMetadata> list = reader.readMetadata( pathList ); assertNotNull( list ); assertTrue( list.isEmpty() ); }
@Test public void testSimpleMetadata() { List<String> pathList = Collections.singletonList( "src/test/resources/simple.xml" ); List<PackageMetadata> list = reader.readMetadata( pathList ); assertNotNull( list ); assertEquals( 1, list.size() ); PackageMetadata pm = list.iterator().next(); Iterator<ArtifactMetadata> iter = pm.getArtifacts().iterator(); assertTrue( iter.hasNext() ); ArtifactMetadata am1 = iter.next(); assertNotNull( am1 ); assertEquals( "org.codehaus.plexus", am1.getGroupId() ); assertEquals( "plexus-ant-factory", am1.getArtifactId() ); assertEquals( "jar", am1.getExtension() ); assertEquals( "", am1.getClassifier() ); assertEquals( "1.0", am1.getVersion() ); assertEquals( "ns", am1.getNamespace() ); assertEquals( "/usr/share/java/plexus/ant-factory-1.0.jar", am1.getPath() ); List<String> compatVersions1 = am1.getCompatVersions(); assertEquals( 1, compatVersions1.size() ); assertEquals( "1.0", compatVersions1.iterator().next() ); assertTrue( iter.hasNext() ); ArtifactMetadata am2 = iter.next(); assertNotNull( am2 ); assertEquals( "org.codehaus.plexus", am2.getGroupId() ); assertEquals( "plexus-ant-factory", am2.getArtifactId() ); assertEquals( "pom", am2.getExtension() ); assertEquals( "", am2.getClassifier() ); assertEquals( "1.0", am2.getVersion() ); assertEquals( "ns", am2.getNamespace() ); assertEquals( "/usr/share/maven-poms/JPP.plexus-ant-factory-1.0.pom", am2.getPath() ); List<String> compatVersions2 = am2.getCompatVersions(); assertEquals( 1, compatVersions2.size() ); assertEquals( "1.0", compatVersions2.iterator().next() ); }