/** * Test if all providers returns valid meta data. * * @see javax.money.convert.ProviderContext */ @Test( description = "4.3.1 Test if all CurrencyConversion instances returns valid ConversionContext, accessed by " + "ConversionQuery/CurrencyUnit.") @SpecAssertion(id = "431-A3", section = "4.3.1") public void testProviderMetadata3WithContext() { for (String providerName : MonetaryConversions.getConversionProviderNames()) { ConversionQuery query = ConversionQueryBuilder.of() .setTermCurrency(Monetary.getCurrency("XXX")) .setProviderName(providerName) .build(); if (MonetaryConversions.isConversionAvailable(query)) { CurrencyConversion conv = MonetaryConversions.getConversion(query); ConversionContext ctx = conv.getContext(); AssertJUnit.assertNotNull( "ExchangeProvider must return a valid ProviderContext, but returned null: " + providerName, ctx); AssertJUnit.assertEquals( "ExchangeProvider's ProviderContext returns invalid name: " + providerName, providerName, ctx.getProviderName()); AssertJUnit.assertNotNull( "ExchangeProvider's ProviderContext declares invalid RateTypes to be returned (null): " + providerName, ctx.getRateType()); } } }
/** * Test if all providers returns valid meta data. * * @see javax.money.convert.ProviderContext */ @Test( description = "4.3.1 Test if all CurrencyConversion instances returns valid ConversionContext, accessed by " + "currency code.") @SpecAssertion(id = "431-A3", section = "4.3.1") public void testProviderMetadata2() { for (String providerName : MonetaryConversions.getConversionProviderNames()) { if (MonetaryConversions.isConversionAvailable("XXX", providerName)) { CurrencyConversion conv = MonetaryConversions.getConversion("XXX", providerName); ConversionContext ctx = conv.getContext(); AssertJUnit.assertNotNull( "ExchangeProvider must return a valid ProviderContext, but returned null: " + providerName, ctx); AssertJUnit.assertEquals( "ExchangeProvider's ProviderContext returns invalid name: " + providerName, providerName, ctx.getProviderName()); AssertJUnit.assertNotNull( "ExchangeProvider's ProviderContext declares invalid RateTypes to be returned (null): " + providerName, ctx.getRateType()); } } }