@Test void testResolveLocaleUserWithoutLanguagecode() { String username = "MyUsername"; String languageCode = "nl"; User user = mock(User.class); when(userService.getUser(username)).thenReturn(user); when(fallbackLocaleSupplier.get()).thenReturn(Locale.forLanguageTag(languageCode)); assertEquals(forLanguageTag(languageCode), userLocaleResolver.resolveLocale(username)); }
@Transactional(readOnly = true) @Override public Locale resolveLocale(String username) { User user = userService.getUser(username); if (user == null) { throw new UnknownUserException(username); } String languageCode = user.getLanguageCode(); Locale locale; if (languageCode != null) { locale = Locale.forLanguageTag(languageCode); } else { locale = fallbackLocaleSupplier.get(); } return locale; }
UserLocaleResolverImpl implements UserLocaleResolver { @Transactional(readOnly = true) @Override public Locale resolveLocale(String username) { User user = userService.getUser(username); if (user == null) { throw new UnknownUserException(username); } String languageCode = user.getLanguageCode(); Locale locale; if (languageCode != null) { locale = Locale.forLanguageTag(languageCode); } else { locale = fallbackLocaleSupplier.get(); } return locale; } }
UserLocaleResolverImpl implements UserLocaleResolver { @Transactional(readOnly = true) @Override public Locale resolveLocale(String username) { User user = userService.getUser(username); if (user == null) { throw new UnknownUserException(username); } String languageCode = user.getLanguageCode(); Locale locale; if (languageCode != null) { locale = Locale.forLanguageTag(languageCode); } else { locale = fallbackLocaleSupplier.get(); } return locale; } UserLocaleResolverImpl(UserService userService, FallbackLocaleSupplier fallbackLocaleSupplier); }
UserLocaleResolverImpl implements UserLocaleResolver { @Transactional(readOnly = true) @Override public Locale resolveLocale(String username) { User user = userService.getUser(username); if (user == null) { throw new UnknownUserException(username); } String languageCode = user.getLanguageCode(); Locale locale; if (languageCode != null) { locale = Locale.forLanguageTag(languageCode); } else { locale = fallbackLocaleSupplier.get(); } return locale; } UserLocaleResolverImpl(UserService userService, FallbackLocaleSupplier fallbackLocaleSupplier); @Transactional(readOnly = true) @Override Locale resolveLocale(String username); }
UserLocaleResolverImpl implements UserLocaleResolver { @Transactional(readOnly = true) @Override public Locale resolveLocale(String username) { User user = userService.getUser(username); if (user == null) { throw new UnknownUserException(username); } String languageCode = user.getLanguageCode(); Locale locale; if (languageCode != null) { locale = Locale.forLanguageTag(languageCode); } else { locale = fallbackLocaleSupplier.get(); } return locale; } UserLocaleResolverImpl(UserService userService, FallbackLocaleSupplier fallbackLocaleSupplier); @Transactional(readOnly = true) @Override Locale resolveLocale(String username);  }