@Test(expected = MotechConfigurationException.class) public void shouldThrowMotechConfigurationExceptionWhenSaving() throws IOException { File file = Mockito.mock(File.class); when(file.getParentFile()).thenReturn(file); when(file.createNewFile()).thenThrow(new IOException()); ConfigPropertiesUtils.saveConfig(file, new Properties()); }
public static void saveConfig(File file, Properties properties) { try { file.getParentFile().mkdirs(); file.createNewFile(); try (Writer writer = new FileWriter(file)) { properties.store(writer, String.format("MOTECH %s properties.", file.getName())); } } catch (IOException e) { throw new MotechConfigurationException(String.format("Error saving %s properties to file.", file.getName()), e); } }
ConfigPropertiesUtils { public static void saveConfig(File file, Properties properties) { try { file.getParentFile().mkdirs(); file.createNewFile(); try (Writer writer = new FileWriter(file)) { properties.store(writer, String.format("MOTECH %s properties.", file.getName())); } } catch (IOException e) { throw new MotechConfigurationException(String.format("Error saving %s properties to file.", file.getName()), e); } } }
ConfigPropertiesUtils { public static void saveConfig(File file, Properties properties) { try { file.getParentFile().mkdirs(); file.createNewFile(); try (Writer writer = new FileWriter(file)) { properties.store(writer, String.format("MOTECH %s properties.", file.getName())); } } catch (IOException e) { throw new MotechConfigurationException(String.format("Error saving %s properties to file.", file.getName()), e); } } private  ConfigPropertiesUtils(); }
ConfigPropertiesUtils { public static void saveConfig(File file, Properties properties) { try { file.getParentFile().mkdirs(); file.createNewFile(); try (Writer writer = new FileWriter(file)) { properties.store(writer, String.format("MOTECH %s properties.", file.getName())); } } catch (IOException e) { throw new MotechConfigurationException(String.format("Error saving %s properties to file.", file.getName()), e); } } private  ConfigPropertiesUtils(); static Properties getPropertiesFromFile(File file); static void saveConfig(File file, Properties properties); static File getDefaultPropertiesFile(ConfigLocation.FileAccessType accessType, Iterable<ConfigLocation> configLocations,
                                                String fileName); static Properties getPropertiesFromSystemVarString(String string); static PropertiesConfiguration createPropertiesConfiguration(String basePath, String fileName); }
ConfigPropertiesUtils { public static void saveConfig(File file, Properties properties) { try { file.getParentFile().mkdirs(); file.createNewFile(); try (Writer writer = new FileWriter(file)) { properties.store(writer, String.format("MOTECH %s properties.", file.getName())); } } catch (IOException e) { throw new MotechConfigurationException(String.format("Error saving %s properties to file.", file.getName()), e); } } private  ConfigPropertiesUtils(); static Properties getPropertiesFromFile(File file); static void saveConfig(File file, Properties properties); static File getDefaultPropertiesFile(ConfigLocation.FileAccessType accessType, Iterable<ConfigLocation> configLocations,
                                                String fileName); static Properties getPropertiesFromSystemVarString(String string); static PropertiesConfiguration createPropertiesConfiguration(String basePath, String fileName);  }