use of ch.jalu.configme.resource.YamlFileResource in project AuthMeReloaded by AuthMe.
the class SettingsIntegrationTest method shouldReloadSettings.
@Test
public void shouldReloadSettings() throws IOException {
// given
File configFile = temporaryFolder.newFile();
PropertyResource resource = new YamlFileResource(configFile);
Settings settings = new Settings(testPluginFolder, resource, null, CONFIG_DATA);
// when
// default value
assertThat(settings.getProperty(TestConfiguration.RATIO_ORDER), equalTo(TestEnum.SECOND));
Files.copy(getJarFile(COMPLETE_FILE), configFile);
settings.reload();
// then
assertThat(settings.getProperty(TestConfiguration.RATIO_ORDER), equalTo(TestEnum.FIRST));
}
use of ch.jalu.configme.resource.YamlFileResource in project AuthMeReloaded by AuthMe.
the class SettingsMigrationServiceTest method shouldKeepOldForceCommandSettings.
@Test
public void shouldKeepOldForceCommandSettings() throws IOException {
// given
File dataFolder = temporaryFolder.newFolder();
File configFile = new File(dataFolder, "config.yml");
Files.copy(getJarFile(OLD_CONFIG_FILE), configFile);
PropertyResource resource = new YamlFileResource(configFile);
SettingsMigrationService migrationService = new SettingsMigrationService(dataFolder);
// when
migrationService.performMigrations(resource, AuthMeSettingsRetriever.buildConfigurationData().getProperties());
// then
assertThat(migrationService.getOnLoginCommands(), contains("spawn"));
assertThat(migrationService.getOnLoginConsoleCommands(), contains("sethome %p:lastloc", "msg %p Welcome back"));
assertThat(migrationService.getOnRegisterCommands(), contains("me registers", "msg CONSOLE hi"));
assertThat(migrationService.getOnRegisterConsoleCommands(), contains("sethome %p:regloc"));
}
use of ch.jalu.configme.resource.YamlFileResource in project AuthMeReloaded by AuthMe.
the class CommandManager method reload.
@Override
public void reload() {
File file = new File(dataFolder, "commands.yml");
FileUtils.copyFileFromResource(file, "commands.yml");
SettingsManager settingsManager = new SettingsManager(new YamlFileResource(file), commandMigrationService, CommandSettingsHolder.class);
CommandConfig commandConfig = settingsManager.getProperty(CommandSettingsHolder.COMMANDS);
onJoinCommands = newReplacer(commandConfig.getOnJoin());
onLoginCommands = newReplacer(commandConfig.getOnLogin());
onSessionLoginCommands = newReplacer(commandConfig.getOnSessionLogin());
onRegisterCommands = newReplacer(commandConfig.getOnRegister());
onUnregisterCommands = newReplacer(commandConfig.getOnUnregister());
onLogoutCommands = newReplacer(commandConfig.getOnLogout());
}
use of ch.jalu.configme.resource.YamlFileResource in project AuthMeReloaded by AuthMe.
the class CommandMigrationServiceTest method shouldRewriteIncompleteFile.
@Test
public void shouldRewriteIncompleteFile() {
// given
File commandFile = TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "settings/commandconfig/commands.incomplete.yml");
PropertyResource resource = new YamlFileResource(commandFile);
// when
boolean result = commandMigrationService.checkAndMigrate(resource, ConfigurationDataBuilder.collectData(CommandSettingsHolder.class).getProperties());
// then
assertThat(result, equalTo(true));
}
use of ch.jalu.configme.resource.YamlFileResource in project AuthMeReloaded by AuthMe.
the class CommandMigrationServiceTest method shouldRewriteForEmptyFile.
@Test
public void shouldRewriteForEmptyFile() {
// given
File commandFile = TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "settings/commandconfig/commands.empty.yml");
PropertyResource resource = new YamlFileResource(commandFile);
// when
boolean result = commandMigrationService.checkAndMigrate(resource, ConfigurationDataBuilder.collectData(CommandSettingsHolder.class).getProperties());
// then
assertThat(result, equalTo(true));
}
Aggregations