package com.avairebot.language;

import com.avairebot.BaseTest;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import java.util.Set;

import static org.junit.jupiter.api.Assertions.*;

public class LanguageTests extends BaseTest {

    @BeforeAll
    public static void initAll() {
        I18n.start(null);
    }

    @Test
    public void testSubLanguagesIsTheSameSizeAsTheDefaultLanguage() {
        Set<String> defaultStrings = getKeys(I18n.DEFAULT);

        for (LanguageHolder entry : I18n.LANGS) {
            Set<String> strings = getKeys(entry);

            assertEquals(defaultStrings.size(), strings.size(), "Comparing keys sizes for the default language and " + entry.getLanguage().getCode());
        }
    }

    @Test
    public void testSubLanguagesHasAllTheSameKeysAsTheDefaultLanguage() {
        Set<String> defaultStrings = getKeys(I18n.DEFAULT);

        for (LanguageHolder entry : I18n.LANGS) {
            for (String str : getKeys(entry)) {
                assertTrue(defaultStrings.contains(str), "Checking the \"" + str + "\" string in the \"" + entry.getLanguage().getCode() + "\" language file");
            }
        }
    }

    @Test
    public void testLanguagesDoesNotReturnNull() {
        Set<String> defaultStrings = getKeys(I18n.DEFAULT);

        for (LanguageHolder entry : I18n.LANGS) {
            for (String str : defaultStrings) {
                assertNotNull(entry.getConfig().getString(str));
            }
        }
    }

    private Set<String> getKeys(LanguageHolder locale) {
        return locale.getConfig().getKeys(true);
    }
}

@@ -131,16 +131,60 @@
 pi.Test;
+%0Aimport org.opentest4j.AssertionFailedError;
 %0A%0Aimport
@@ -251,9 +251,80 @@
 ons.
-*
+assertNotNull;%0Aimport static org.junit.jupiter.api.Assertions.assertTrue
 ;%0A%0Ap
@@ -710,20 +710,11 @@
     
-assertEquals
+if 
 (def
@@ -731,17 +731,19 @@
 s.size()
-,
+ !=
  strings
@@ -749,18 +749,54 @@
 s.size()
-, 
+) %7B%0A                getLogger().error(
 %22Compari
@@ -871,18 +871,183 @@
 etCode()
-);
+ + %22 failed!%5Cn%5CnExpected:%5Ct%7B%7D%5CnActual:%5Ct%5Ct%7B%7D%5Cn%22,%0A                    defaultStrings.size(), strings.size(), new AssertionFailedError()%0A                );%0A            %7D
 %0A       
@@ -1772,16 +1772,108 @@
 ing(str)
+, str + %22 in the %22 + entry.getLanguage().getEnglishName() + %22 language files was not found!%22
 );%0A     

Make language tests more informative when they fail