diff --git a/enrollment-server/src/main/java/com/wultra/app/enrollmentserver/impl/service/converter/MonetaryConverter.java b/enrollment-server/src/main/java/com/wultra/app/enrollmentserver/impl/service/converter/MonetaryConverter.java index 35022cb83..3b9321ba2 100644 --- a/enrollment-server/src/main/java/com/wultra/app/enrollmentserver/impl/service/converter/MonetaryConverter.java +++ b/enrollment-server/src/main/java/com/wultra/app/enrollmentserver/impl/service/converter/MonetaryConverter.java @@ -21,7 +21,7 @@ import javax.money.CurrencyUnit; import javax.money.Monetary; -import javax.money.UnknownCurrencyException; +import javax.money.MonetaryException; import java.math.RoundingMode; import java.text.NumberFormat; import java.util.Currency; @@ -113,7 +113,7 @@ private static int getFractionDigits(String code) { try { final CurrencyUnit currencyUnit = Monetary.getCurrency(code); return currencyUnit.getDefaultFractionDigits(); - } catch (UnknownCurrencyException e) { + } catch (MonetaryException e) { logger.debug("No currency mapping for code={}, most probably not FIAT", code); logger.trace("No currency mapping for code={}", code, e); return DEFAULT_MINIMAL_FRACTION_DIGITS; diff --git a/enrollment-server/src/test/java/com/wultra/app/enrollmentserver/impl/service/converter/MonetaryConverterTest.java b/enrollment-server/src/test/java/com/wultra/app/enrollmentserver/impl/service/converter/MonetaryConverterTest.java index 4760d9bec..38e245b9d 100644 --- a/enrollment-server/src/test/java/com/wultra/app/enrollmentserver/impl/service/converter/MonetaryConverterTest.java +++ b/enrollment-server/src/test/java/com/wultra/app/enrollmentserver/impl/service/converter/MonetaryConverterTest.java @@ -47,7 +47,8 @@ class MonetaryConverterTest { "NZD, en, NZ$", "NZD, cs, NZ$", "NZD, nz, NZ$", - "BTC, cs, BTC" + "BTC, cs, BTC", + "..., cs, ..." }) void testFormatCurrency(final String source, final String locale, final String expected) { final String result = MonetaryConverter.formatCurrency(source, new Locale(locale)); @@ -68,7 +69,8 @@ void testFormatCurrency(final String source, final String locale, final String e "1, BTC, en, '1'", "1.1, BTC, en, '1.1'", "0.123456789, BTC, en, '0.123456789'", - "0.567567567567567567567, BTC, en, '0.567567567567567567'" + "0.567567567567567567567, BTC, en, '0.567567567567567567'", + "1, ..., en, '1'" }) void testFormatAmount(final String amount, final String code, final String locale, final String expected) { final String result = MonetaryConverter.formatAmount(new BigDecimal(amount), code, new Locale(locale)); @@ -92,7 +94,8 @@ void testFormatAmount(final String amount, final String code, final String local "1, BTC, en, '1 BTC'", "1.1, BTC, en, '1.1 BTC'", "0.123456789, BTC, en, '0.123456789 BTC'", - "0.567567567567567567567, BTC, en, '0.567567567567567567 BTC'" + "0.567567567567567567567, BTC, en, '0.567567567567567567 BTC'", + "1, ..., en, '1 ...'" }) void testFormatValue(final String amount, final String code, final String locale, final String expected) { final String result = MonetaryConverter.formatValue(new BigDecimal(amount), code, new Locale(locale));