DefinitionFinder { public Properties find(String definitionName) { String fileName = definitionName + ".properties"; for (File dir : searchedDirs) { File file = FileUtils.getFile(dir, fileName); if (file.exists()) { return loadFromFile(file, new Properties()); } } Properties loadFromClasspath = loadFromClasspath(fileName); if (loadFromClasspath != null) { return loadFromClasspath; } throw new IllegalArgumentException("Could not find definition " + definitionName); } DefinitionFinder(List<File> searchedDirs); Properties find(String definitionName);  }
@Test public void fromClassPath() { DefinitionFinder definitionFinder = new DefinitionFinder(ImmutableList.<File> of()); Properties find = definitionFinder.find("launcher_icon"); assertThat(find).hasSize(4).includes( entry("rezenerator.val.mdpi", "48"), entry("rezenerator.def.hdpi", "xxhdpi.divide(2)"), entry("rezenerator.def.xhdpi", "mdpi.multiply(2)"), entry("rezenerator.def.xxhdpi", "mdpi.multiply(3)")); }
@Test public void fromFileAndClasspath() { DefinitionFinder definitionFinder = new DefinitionFinder(of(new File("src/test/resources/definitions"))); Properties find = definitionFinder.find("test"); assertThat(find).hasSize(4).includes( entry("rezenerator.val.mdpi", "42"), entry("rezenerator.def.hdpi", "xxhdpi.divide(2)"), entry("rezenerator.def.xhdpi", "mdpi.multiply(2)"), entry("rezenerator.def.xxhdpi", "mdpi.multiply(3)")); }