@Test public void smokeTest_loadValidUser_sameCase() { final String userEmail = "test" + System.currentTimeMillis() + "@example.com"; final User user = userTestTools.createUser(); user.setEmail(userEmail); userTestTools.save(user); final UserDetails userDetails = customUserDetailsService.loadUserByUsername(userEmail); assertNotNull("Result should be non-null", userDetails); assertTrue("Should be a CustomUserDetails instance", userDetails instanceof CustomUserDetails); assertEquals("Should have correct email", userEmail, userDetails.getUsername()); assertEquals("Should have correct id", user.getId(), ((CustomUserDetails) userDetails).getUserId()); assertNotNull("Should have a user model", ((CustomUserDetails) userDetails).getUserModel()); }
@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);  }