Close #449 Rename NewSetting class to Settings :)
This commit is contained in:
@@ -23,7 +23,7 @@ import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Test for {@link NewSetting} and the project's config.yml,
|
||||
* Test for {@link Settings} and the project's config.yml,
|
||||
* verifying that no settings are missing from the file.
|
||||
*/
|
||||
public class ConfigFileConsistencyTest {
|
||||
|
||||
+8
-8
@@ -27,9 +27,9 @@ import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* Integration test for {@link NewSetting}.
|
||||
* Integration test for {@link Settings}.
|
||||
*/
|
||||
public class NewSettingIntegrationTest {
|
||||
public class SettingsIntegrationTest {
|
||||
|
||||
/** File name of the sample config including all {@link TestConfiguration} values. */
|
||||
private static final String COMPLETE_FILE = TestHelper.PROJECT_ROOT + "settings/config-sample-values.yml";
|
||||
@@ -63,7 +63,7 @@ public class NewSettingIntegrationTest {
|
||||
File newFile = temporaryFolder.newFile();
|
||||
|
||||
// when / then
|
||||
NewSetting settings = new NewSetting(configuration, newFile, testPluginFolder, propertyMap,
|
||||
Settings settings = new Settings(configuration, newFile, testPluginFolder, propertyMap,
|
||||
checkAllPropertiesPresent());
|
||||
Map<Property<?>, Object> expectedValues = ImmutableMap.<Property<?>, Object>builder()
|
||||
.put(TestConfiguration.DURATION_IN_SECONDS, 22)
|
||||
@@ -90,13 +90,13 @@ public class NewSettingIntegrationTest {
|
||||
File file = copyFileFromResources(INCOMPLETE_FILE);
|
||||
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(file);
|
||||
// Expectation: File is rewritten to since it does not have all configurations
|
||||
new NewSetting(configuration, file, testPluginFolder, propertyMap, checkAllPropertiesPresent());
|
||||
new Settings(configuration, file, testPluginFolder, propertyMap, checkAllPropertiesPresent());
|
||||
|
||||
// Load the settings again -> checks that what we wrote can be loaded again
|
||||
configuration = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
// then
|
||||
NewSetting settings = new NewSetting(configuration, file, testPluginFolder, propertyMap,
|
||||
Settings settings = new Settings(configuration, file, testPluginFolder, propertyMap,
|
||||
checkAllPropertiesPresent());
|
||||
Map<Property<?>, Object> expectedValues = ImmutableMap.<Property<?>, Object>builder()
|
||||
.put(TestConfiguration.DURATION_IN_SECONDS, 22)
|
||||
@@ -133,14 +133,14 @@ public class NewSettingIntegrationTest {
|
||||
}
|
||||
|
||||
// when
|
||||
new NewSetting(configuration, file, testPluginFolder, propertyMap, checkAllPropertiesPresent());
|
||||
new Settings(configuration, file, testPluginFolder, propertyMap, checkAllPropertiesPresent());
|
||||
// reload the file as settings should have been rewritten
|
||||
configuration = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
// then
|
||||
// assert that we won't rewrite the settings again! One rewrite should produce a valid, complete configuration
|
||||
File unusedFile = new File("config-difficult-values.unused.yml");
|
||||
NewSetting settings = new NewSetting(configuration, unusedFile, testPluginFolder, propertyMap,
|
||||
Settings settings = new Settings(configuration, unusedFile, testPluginFolder, propertyMap,
|
||||
checkAllPropertiesPresent());
|
||||
assertThat(unusedFile.exists(), equalTo(false));
|
||||
assertThat(configuration.contains(TestConfiguration.DUST_LEVEL.getPath()), equalTo(true));
|
||||
@@ -171,7 +171,7 @@ public class NewSettingIntegrationTest {
|
||||
// given
|
||||
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(temporaryFolder.newFile());
|
||||
File fullConfigFile = copyFileFromResources(COMPLETE_FILE);
|
||||
NewSetting settings = new NewSetting(configuration, fullConfigFile, testPluginFolder, propertyMap,
|
||||
Settings settings = new Settings(configuration, fullConfigFile, testPluginFolder, propertyMap,
|
||||
TestSettingsMigrationServices.alwaysFulfilled());
|
||||
|
||||
// when
|
||||
+10
-10
@@ -38,9 +38,9 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link NewSetting}.
|
||||
* Unit tests for {@link Settings}.
|
||||
*/
|
||||
public class NewSettingTest {
|
||||
public class SettingsTest {
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
@@ -71,7 +71,7 @@ public class NewSettingTest {
|
||||
setReturnValue(configuration, TestConfiguration.SYSTEM_NAME, "myTestSys");
|
||||
|
||||
// when / then
|
||||
NewSetting settings = new NewSetting(configuration, null, null, null, null);
|
||||
Settings settings = new Settings(configuration, null, null, null, null);
|
||||
|
||||
assertThat(settings.getProperty(TestConfiguration.VERSION_NUMBER), equalTo(20));
|
||||
assertThat(settings.getProperty(TestConfiguration.SKIP_BORING_FEATURES), equalTo(true));
|
||||
@@ -87,7 +87,7 @@ public class NewSettingTest {
|
||||
public void shouldReturnDefaultFile() throws IOException {
|
||||
// given
|
||||
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
||||
NewSetting settings = new NewSetting(configuration, null, null, null, null);
|
||||
Settings settings = new Settings(configuration, null, null, null, null);
|
||||
|
||||
// when
|
||||
String defaultFile = settings.getDefaultMessagesFile();
|
||||
@@ -103,7 +103,7 @@ public class NewSettingTest {
|
||||
public void shouldSetProperty() {
|
||||
// given
|
||||
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
||||
NewSetting settings = new NewSetting(configuration, null, null, null, null);
|
||||
Settings settings = new Settings(configuration, null, null, null, null);
|
||||
|
||||
// when
|
||||
settings.setProperty(TestConfiguration.DUST_LEVEL, -4);
|
||||
@@ -123,7 +123,7 @@ public class NewSettingTest {
|
||||
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
||||
given(configuration.contains(anyString())).willReturn(true);
|
||||
setReturnValue(configuration, MESSAGES_LANGUAGE, languageCode);
|
||||
NewSetting settings = new NewSetting(configuration, null, testPluginFolder,
|
||||
Settings settings = new Settings(configuration, null, testPluginFolder,
|
||||
TestConfiguration.generatePropertyMap(), TestSettingsMigrationServices.alwaysFulfilled());
|
||||
|
||||
// when
|
||||
@@ -140,7 +140,7 @@ public class NewSettingTest {
|
||||
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
||||
given(configuration.contains(anyString())).willReturn(true);
|
||||
setReturnValue(configuration, MESSAGES_LANGUAGE, "doesntexist");
|
||||
NewSetting settings = new NewSetting(configuration, null, testPluginFolder,
|
||||
Settings settings = new Settings(configuration, null, testPluginFolder,
|
||||
TestConfiguration.generatePropertyMap(), TestSettingsMigrationServices.alwaysFulfilled());
|
||||
|
||||
// when
|
||||
@@ -161,7 +161,7 @@ public class NewSettingTest {
|
||||
|
||||
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
||||
setReturnValue(configuration, RegistrationSettings.USE_WELCOME_MESSAGE, true);
|
||||
NewSetting settings = new NewSetting(configuration, null, testPluginFolder,
|
||||
Settings settings = new Settings(configuration, null, testPluginFolder,
|
||||
TestConfiguration.generatePropertyMap(), TestSettingsMigrationServices.alwaysFulfilled());
|
||||
|
||||
// when
|
||||
@@ -182,7 +182,7 @@ public class NewSettingTest {
|
||||
Files.write(emailFile.toPath(), emailMessage.getBytes());
|
||||
|
||||
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
||||
NewSetting settings = new NewSetting(configuration, null, testPluginFolder,
|
||||
Settings settings = new Settings(configuration, null, testPluginFolder,
|
||||
TestConfiguration.generatePropertyMap(), TestSettingsMigrationServices.alwaysFulfilled());
|
||||
|
||||
// when
|
||||
@@ -207,7 +207,7 @@ public class NewSettingTest {
|
||||
}
|
||||
}
|
||||
|
||||
private static void assertDefaultValue(Property<?> property, NewSetting setting) {
|
||||
private static void assertDefaultValue(Property<?> property, Settings setting) {
|
||||
assertThat(property.getPath() + " has default value",
|
||||
setting.getProperty(property).equals(property.getDefaultValue()), equalTo(true));
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class SpawnLoaderTest {
|
||||
private SpawnLoader spawnLoader;
|
||||
|
||||
@Mock
|
||||
private NewSetting settings;
|
||||
private Settings settings;
|
||||
|
||||
@Mock
|
||||
private DataSource dataSource;
|
||||
|
||||
Reference in New Issue
Block a user