2020package tests ;
2121
2222
23- import com .izanagicraft .messages .Translations ;
23+ import com .izanagicraft .messages .translations . GlobalTranslations ;
2424import org .junit .jupiter .api .BeforeAll ;
2525import org .junit .jupiter .api .Test ;
2626
3232import static org .junit .jupiter .api .Assertions .*;
3333
3434/**
35- * message-format; tests:TranslationTest
35+ * message-format; tests:GlobalTranslationsTest
3636 *
3737 * @author <a href="https://github.com/LuciferMorningstarDev">LuciferMorningstarDev</a>
3838 * @since 13.12.2023
3939 */
40- public class TranslationsTest {
40+ public class GlobalTranslationsTest {
4141
4242 @ BeforeAll
43- static void initTranslations () {
43+ static void initGlobalTranslations () {
4444 // Load the test language file
4545 File testFile = new File ("src/test/resources/lang.properties" );
4646
@@ -49,7 +49,7 @@ static void initTranslations() {
4949
5050 // Initialize translations with the test language file
5151 Map <String , Object > defaultReplacements = createDefaultReplacements ();
52- Translations .init (defaultReplacements , testFile );
52+ GlobalTranslations .init (defaultReplacements , testFile );
5353 }
5454
5555 private static Map <String , Object > createDefaultReplacements () {
@@ -62,24 +62,24 @@ private static Map<String, Object> createDefaultReplacements() {
6262 @ Test
6363 void testInit () {
6464 // Ensure translations are initialized
65- assertNotNull (Translations .getTranslations ());
66- assertFalse (Translations .getTranslations ().isEmpty ());
65+ assertNotNull (GlobalTranslations .getTranslations ());
66+ assertFalse (GlobalTranslations .getTranslations ().isEmpty ());
6767
6868 // Ensure fallback is set
69- assertNotNull (Translations .getFallback ());
69+ assertNotNull (GlobalTranslations .getFallback ());
7070 }
7171
7272 @ Test
7373 void testTranslateGreeting () {
7474 // Test translating the 'greeting' key with a placeholder
75- String translated = Translations .translate ("greeting" , "John" );
75+ String translated = GlobalTranslations .translate ("greeting" , "John" );
7676 assertEquals ("[PREFIX] Hello, John!" , translated );
7777 }
7878
7979 @ Test
8080 void testTranslateGreetingWithLocale () {
8181 // Test translating the 'greeting' key with a specific locale
82- String translated = Translations .translate (Locale .US , "greeting" , "Alice" );
82+ String translated = GlobalTranslations .translate (Locale .US , "greeting" , "Alice" );
8383 assertEquals ("[PREFIX] Hello, Alice!" , translated );
8484 }
8585
@@ -88,7 +88,7 @@ void testTranslateIterator() {
8888 // Test translating the 'iterator' key with a numeric placeholder
8989 for (int i = 0 ; i < 5 ; i ++) {
9090 int placeholderValue = 42 ;
91- String translated = Translations .translate ("iterator" , placeholderValue );
91+ String translated = GlobalTranslations .translate ("iterator" , placeholderValue );
9292 String expected = "[PREFIX] Current Iteration Index " + placeholderValue + "." ;
9393 assertEquals (expected , translated );
9494 }
@@ -100,7 +100,7 @@ void testTranslateIteratorWithLocale() {
100100 // Test translating the 'iterator' key with a specific locale and numeric placeholder
101101 for (int i = 0 ; i < 5 ; i ++) {
102102 int placeholderValue = i ;
103- String translated = Translations .translate (locale , "iterator" , placeholderValue );
103+ String translated = GlobalTranslations .translate (locale , "iterator" , placeholderValue );
104104 String expected = "[PREFIX] Current Iteration Index " + placeholderValue + "." ;
105105 assertEquals (expected , translated );
106106 }
@@ -109,21 +109,21 @@ void testTranslateIteratorWithLocale() {
109109 @ Test
110110 void testTranslateWithMissingKey () {
111111 // Test translating a key that does not exist in the language file
112- String translated = Translations .translate ("nonexistent.key" , "arg1" , "arg2" );
112+ String translated = GlobalTranslations .translate ("nonexistent.key" , "arg1" , "arg2" );
113113 assertEquals ("nonexistent.key" , translated );
114114 }
115115
116116 @ Test
117117 void testTranslateWithDefaultReplacements () {
118118 // Test translating with default replacements
119- String translated = Translations .translate ("greeting" );
119+ String translated = GlobalTranslations .translate ("greeting" );
120120 assertEquals ("[PREFIX] Hello, null!" , translated );
121121 }
122122
123123 @ Test
124124 void testTranslateWithInvalidLocale () {
125125 // Test translating with an invalid locale, should fall back to default
126- String translated = Translations .translate (new Locale ("invalid" ), "greeting" , "Bob" );
126+ String translated = GlobalTranslations .translate (new Locale ("invalid" ), "greeting" , "Bob" );
127127 assertEquals ("[PREFIX] Hello, Bob!" , translated );
128128 }
129129
0 commit comments