use of ch.jalu.configme.configurationdata.ConfigurationData in project AuthMeReloaded by AuthMe.
the class SettingsProvider method get.
/**
* Loads the plugin's settings.
*
* @return the settings instance, or null if it could not be constructed
*/
@Override
public Settings get() {
File configFile = new File(dataFolder, "config.yml");
if (!configFile.exists()) {
FileUtils.create(configFile);
}
PropertyResource resource = new YamlFileResource(configFile);
ConfigurationData configurationData = AuthMeSettingsRetriever.buildConfigurationData();
return new Settings(dataFolder, resource, migrationService, configurationData);
}
use of ch.jalu.configme.configurationdata.ConfigurationData in project AuthMeReloaded by AuthMe.
the class AuthMeSettingsRetrieverTest method shouldReturnAllProperties.
@Test
public void shouldReturnAllProperties() {
// given / when
ConfigurationData configurationData = AuthMeSettingsRetriever.buildConfigurationData();
// then
// Note ljacqu 20161123: Check that the number of properties returned corresponds to what we expect with
// an error margin of 10: this prevents us from having to adjust the test every time the config is changed.
// If this test fails, replace the first argument in closeTo() with the new number of properties
assertThat((double) configurationData.getProperties().size(), closeTo(160, 10));
}
use of ch.jalu.configme.configurationdata.ConfigurationData in project AuthMeReloaded by AuthMe.
the class SettingsClassConsistencyTest method shouldHaveAllClassesInConfigurationData.
/**
* Checks that {@link AuthMeSettingsRetriever} returns a ConfigurationData with all
* available SettingsHolder classes.
*/
@Test
public void shouldHaveAllClassesInConfigurationData() {
// given
long totalProperties = classes.stream().map(Class::getDeclaredFields).flatMap(Arrays::stream).filter(field -> Property.class.isAssignableFrom(field.getType())).count();
// when
ConfigurationData configData = AuthMeSettingsRetriever.buildConfigurationData();
// then
assertThat("ConfigurationData should have " + totalProperties + " properties (as found manually)", configData.getProperties(), hasSize((int) totalProperties));
}
Aggregations