@Test public void testYamlPropertiesFactory() throws URISyntaxException, IOException { File test = new File(getClass().getResource("/").toURI()); String projectDir = test.getParentFile().getParentFile().getParent(); String resources = new File(projectDir, "src/test/resources").getAbsolutePath(); YamlPropertiesFactoryBean propertiesFactory = ThymeleafConfig.yamlPropertiesFactory(resources, singletonList("nginx")); Properties props = propertiesFactory.getObject(); assertThat(props.getProperty("app.name"), is("test")); }
static YamlPropertiesFactoryBean yamlPropertiesFactory(String path, List<String> names) throws IOException { YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); FileSystemResource[] resources = Files.find(Paths.get(path, "properties"), MAX_DEPTH, (p, attr) -> { String filename = getFilename(cleanPath(p.toFile().getAbsolutePath())); return isYaml(filename) && isGlobalOrMatchesTemplatesNames(filename, names); }) .map(Path::toFile) .peek(f -> log.debug("Found resource: {}.", f.getAbsolutePath())) .map(FileSystemResource::new) .toArray(size -> new FileSystemResource[size]); factory.setResources(resources); return factory; }
ThymeleafConfig { static YamlPropertiesFactoryBean yamlPropertiesFactory(String path, List<String> names) throws IOException { YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); FileSystemResource[] resources = Files.find(Paths.get(path, "properties"), MAX_DEPTH, (p, attr) -> { String filename = getFilename(cleanPath(p.toFile().getAbsolutePath())); return isYaml(filename) && isGlobalOrMatchesTemplatesNames(filename, names); }) .map(Path::toFile) .peek(f -> log.debug("Found resource: {}.", f.getAbsolutePath())) .map(FileSystemResource::new) .toArray(size -> new FileSystemResource[size]); factory.setResources(resources); return factory; } }
ThymeleafConfig { static YamlPropertiesFactoryBean yamlPropertiesFactory(String path, List<String> names) throws IOException { YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); FileSystemResource[] resources = Files.find(Paths.get(path, "properties"), MAX_DEPTH, (p, attr) -> { String filename = getFilename(cleanPath(p.toFile().getAbsolutePath())); return isYaml(filename) && isGlobalOrMatchesTemplatesNames(filename, names); }) .map(Path::toFile) .peek(f -> log.debug("Found resource: {}.", f.getAbsolutePath())) .map(FileSystemResource::new) .toArray(size -> new FileSystemResource[size]); factory.setResources(resources); return factory; }  }
ThymeleafConfig { static YamlPropertiesFactoryBean yamlPropertiesFactory(String path, List<String> names) throws IOException { YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); FileSystemResource[] resources = Files.find(Paths.get(path, "properties"), MAX_DEPTH, (p, attr) -> { String filename = getFilename(cleanPath(p.toFile().getAbsolutePath())); return isYaml(filename) && isGlobalOrMatchesTemplatesNames(filename, names); }) .map(Path::toFile) .peek(f -> log.debug("Found resource: {}.", f.getAbsolutePath())) .map(FileSystemResource::new) .toArray(size -> new FileSystemResource[size]); factory.setResources(resources); return factory; }   }
ThymeleafConfig { static YamlPropertiesFactoryBean yamlPropertiesFactory(String path, List<String> names) throws IOException { YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); FileSystemResource[] resources = Files.find(Paths.get(path, "properties"), MAX_DEPTH, (p, attr) -> { String filename = getFilename(cleanPath(p.toFile().getAbsolutePath())); return isYaml(filename) && isGlobalOrMatchesTemplatesNames(filename, names); }) .map(Path::toFile) .peek(f -> log.debug("Found resource: {}.", f.getAbsolutePath())) .map(FileSystemResource::new) .toArray(size -> new FileSystemResource[size]); factory.setResources(resources); return factory; }   static final int MAX_DEPTH; }