FormatterProperties { public static FormatterProperties from(File... files) throws IllegalArgumentException { Objects.requireNonNull(files); return from(Arrays.asList(files)); } private  FormatterProperties(); static FormatterProperties from(File... files); static FormatterProperties from(Iterable<File> files); Properties getProperties();  }
@Test public void invalidPropertyFiles() throws IOException { for (String settingsResource : INVALID_SETTINGS_RESOURCES) { File settingsFile = createTestFile(settingsResource); boolean exceptionCaught = false; try { FormatterProperties.from(settingsFile); } catch (IllegalArgumentException ex) { exceptionCaught = true; assertThat(ex.getMessage()) .as("IllegalArgumentException does not contain absolute path of file '%s'", settingsFile.getName()) .contains(settingsFile.getAbsolutePath()); } assertThat(exceptionCaught) .as("No IllegalArgumentException thrown when parsing '%s'", settingsFile.getName()) .isTrue(); } }
@Test public void nonExistingFile() throws IOException { String filePath = FileSignature.pathUnixToNative("does/not/exist.properties"); try { FormatterProperties.from(new File(filePath)); Assertions.fail("Should have thrown"); } catch (IllegalArgumentException ex) { assertThat(ex.getMessage()) .as("IllegalArgumentException does not contain path of non-existing file.").contains(filePath); } }
@Test public void differntPropertyFileTypes() throws IOException { for (String settingsResource : VALID_SETTINGS_RESOURCES) { File settingsFile = createTestFile(settingsResource); FormatterProperties preferences = FormatterProperties.from(settingsFile); assertFor(preferences) .containsSpecificValuesOf(settingsFile) .containsCommonValueOf(settingsFile); } }