### Question:
LocaleHelper { @Nullable public static Locale getLocaleToUseOrFallback (@Nonnull final Locale aRequestLocale, @Nonnull final Collection <Locale> aAvailableLocales, @Nullable final Locale aFallback) { ValueEnforcer.notNull (aRequestLocale, "RequestLocale"); ValueEnforcer.notNull (aAvailableLocales, "AvailableLocales"); if (aAvailableLocales.contains (aRequestLocale)) return aRequestLocale; for (final Locale aCurrentLocale : getCalculatedLocaleListForResolving (aRequestLocale)) if (aAvailableLocales.contains (aCurrentLocale)) return aCurrentLocale; final String sRequestLanguage = aRequestLocale.getLanguage (); if (sRequestLanguage != null) for (final Locale aCurrentAvailableLocale : aAvailableLocales) if (sRequestLanguage.equals (aCurrentAvailableLocale.getLanguage ())) return aCurrentAvailableLocale; if (aAvailableLocales.contains (LOCALE_ALL)) return LOCALE_ALL; if (aAvailableLocales.contains (LOCALE_INDEPENDENT)) return LOCALE_INDEPENDENT; return aFallback; } private  LocaleHelper(); @Nonnull static String getLocaleDisplayName(@Nullable final Locale aLocale, @Nonnull final Locale aContentLocale); @Nonnull static String getLocaleNativeDisplayName(@Nonnull final Locale aLocale); @Nonnull @ReturnsMutableCopy static ICommonsMap <Locale, String> getAllLocaleDisplayNames(@Nonnull final Locale aContentLocale); @Nonnull @ReturnsImmutableObject @CodingStyleguideUnaware static List <Locale> getCalculatedLocaleListForResolving(@Nonnull final Locale aLocale); @Nonnull static Locale getLocaleFromString(@Nullable final String sLocaleAsString); @Nullable static Locale getLocaleToUseOrNull(@Nonnull final Locale aRequestLocale, @Nonnull final Collection <Locale> aAvailableLocales); @Nullable static Locale getLocaleToUseOrFallback(@Nonnull final Locale aRequestLocale,
                                                 @Nonnull final Collection <Locale> aAvailableLocales,
                                                 @Nullable final Locale aFallback); static boolean isSpecialLocale(@Nullable final Locale aLocale); static boolean isSpecialLocaleCode(@Nullable final String sLocale); @Nullable static String getValidLanguageCode(@Nullable final String sCode); @Nullable static String getValidCountryCode(@Nullable final String sCode); @Nonnull static EChange clearCache(); static final char LOCALE_SEPARATOR; static final String STR_ALL; static final Locale LOCALE_ALL; static final String STR_INDEPENDENT; static final Locale LOCALE_INDEPENDENT; }### Answer:
@Test public void testGetLocaleToUseOrFallback () { final ICommonsList <Locale> aLocales = new CommonsArrayList <> (L_DE, L_EN, LocaleHelper.LOCALE_ALL); try { LocaleHelper.getLocaleToUseOrFallback (null, aLocales, null); fail (); } catch (final NullPointerException ex) {} try { LocaleHelper.getLocaleToUseOrFallback (L_DE, null, null); fail (); } catch (final NullPointerException ex) {} assertSame (L_DE, LocaleHelper.getLocaleToUseOrFallback (L_DE, aLocales, null)); assertEquals (L_DE, LocaleHelper.getLocaleToUseOrFallback (L_DE_AT, aLocales, null)); assertEquals (LocaleHelper.LOCALE_ALL, LocaleHelper.getLocaleToUseOrFallback (L_FR, aLocales, null)); assertEquals (LocaleHelper.LOCALE_ALL, LocaleHelper.getLocaleToUseOrFallback (LocaleHelper.LOCALE_INDEPENDENT, aLocales, null)); assertEquals (LocaleHelper.LOCALE_INDEPENDENT, LocaleHelper.getLocaleToUseOrFallback (L_FR, new CommonsArrayList <> (LocaleHelper.LOCALE_INDEPENDENT), null)); assertNull (LocaleHelper.getLocaleToUseOrFallback (L_FR, new CommonsArrayList <> (L_DE, L_EN), null)); assertEquals (L_FR_FR, LocaleHelper.getLocaleToUseOrFallback (L_FR, new CommonsArrayList <> (L_DE, L_EN), L_FR_FR)); assertEquals (L_FR_FR, LocaleHelper.getLocaleToUseOrFallback (L_FR, new CommonsArrayList <> (L_FR_FR), null)); }