Environment { protected void save() { if (configFile != null) { try (FileWriter writer = new FileWriter(configFile)) { this.getConfiguration().write(writer); } catch (Exception e) { LOGGER.warn("Error saving the config file: {}", e.getMessage(), e); } } } private  Environment(); File getConfigDirectory();  }
@Test public void testSave() { YAMLConfiguration configuration = Environment.getInstance().getConfiguration(); configuration.setProperty("ui.features.foo", false); configuration.setProperty("ui.features.bar", true); configuration.setProperty("ui.endpoints.quaz", ""); Environment.getInstance().save(); Environment.getInstance().setConfiguration(null); configuration = Environment.getInstance().getConfiguration(); assertFalse(configuration.getBoolean("ui.features.foo")); assertTrue(configuration.getBoolean("ui.features.bar")); assertEquals(configuration.getString("ui.endpoints.quaz"), ""); }