### Question:
AuthenticationServiceV1 { protected String getLocalizedMessage(Request request, Exception exception) { AcceptLanguageHeader languages = null; try { languages = request.getHeaders().get(AcceptLanguageHeader.class); } catch (MalformedHeaderException e) { DEBUG.warning("Could not parse accept language header", e); } String message = null; L10NMessage localizedException = null; if (exception instanceof L10NMessage) { localizedException = (L10NMessage) exception; } else if (exception.getCause() instanceof L10NMessage) { localizedException = (L10NMessage) exception.getCause(); } if (localizedException != null) { if (languages == null) { message = localizeMessage(localizedException, Locale.getDefaultLocale()); } else { for (java.util.Locale language : languages.getLocales().getLocales()) { message = localizeMessage(localizedException, language); if (message != null) { break; } } } } if (message == null) { message = exception.getMessage(); } return message; } @Inject  AuthenticationServiceV1(RestAuthenticationHandler restAuthenticationHandler); @Post Response authenticate(@Contextual Context context, @Contextual Request httpRequest);  }### Answer:
@Test public void shouldReturnFrenchErrorMessageFromException() throws IOException { Request httpRequest = new Request(); AuthLoginException exception = new AuthLoginException("amAuth", "120", null); httpRequest.getHeaders().put("Accept-Language", "fr-fr"); String message = authServiceV1.getLocalizedMessage(httpRequest, exception); assertThat(message).isEqualTo("L\u2019authentification sur module n\u2019est pas autoris\u00e9e."); }
@Test public void shouldReturnFrenchErrorMessageFromCause() throws IOException { Request httpRequest = new Request(); AuthLoginException ale = new AuthLoginException("amAuth", "120", null); RestAuthException exception = new RestAuthException(401, ale); httpRequest.getHeaders().put("Accept-Language", "fr-fr"); String message = authServiceV1.getLocalizedMessage(httpRequest, exception); assertThat(message).isEqualTo("L\u2019authentification sur module n\u2019est pas autoris\u00e9e."); }
@Test public void shouldReturnErrorMessageWithoutTemplate() throws IOException { Request httpRequest = new Request(); AuthLoginException ale = new AuthLoginException("amAuth", "119", null); RestAuthException exception = new RestAuthException(401, ale); String message = authServiceV1.getLocalizedMessage(httpRequest, exception); assertThat(message).isEqualTo("Invalid Auth Level."); }