@Test(expected = UsernameNotFoundException.class) public void smokeTest_invalidUser() { final String email = "Does-not-exist@example.com"; customUserDetailsService.loadUserByUsername(email); }
@Override public UserDetails loadUserByUsername(final String email) throws UsernameNotFoundException { final User user = userRepository.findByEmailIgnoreCase(email); if (user == null) { throw new UsernameNotFoundException("User not found."); } return new CustomUserDetails(user); }
CustomUserDetailsService implements UserDetailsService { @Override public UserDetails loadUserByUsername(final String email) throws UsernameNotFoundException { final User user = userRepository.findByEmailIgnoreCase(email); if (user == null) { throw new UsernameNotFoundException("User not found."); } return new CustomUserDetails(user); } }
CustomUserDetailsService implements UserDetailsService { @Override public UserDetails loadUserByUsername(final String email) throws UsernameNotFoundException { final User user = userRepository.findByEmailIgnoreCase(email); if (user == null) { throw new UsernameNotFoundException("User not found."); } return new CustomUserDetails(user); } CustomUserDetailsService(final UserRepository userRepository); }
CustomUserDetailsService implements UserDetailsService { @Override public UserDetails loadUserByUsername(final String email) throws UsernameNotFoundException { final User user = userRepository.findByEmailIgnoreCase(email); if (user == null) { throw new UsernameNotFoundException("User not found."); } return new CustomUserDetails(user); } CustomUserDetailsService(final UserRepository userRepository); @Override UserDetails loadUserByUsername(final String email); }
CustomUserDetailsService implements UserDetailsService { @Override public UserDetails loadUserByUsername(final String email) throws UsernameNotFoundException { final User user = userRepository.findByEmailIgnoreCase(email); if (user == null) { throw new UsernameNotFoundException("User not found."); } return new CustomUserDetails(user); } CustomUserDetailsService(final UserRepository userRepository); @Override UserDetails loadUserByUsername(final String email);  }