LangImpl implements Lang { @Override public boolean isLanguageDirectlySupportedByThisApplication(String language) { String applicationLanguages = ninjaProperties.get(NinjaConstant.applicationLanguages); Iterable<String> languages = Splitter.on(",").trimResults().split(applicationLanguages); for (String applicationLanguage : languages) { if (applicationLanguage.equals(language)) { return true; } } return false; } @Inject  LangImpl(NinjaProperties ninjaProperties); @Override void clearLanguage(Result result); @Override Result setLanguage(String locale, Result result); @Override Optional<String> getLanguage(Context context, Optional<Result> result); @Override boolean isLanguageDirectlySupportedByThisApplication(String language); @Override Locale getLocaleFromStringOrDefault(Optional<String> language);  }
@Test public void testIsLanguageDirectlySupportedByThisApplication() { when(ninjaProperties.getOrDie(NinjaConstant.applicationCookiePrefix)).thenReturn("NINJA_TEST"); when(ninjaProperties.get(NinjaConstant.applicationLanguages)).thenReturn("en"); Lang lang = new LangImpl(ninjaProperties); assertTrue(lang.isLanguageDirectlySupportedByThisApplication("en")); assertFalse(lang.isLanguageDirectlySupportedByThisApplication("de")); when(ninjaProperties.get(NinjaConstant.applicationLanguages)).thenReturn("en, de, se"); assertTrue(lang.isLanguageDirectlySupportedByThisApplication("en")); assertTrue(lang.isLanguageDirectlySupportedByThisApplication("de")); assertTrue(lang.isLanguageDirectlySupportedByThisApplication("se")); assertFalse(lang.isLanguageDirectlySupportedByThisApplication("tk")); }