Search in sources :

Example 1 with YamlFile

use of com.alessiodp.core.common.addons.external.simpleyaml.configuration.file.YamlFile in project Parties by AlessioDP.

the class BungeeConfigurationTest method testConfiguration.

private void testConfiguration(ConfigurationFile configurationFile, List<String> skipPaths) throws IllegalAccessException {
    Field[] fields = configurationFile.getClass().getFields();
    // Initialize YAML
    YamlFile yf = YamlFile.loadConfiguration(new InputStreamReader(getClass().getResourceAsStream("/" + configurationFile.getResourceName())));
    // Check fields
    for (Field f : fields) {
        ConfigOption co = f.getAnnotation(ConfigOption.class);
        if (co != null && !skippablePath(co.path(), skipPaths)) {
            Object value = yf.get(co.path());
            assertNotNull(value, "The " + configurationFile.getClass().getSimpleName() + " path '" + co.path() + "' is null.");
            f.set(null, value);
        }
    }
}
Also used : ConfigOption(com.alessiodp.core.common.configuration.ConfigOption) Field(java.lang.reflect.Field) InputStreamReader(java.io.InputStreamReader) YamlFile(com.alessiodp.core.common.addons.external.simpleyaml.configuration.file.YamlFile)

Example 2 with YamlFile

use of com.alessiodp.core.common.addons.external.simpleyaml.configuration.file.YamlFile in project Parties by AlessioDP.

the class BukkitConfigurationTest method testConfiguration.

private void testConfiguration(ConfigurationFile configurationFile, List<String> skipPaths) throws IllegalAccessException {
    Field[] fields = configurationFile.getClass().getFields();
    // Initialize YAML
    YamlFile yf = YamlFile.loadConfiguration(new InputStreamReader(getClass().getResourceAsStream("/" + configurationFile.getResourceName())));
    // Check fields
    for (Field f : fields) {
        ConfigOption co = f.getAnnotation(ConfigOption.class);
        if (co != null && !skippablePath(co.path(), skipPaths)) {
            Object value = yf.get(co.path());
            assertNotNull(value, "The " + configurationFile.getClass().getSimpleName() + " path '" + co.path() + "' is null.");
            f.set(null, value);
        }
    }
}
Also used : ConfigOption(com.alessiodp.core.common.configuration.ConfigOption) Field(java.lang.reflect.Field) InputStreamReader(java.io.InputStreamReader) YamlFile(com.alessiodp.core.common.addons.external.simpleyaml.configuration.file.YamlFile)

Example 3 with YamlFile

use of com.alessiodp.core.common.addons.external.simpleyaml.configuration.file.YamlFile in project Parties by AlessioDP.

the class VelocityConfigurationTest method testConfiguration.

private void testConfiguration(ConfigurationFile configurationFile, List<String> skipPaths) throws IllegalAccessException {
    Field[] fields = configurationFile.getClass().getFields();
    // Initialize YAML
    YamlFile yf = YamlFile.loadConfiguration(new InputStreamReader(getClass().getResourceAsStream("/" + configurationFile.getResourceName())));
    // Check fields
    for (Field f : fields) {
        ConfigOption co = f.getAnnotation(ConfigOption.class);
        if (co != null && !skippablePath(co.path(), skipPaths)) {
            Object value = yf.get(co.path());
            assertNotNull(value, "The " + configurationFile.getClass().getSimpleName() + " path '" + co.path() + "' is null.");
            f.set(null, value);
        }
    }
}
Also used : ConfigOption(com.alessiodp.core.common.configuration.ConfigOption) Field(java.lang.reflect.Field) InputStreamReader(java.io.InputStreamReader) YamlFile(com.alessiodp.core.common.addons.external.simpleyaml.configuration.file.YamlFile)

Aggregations

YamlFile (com.alessiodp.core.common.addons.external.simpleyaml.configuration.file.YamlFile)3 ConfigOption (com.alessiodp.core.common.configuration.ConfigOption)3 InputStreamReader (java.io.InputStreamReader)3 Field (java.lang.reflect.Field)3