@Test public void testNullConfigurationsDir() throws Exception { ObjectMapper mapper = fixSerializationHelper(fixtures); ConfigurationIntake configurationIntake = new ConfigurationIntake(mapper); List<String> configurations = configurationIntake.getAllConfigurationsFromDisk(null); assertThat(configurations, empty()); }
List<String> getAllConfigurationsFromDisk(String dir) throws IOException { if (isNull(dir)) { logger.warn("Null configuration dir passed, returning empty configuration list"); return Collections.emptyList(); } try (DirectoryStream<Path> configurationsDirectory = Files.newDirectoryStream(Paths.get(dir))) { return StreamSupport.stream(configurationsDirectory.spliterator(), true) .filter(ConfigurationIntake::isJsonFile) .map(Path::toAbsolutePath) .map(Path::toString) .collect(Collectors.toList()); } }
ConfigurationIntake { List<String> getAllConfigurationsFromDisk(String dir) throws IOException { if (isNull(dir)) { logger.warn("Null configuration dir passed, returning empty configuration list"); return Collections.emptyList(); } try (DirectoryStream<Path> configurationsDirectory = Files.newDirectoryStream(Paths.get(dir))) { return StreamSupport.stream(configurationsDirectory.spliterator(), true) .filter(ConfigurationIntake::isJsonFile) .map(Path::toAbsolutePath) .map(Path::toString) .collect(Collectors.toList()); } } }
ConfigurationIntake { List<String> getAllConfigurationsFromDisk(String dir) throws IOException { if (isNull(dir)) { logger.warn("Null configuration dir passed, returning empty configuration list"); return Collections.emptyList(); } try (DirectoryStream<Path> configurationsDirectory = Files.newDirectoryStream(Paths.get(dir))) { return StreamSupport.stream(configurationsDirectory.spliterator(), true) .filter(ConfigurationIntake::isJsonFile) .map(Path::toAbsolutePath) .map(Path::toString) .collect(Collectors.toList()); } } @Inject  ConfigurationIntake(ObjectMapper mapper); }
ConfigurationIntake { List<String> getAllConfigurationsFromDisk(String dir) throws IOException { if (isNull(dir)) { logger.warn("Null configuration dir passed, returning empty configuration list"); return Collections.emptyList(); } try (DirectoryStream<Path> configurationsDirectory = Files.newDirectoryStream(Paths.get(dir))) { return StreamSupport.stream(configurationsDirectory.spliterator(), true) .filter(ConfigurationIntake::isJsonFile) .map(Path::toAbsolutePath) .map(Path::toString) .collect(Collectors.toList()); } } @Inject  ConfigurationIntake(ObjectMapper mapper); Set<Configuration> parseAll(String configurationsPath); void throwRuntimeExceptionOnErrors(); }
ConfigurationIntake { List<String> getAllConfigurationsFromDisk(String dir) throws IOException { if (isNull(dir)) { logger.warn("Null configuration dir passed, returning empty configuration list"); return Collections.emptyList(); } try (DirectoryStream<Path> configurationsDirectory = Files.newDirectoryStream(Paths.get(dir))) { return StreamSupport.stream(configurationsDirectory.spliterator(), true) .filter(ConfigurationIntake::isJsonFile) .map(Path::toAbsolutePath) .map(Path::toString) .collect(Collectors.toList()); } } @Inject  ConfigurationIntake(ObjectMapper mapper); Set<Configuration> parseAll(String configurationsPath); void throwRuntimeExceptionOnErrors(); static final String CONFIGURATIONS_READ_ERROR; }