CurrencyUtils { public static String countryFlagForCurrency(String c) { if (EUR.equals(c)) { return "europeanunion"; } else if (USD.equals(c)) { return "us"; } String commodityCode = COMMODITIES.get(c); if (commodityCode != null) { return commodityCode; } List<String> codes = countryCodesForCurrency(c); if (!codes.isEmpty()) { Collections.sort(codes); String code = codes.get(0); return code.toLowerCase(); } return null; }  static String countryFlagForCurrency(String c); static String nameForCurrency(String currency); static final String EUR; static final String USD; static final String GBP; static final String CHF; }
@Test public void testCountryFlagForCurrency() { assertThat(CurrencyUtils.countryFlagForCurrency(USD)).isEqualTo("us"); assertThat(CurrencyUtils.countryFlagForCurrency(EUR)).isEqualTo("europeanunion"); assertThat(CurrencyUtils.countryFlagForCurrency("RUB")).isEqualTo("ru"); assertThat(CurrencyUtils.countryFlagForCurrency(GBP)).isEqualTo("gb"); assertThat(CurrencyUtils.countryFlagForCurrency(CHF)).isEqualTo("ch"); assertThat(CurrencyUtils.countryFlagForCurrency("XAU")).isEqualTo("gold"); assertThat(CurrencyUtils.countryFlagForCurrency("TOTO")).isNull(); }