Search in sources :

Example 11 with PropertyReader

use of ch.jalu.configme.resource.PropertyReader in project AuthMeReloaded by AuthMe.

the class MessagesFileConsistencyTest method shouldHaveAllMessages.

@Test
public void shouldHaveAllMessages() {
    File file = TestHelper.getJarFile("/" + MESSAGES_FILE);
    PropertyReader reader = new YamlFileReader(file);
    List<String> errors = new ArrayList<>();
    for (MessageKey messageKey : MessageKey.values()) {
        validateMessage(messageKey, reader, errors);
    }
    if (!errors.isEmpty()) {
        fail("Validation errors in " + MESSAGES_FILE + ":\n- " + String.join("\n- ", errors));
    }
}
Also used : YamlFileReader(ch.jalu.configme.resource.YamlFileReader) ArrayList(java.util.ArrayList) PropertyReader(ch.jalu.configme.resource.PropertyReader) File(java.io.File) Test(org.junit.Test)

Example 12 with PropertyReader

use of ch.jalu.configme.resource.PropertyReader in project AuthMeReloaded by AuthMe.

the class MessageUpdaterTest method shouldAddMissingKeys.

@Test
public void shouldAddMissingKeys() throws IOException {
    // given
    File messagesFile = temporaryFolder.newFile();
    Files.copy(TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "message/messages_test.yml"), messagesFile);
    // when
    boolean wasChanged = messageUpdater.migrateAndSave(messagesFile, "does-not-exist", DEFAULT_MESSAGES_FILE);
    // then
    assertThat(wasChanged, equalTo(true));
    PropertyReader reader = new YamlFileReader(messagesFile);
    // Existing keys should not be overridden
    assertThat(reader.getString(MessageKey.LOGIN_SUCCESS.getKey()), equalTo("&cHere we have&bdefined some colors &dand some other &lthings"));
    assertThat(reader.getString(MessageKey.EMAIL_ALREADY_USED_ERROR.getKey()), equalTo(""));
    // Check that new keys were added
    assertThat(reader.getString(MessageKey.SECOND.getKey()), equalTo("second"));
    assertThat(reader.getString(MessageKey.ERROR.getKey()), equalTo("&4An unexpected error occurred, please contact an administrator!"));
}
Also used : YamlFileReader(ch.jalu.configme.resource.YamlFileReader) PropertyReader(ch.jalu.configme.resource.PropertyReader) File(java.io.File) Test(org.junit.Test)

Example 13 with PropertyReader

use of ch.jalu.configme.resource.PropertyReader in project AuthMeReloaded by AuthMe.

the class HelpMessageConsistencyTest method shouldHaveRequiredEntries.

@Test
public void shouldHaveRequiredEntries() {
    for (File file : helpFiles) {
        // given
        PropertyReader reader = new YamlFileReader(file);
        // when / then
        assertHasAllHelpSectionEntries(file.getName(), reader);
    }
}
Also used : YamlFileReader(ch.jalu.configme.resource.YamlFileReader) PropertyReader(ch.jalu.configme.resource.PropertyReader) File(java.io.File) Test(org.junit.Test)

Aggregations

PropertyReader (ch.jalu.configme.resource.PropertyReader)13 Test (org.junit.Test)9 YamlFileReader (ch.jalu.configme.resource.YamlFileReader)7 File (java.io.File)7 PropertyResource (ch.jalu.configme.resource.PropertyResource)3 ArrayList (java.util.ArrayList)2 ConfigurationData (ch.jalu.configme.configurationdata.ConfigurationData)1 StringProperty (ch.jalu.configme.properties.StringProperty)1 YamlFileResource (ch.jalu.configme.resource.YamlFileResource)1 Injector (ch.jalu.injector.Injector)1 InjectorBuilder (ch.jalu.injector.InjectorBuilder)1 AuthMeApi (fr.xephi.authme.api.v3.AuthMeApi)1 CommandHandler (fr.xephi.authme.command.CommandHandler)1 DataSource (fr.xephi.authme.datasource.DataSource)1 BlockListener (fr.xephi.authme.listener.BlockListener)1 MessageKey (fr.xephi.authme.message.MessageKey)1 MessageKeyConfigurationData (fr.xephi.authme.message.updater.MessageKeyConfigurationData)1 MigraterYamlFileResource (fr.xephi.authme.message.updater.MigraterYamlFileResource)1 PermissionsManager (fr.xephi.authme.permission.PermissionsManager)1 Management (fr.xephi.authme.process.Management)1