LangImpl implements Lang { @Override public Result setLanguage(String locale, Result result) { Cookie defaultLangCookie = generateNinjaLanguageCookie(); Cookie cookie = Cookie.builder(defaultLangCookie).setValue(locale).build(); result.addCookie(cookie); return result; } @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 testChangeLanguage() { Cookie cookie = Cookie.builder("NINJA_TEST" + NinjaConstant.LANG_COOKIE_SUFFIX, "de").build(); when(ninjaProperties.getOrDie(NinjaConstant.applicationCookiePrefix)).thenReturn("NINJA_TEST"); Lang lang = new LangImpl(ninjaProperties); Result result = Results.noContent(); result = lang.setLanguage("to", result); assertEquals("to", result.getCookie(cookie.getName()).getValue()); assertEquals(Result.SC_204_NO_CONTENT, result.getStatusCode()); }