Skip to content

Commit a088f13

Browse files
Add locale handling to Money.getCurrentCurrency test
1 parent 279e4c0 commit a088f13

File tree

1 file changed

+17
-4
lines changed
  • extensions/finances/sources/api/src/test/java/tools/dynamia/modules/finances/api

1 file changed

+17
-4
lines changed

extensions/finances/sources/api/src/test/java/tools/dynamia/modules/finances/api/MoneyTest.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.junit.jupiter.api.Test;
55

66
import java.math.BigDecimal;
7+
import java.util.Locale;
78

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

@@ -236,10 +237,22 @@ void testGetCurrencyForLocale() {
236237
@Test
237238
@DisplayName("Should get current currency")
238239
void testGetCurrentCurrency() {
239-
String currency = Money.getCurrentCurrency();
240-
241-
assertNotNull(currency);
242-
assertFalse(currency.isEmpty());
240+
// Save the current default locale
241+
Locale originalLocale = java.util.Locale.getDefault();
242+
243+
try {
244+
// Set a locale with a valid country code for testing
245+
java.util.Locale.setDefault(java.util.Locale.US);
246+
247+
String currency = Money.getCurrentCurrency();
248+
249+
assertNotNull(currency);
250+
assertFalse(currency.isEmpty());
251+
assertEquals("USD", currency);
252+
} finally {
253+
// Restore the original locale
254+
java.util.Locale.setDefault(originalLocale);
255+
}
243256
}
244257

245258
@Test

0 commit comments

Comments
 (0)