Search in sources :

Example 6 with YamlFileReader

use of ch.jalu.configme.resource.YamlFileReader 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 7 with YamlFileReader

use of ch.jalu.configme.resource.YamlFileReader 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)7 YamlFileReader (ch.jalu.configme.resource.YamlFileReader)7 Test (org.junit.Test)6 File (java.io.File)5 ArrayList (java.util.ArrayList)2 MessageKey (fr.xephi.authme.message.MessageKey)1