### Question:
LocaleUtil { public static String getLocaleCode(String localeStr) { Locale locale = FALLBACK; try { locale = (localeStr != null)? LocaleUtils.toLocale(localeStr):FALLBACK; } catch (IllegalArgumentException e) { logger.warn("cannot get locale from {}. Returning fallback locale: "+FALLBACK,localeStr); } return locale.toString(); }  static String getLocaleCode(String localeStr); static final Locale FALLBACK; }### Answer:
@Test public void getLocaleCode_shouldReturnLocaleCode() throws Exception { assertThat(LocaleUtil.getLocaleCode("en_GB")).isEqualTo("en_GB"); }
@Test public void getLocaleCode_shouldFallbackForInvalidLocale() throws Exception { assertThat(LocaleUtil.getLocaleCode("qsdpjsd")).isEqualTo(LocaleUtil.FALLBACK.toString()); }
@Test public void getLocaleCode_shouldFallbackWhenNullLocaleProvided() throws Exception { assertThat(LocaleUtil.getLocaleCode(null)).isEqualTo(LocaleUtil.FALLBACK.toString()); }