Move to Annotaml v2, fixes to config handling

This commit is contained in:
William committed 2022-10-01 18:10:12 +01:00
1 parent 128dc990cb
commit 089642f5de
8 files changed
+137 -109

No files matched your search

@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.Objects;
import java.util.Set;
@@ -18,7 +19,7 @@ public class LocalesTests {
// Load locales/en-gb.yml as an InputStream
try (InputStream localeStream = LocalesTests.class.getClassLoader().getResourceAsStream("locales/en-gb.yml")) {
Assertions.assertNotNull(localeStream, "en-gb.yml is missing from the locales folder");
final Locales englishLocales = Annotaml.load(localeStream, Locales.class);
final Locales englishLocales = Annotaml.create(Locales.class, localeStream).get();
final Set<String> keys = englishLocales.rawLocales.keySet();
// Iterate through every locale file in the locales folder
@@ -27,11 +28,11 @@ public class LocalesTests {
for (File file : Objects.requireNonNull(new File(url.getPath()).listFiles(file -> file.getName().endsWith("yml")
&& !file.getName().equals("en-gb.yml")))) {
final Set<String> fileKeys = Annotaml.load(file, Locales.class).rawLocales.keySet();
final Set<String> fileKeys = Annotaml.create(file, Locales.class).get().rawLocales.keySet();
keys.forEach(key -> Assertions.assertTrue(fileKeys.contains(key),
"Locale key " + key + " is missing from " + file.getName()));
}
} catch (IOException e) {
} catch (IOException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}