@Test public void should_serialize_valid_locale() { Locale[] locales = Locale.getAvailableLocales(); for (Locale locale : locales) { String languageTag = LocaleUtil.toLanguageTag(locale); assertEquals( locale.getLanguage() + (StringUtils.isNotBlank(locale.getCountry()) ? ("-" + locale.getCountry()) : ""), languageTag); } }
@Test public void should_serialize_locale_with_just_languageTag() { assertEquals("en", LocaleUtil.toLanguageTag(new Locale("en"))); }
@Test public void should_serialize_valid_predefined_locale() { String languageTag = LocaleUtil.toLanguageTag(Locale.US); assertEquals("en-US", languageTag); }