/**
  * Access and test different Currency Conversions for the provider in place.
  *
  * <p>Test TCK providers, but also test implementation providers. Doing the ladder it is not
  * possible to test the rates quality, just that rates are returned if necessary.
  */
 @Test(
     description =
         "4.3.1 Access Conversion by query to term currency XXX for all providers that support according "
             + "conversion, if"
             + "available a non-null CurrencyConversion must be provided.")
 @SpecAssertion(id = "431-A2", section = "4.3.1")
 public void testConversionsAreAvailableWithQuery() {
   for (String providerName : MonetaryConversions.getConversionProviderNames()) {
     ConversionQuery query =
         ConversionQueryBuilder.of().setTermCurrency("XXX").setProviderNames(providerName).build();
     try {
       if (MonetaryConversions.isConversionAvailable(query)) {
         CurrencyConversion conv = MonetaryConversions.getConversion(query);
         AssertJUnit.assertNotNull(
             "CurrencyConversion returned from MonetaryConversions.getConversion(ConversionQuery) must"
                 + " "
                 + "never be null: "
                 + providerName,
             conv);
         AssertJUnit.assertTrue(
             "CurrencyConversion is not flagged as available though it was returned from "
                 + "MonetaryConversions.getConversion(ConversionQuery): "
                 + providerName,
             MonetaryConversions.isConversionAvailable(query));
       }
     } catch (MonetaryException e) {
       // OK, possible!
       AssertJUnit.assertFalse(
           "CurrencyConversion is not flagged as not available, though it was not returned from "
               + "MonetaryConversions.getConversion(ConversionQuery): "
               + providerName,
           MonetaryConversions.isConversionAvailable(query));
     }
   }
 }
 /**
  * Access and test different Currency Conversions for the provider in place.
  *
  * <p>Test TCK providers, but also test implementation providers. Doing the ladder it is not
  * possible to test the rates quality, just that rates are returned if necessary.
  */
 @Test(
     description =
         "4.3.1 Access Conversion to term currency code XXX for all providers that support according "
             + "conversion, if"
             + "available a non-null CurrencyConversion must be provided.")
 @SpecAssertion(id = "431-A2", section = "4.3.1")
 public void testConversionsAreAvailable() {
   for (String providerName : MonetaryConversions.getConversionProviderNames()) {
     try {
       if (MonetaryConversions.isConversionAvailable("XXX", providerName)) {
         CurrencyConversion conv = MonetaryConversions.getConversion("XXX", providerName);
         AssertJUnit.assertNotNull(
             "CurrencyConversion returned from MonetaryConversions.getConversion(String, "
                 + "String...) should never be null: "
                 + providerName,
             conv);
         AssertJUnit.assertTrue(
             "CurrencyConversion is not flagged as available, "
                 + "though it was returned from MonetaryConversions.getConversion"
                 + "(String,"
                 + " String...): "
                 + providerName,
             MonetaryConversions.isConversionAvailable("XXX", providerName));
       }
     } catch (MonetaryException e) {
       AssertJUnit.assertFalse(
           "CurrencyConversion is not flagged as NOT available, though it is not accessible from "
               + "MonetaryConversions.getConversion(String, String...): "
               + providerName,
           MonetaryConversions.isConversionAvailable("XXX", providerName));
     }
   }
 }
 /**
  * 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());
     }
   }
 }