@Test
  public void testGetCurrentLocale() {
    final Locale locale = new Locale("de");
    when(localizationService.getCurrentLocale()).thenReturn(locale);

    final Locale currentLocale = i18NService.getCurrentLocale();
    assertEquals(
        "Wrong current locale isocode! Should be: '"
            + locale.getLanguage()
            + "' but was: '"
            + currentLocale.getLanguage()
            + "'.",
        locale.getLanguage(),
        currentLocale.getLanguage());

    verify(localizationService, times(1)).getCurrentLocale();
  }
  @Test
  public void testGetBestMatchingLocale() {
    final Locale locale = new Locale("de");
    when(localizationService.getDataLocale(locale)).thenReturn(locale);

    final Locale bestMatchingLocale = i18NService.getBestMatchingLocale(locale);
    assertEquals(
        "Wrong best matching locale isocode! Should be: '"
            + locale.getLanguage()
            + "' but was: '"
            + bestMatchingLocale.getLanguage()
            + "'.",
        locale.getLanguage(),
        bestMatchingLocale.getLanguage());

    verify(localizationService, times(1)).getDataLocale(locale);
  }
  @Test
  public void testGetSupportedLocales() {
    final Set<Locale> locales = new HashSet<Locale>();
    locales.add(new Locale("de"));
    locales.add(new Locale("en"));

    when(localizationService.getSupportedDataLocales()).thenReturn(locales);

    final Set<Locale> supportesLocales = i18NService.getSupportedDataLocales();

    assertEquals(
        "Wrong number of supported locales! Should be: '"
            + locales.size()
            + "' but was: '"
            + supportesLocales.size()
            + "'.",
        locales.size(),
        supportesLocales.size());
    assertEquals(
        "Wrong number of supported locales! Should be: '"
            + NUMBER_OF_ELEMENTS
            + "' but was: '"
            + supportesLocales.size()
            + "'.",
        NUMBER_OF_ELEMENTS,
        supportesLocales.size());

    final Iterator<Locale> itLocales = locales.iterator();
    final Iterator<Locale> itSupportesLocales = supportesLocales.iterator();

    while (itLocales.hasNext()) {
      final Locale tempLocale = itLocales.next();
      final Locale tempSupportesLocale = itSupportesLocales.next();
      assertEquals(
          "Wrong current locale isocode! Should be: '"
              + tempLocale
              + "' but was: '"
              + tempSupportesLocale
              + "'.",
          tempLocale,
          tempSupportesLocale);
    }

    verify(localizationService, times(1)).getSupportedDataLocales();
  }
  @Test
  public void testGetFallbackLocales() {
    final Locale locale1 = new Locale("de");
    // fallback languages
    final Locale locale2 = new Locale("en");
    final Locale locale3 = new Locale("pl");

    when(localizationService.getFallbackLocales(locale1))
        .thenReturn((Locale[]) Arrays.asList(locale2, locale3).toArray());

    final Locale[] fallbackLocales = i18NService.getFallbackLocales(locale1);
    assertEquals(
        "Wrong number of all locales for: '"
            + locale1.getLanguage()
            + "'! Should be: '"
            + NUMBER_OF_FALLBACK_LOCALES
            + "' but was: '"
            + fallbackLocales.length
            + "'.",
        NUMBER_OF_FALLBACK_LOCALES,
        fallbackLocales.length);

    verify(localizationService, times(1)).getFallbackLocales(locale1);
  }