public DefaultAmountFormatProviderSpi() { supportedSets.addAll(Arrays.asList(DecimalFormat.getAvailableLocales())); supportedSets = Collections.unmodifiableSet(supportedSets); formatNames.add(DEFAULT_STYLE); formatNames = Collections.unmodifiableSet(formatNames); }
/** * Test MonetaryFormats.getAvailableLocales, all locales available also from java.text.DecimalFormat must be * supported (using AmountFormatContext.of(Locale)), more locales are possible. */ @Test(description = "4.4.3 Ensures for each locale defined by DecimalFormat.getAvailableLocales() a " + "MonetaryFormats.isAvailable(Locale) is true.") @SpecAssertion(section = "4.4.3", id = "443-A3") public void testGetAvailableLocales() { Set<Locale> locales = MonetaryFormats.getAvailableLocales(); for (Locale locale : DecimalFormat.getAvailableLocales()) { if (Locale.ROOT.equals(locale)) { continue; } AssertJUnit.assertTrue( "MonetaryFormats.getAvailableLocales(); Locale supported by JDKs DecimalFormat is not available: " + locale, locales.contains(locale)); } }
/** * Test MonetaryFormats.getAvailableLocales, all locales available also from java.text.DecimalFormat must be * supported (using AmountFormatContext.of(Locale)), more locales are possible. */ @Test(description = "4.4.3 Ensures for each locale defined by DecimalFormat.getAvailableLocales() a " + "MonetaryFormats.getAmountFormat(AmountFormatQuery) returns a formatter.") @SpecAssertion(section = "4.4.3", id = "443-A3") public void testAmountStyleOf() { for (Locale locale : DecimalFormat.getAvailableLocales()) { AssertJUnit.assertNotNull(MonetaryFormats.getAmountFormat(AmountFormatQuery.of(locale))); } } }
/** * AccessingMonetaryAmountFormat using * MonetaryFormats.getAmountFormat(AmountFormatContext style), all locales * available also from java.text.DecimalFormat must be supported * (using AmountFormatContext.of(Locale)). */ @Test(description = "4.4.3 Ensures for each locale defined by DecimalFormat.getAvailableLocales() a " + "MonetaryAmountFormat instance is provided.") @SpecAssertion(section = "4.4.3", id = "443-A2") public void testGetAmountFormat() { for (Locale locale : DecimalFormat.getAvailableLocales()) { AssertJUnit.assertNotNull(MonetaryFormats.getAmountFormat(AmountFormatQuery.of(locale))); } }
/** * AccessingMonetaryAmountFormat using * MonetaryFormats.getAmountFormat(Locale locale), all locales * available also from java.text.DecimalFormat must be supported. */ @SpecAssertion(section = "4.4.3", id = "443-A1") @Test(description = "4.4.3 Ensures all Locales defined by DecimalFormat.getAvailableLocales() are available for " + "monetary formatting.") public void testLocalesSupported() { Locale[] jdkDecimalFormatLocales = DecimalFormat.getAvailableLocales(); for (Locale jdkDecimalFormatLocale : jdkDecimalFormatLocales) { MonetaryAmountFormat amountFormat = MonetaryFormats.getAmountFormat(jdkDecimalFormatLocale); AssertJUnit.assertNotNull(amountFormat); assertEquals(jdkDecimalFormatLocale, amountFormat.getContext().getLocale()); } }