@Test public void getUserByEmailIdTest() throws PacManException { User user = getUserDetails(); List<String[]> userRoles = getUserRoles(); UserPreferences userPreferences = getUserPreferences(); when(userRepository.findByEmailIgnoreCase(anyString())).thenReturn(user); when(userRolesMappingRepository.findAllUserRoleDetailsByUserIdIgnoreCase(user.getUserId())).thenReturn(userRoles); when(userPreferencesService.getUserPreferencesByNtId(user.getUserId())).thenReturn(userPreferences); assertThat(userService.getUserByEmailId(anyString()).getEmail(), is("email123")); }
@Override public UserDetails getUserByEmailId(final String emailId) throws PacManException { User user; if (emailId != null) { user = userRepository.findByEmailIgnoreCase(emailId); return fetchUserDetails(user, emailId); } else { throw new PacManException("Email Id cannot be empty"); } }
UserServiceImpl implements UserService { @Override public UserDetails getUserByEmailId(final String emailId) throws PacManException { User user; if (emailId != null) { user = userRepository.findByEmailIgnoreCase(emailId); return fetchUserDetails(user, emailId); } else { throw new PacManException("Email Id cannot be empty"); } } }
UserServiceImpl implements UserService { @Override public UserDetails getUserByEmailId(final String emailId) throws PacManException { User user; if (emailId != null) { user = userRepository.findByEmailIgnoreCase(emailId); return fetchUserDetails(user, emailId); } else { throw new PacManException("Email Id cannot be empty"); } }  }
UserServiceImpl implements UserService { @Override public UserDetails getUserByEmailId(final String emailId) throws PacManException { User user; if (emailId != null) { user = userRepository.findByEmailIgnoreCase(emailId); return fetchUserDetails(user, emailId); } else { throw new PacManException("Email Id cannot be empty"); } }  @Override List<User> getAllLoginUsers(); @Override UserDetails getUserByEmailId(final String emailId); }
UserServiceImpl implements UserService { @Override public UserDetails getUserByEmailId(final String emailId) throws PacManException { User user; if (emailId != null) { user = userRepository.findByEmailIgnoreCase(emailId); return fetchUserDetails(user, emailId); } else { throw new PacManException("Email Id cannot be empty"); } }  @Override List<User> getAllLoginUsers(); @Override UserDetails getUserByEmailId(final String emailId);  }