@Test public void dependencyScanWhenEnablePreviewFalse() { String[] srcLocation = new String[]{"srcLocation1", "srcLocation2"}; String[] testLocation = new String[]{"testLocation1", "testLocation2"}; String[] dependencies = new String[]{"dependency1", "dependency2"}; Set<String> allLocations = new HashSet<>(); allLocations.addAll(Stream.of(srcLocation).map(location -> new File(location).getAbsolutePath()).collect(Collectors.toSet())); allLocations.addAll(Stream.of(testLocation).map(location -> new File(location).getAbsolutePath()).collect(Collectors.toSet())); Context context = new Context("appId", srcLocation, testLocation, dependencies, "", new ChangeScopeImpl(), null, null, false); Map<String, Set<File>> scanResult = directoryScanner.scan((location, files) -> { }, context, true); assertEquals(4, scanResult.size()); allLocations.forEach(location -> { assertTrue(scanResult.containsKey(location)); assertFalse(scanResult.get(location).isEmpty()); }); }
@Override public Map<String, Set<File>> scan(ThrowingBiConsumer<String, Set<File>> consumer, Context context, boolean scanDependencies) { long start = System.nanoTime(); logger.debug("[{}] {} Start traversing locations", Thread.currentThread().getName(), scannerName); List<String> allLocations = new ArrayList<>(); allLocations.addAll(context.getTestLocations()); allLocations.addAll(context.getSrcLocations()); Map<String, Set<File>> locationFiles = new HashMap<>(); Collection<Map<String, Set<File>>> locationToFilesFound = getDirectoryFinder(consumer).execute(allLocations); locationToFilesFound.forEach(map -> { map.forEach(locationFiles::put); }); logger.debug("[{}] {} Finished traversing locations in {} milliseconds", Thread.currentThread().getName(), scannerName, elapsedTime(start)); if (context.isEnablePreview() && scanDependencies) { locationFiles.put(DEPENDENCY_JARS, context.getDependencyJars().stream() .map(File::new).collect(Collectors.toSet())); } return locationFiles; }
DirectoryScanner implements LocationScanner { @Override public Map<String, Set<File>> scan(ThrowingBiConsumer<String, Set<File>> consumer, Context context, boolean scanDependencies) { long start = System.nanoTime(); logger.debug("[{}] {} Start traversing locations", Thread.currentThread().getName(), scannerName); List<String> allLocations = new ArrayList<>(); allLocations.addAll(context.getTestLocations()); allLocations.addAll(context.getSrcLocations()); Map<String, Set<File>> locationFiles = new HashMap<>(); Collection<Map<String, Set<File>>> locationToFilesFound = getDirectoryFinder(consumer).execute(allLocations); locationToFilesFound.forEach(map -> { map.forEach(locationFiles::put); }); logger.debug("[{}] {} Finished traversing locations in {} milliseconds", Thread.currentThread().getName(), scannerName, elapsedTime(start)); if (context.isEnablePreview() && scanDependencies) { locationFiles.put(DEPENDENCY_JARS, context.getDependencyJars().stream() .map(File::new).collect(Collectors.toSet())); } return locationFiles; } }
DirectoryScanner implements LocationScanner { @Override public Map<String, Set<File>> scan(ThrowingBiConsumer<String, Set<File>> consumer, Context context, boolean scanDependencies) { long start = System.nanoTime(); logger.debug("[{}] {} Start traversing locations", Thread.currentThread().getName(), scannerName); List<String> allLocations = new ArrayList<>(); allLocations.addAll(context.getTestLocations()); allLocations.addAll(context.getSrcLocations()); Map<String, Set<File>> locationFiles = new HashMap<>(); Collection<Map<String, Set<File>>> locationToFilesFound = getDirectoryFinder(consumer).execute(allLocations); locationToFilesFound.forEach(map -> { map.forEach(locationFiles::put); }); logger.debug("[{}] {} Finished traversing locations in {} milliseconds", Thread.currentThread().getName(), scannerName, elapsedTime(start)); if (context.isEnablePreview() && scanDependencies) { locationFiles.put(DEPENDENCY_JARS, context.getDependencyJars().stream() .map(File::new).collect(Collectors.toSet())); } return locationFiles; } DirectoryScanner(String scannerName); }
DirectoryScanner implements LocationScanner { @Override public Map<String, Set<File>> scan(ThrowingBiConsumer<String, Set<File>> consumer, Context context, boolean scanDependencies) { long start = System.nanoTime(); logger.debug("[{}] {} Start traversing locations", Thread.currentThread().getName(), scannerName); List<String> allLocations = new ArrayList<>(); allLocations.addAll(context.getTestLocations()); allLocations.addAll(context.getSrcLocations()); Map<String, Set<File>> locationFiles = new HashMap<>(); Collection<Map<String, Set<File>>> locationToFilesFound = getDirectoryFinder(consumer).execute(allLocations); locationToFilesFound.forEach(map -> { map.forEach(locationFiles::put); }); logger.debug("[{}] {} Finished traversing locations in {} milliseconds", Thread.currentThread().getName(), scannerName, elapsedTime(start)); if (context.isEnablePreview() && scanDependencies) { locationFiles.put(DEPENDENCY_JARS, context.getDependencyJars().stream() .map(File::new).collect(Collectors.toSet())); } return locationFiles; } DirectoryScanner(String scannerName); @Override Map<String, Set<File>> scan(ThrowingBiConsumer<String, Set<File>> consumer, Context context, boolean scanDependencies); }
DirectoryScanner implements LocationScanner { @Override public Map<String, Set<File>> scan(ThrowingBiConsumer<String, Set<File>> consumer, Context context, boolean scanDependencies) { long start = System.nanoTime(); logger.debug("[{}] {} Start traversing locations", Thread.currentThread().getName(), scannerName); List<String> allLocations = new ArrayList<>(); allLocations.addAll(context.getTestLocations()); allLocations.addAll(context.getSrcLocations()); Map<String, Set<File>> locationFiles = new HashMap<>(); Collection<Map<String, Set<File>>> locationToFilesFound = getDirectoryFinder(consumer).execute(allLocations); locationToFilesFound.forEach(map -> { map.forEach(locationFiles::put); }); logger.debug("[{}] {} Finished traversing locations in {} milliseconds", Thread.currentThread().getName(), scannerName, elapsedTime(start)); if (context.isEnablePreview() && scanDependencies) { locationFiles.put(DEPENDENCY_JARS, context.getDependencyJars().stream() .map(File::new).collect(Collectors.toSet())); } return locationFiles; } DirectoryScanner(String scannerName); @Override Map<String, Set<File>> scan(ThrowingBiConsumer<String, Set<File>> consumer, Context context, boolean scanDependencies);  }