UserServiceImpl implements UserService { @Override public User getUserByEmail(String userEmail) throws FieldValidationException, UserNotFoundException { Assert.notNull(userEmail, "user email must be provided"); validateEmail(userEmail); User foundUser; try { foundUser = userDao.findUserByEmail(userEmail); } catch (Throwable t) { String msg = String.format("Failed to find user by email '%s'", userEmail); throw new UserServiceUnexpectedException(msg, t); } if (foundUser == null) { throw new UserNotFoundException(userEmail); } return foundUser; }  @Override @Transactional(rollbackFor = Throwable.class) User createUser(User userTemplate); @Override User getUserByUuid(String userUuid); @Override User getUserByEmail(String userEmail); @Override PaginatedList<User> findUsersByDisplayNamePartial(String displayNamePartial, PagerParams pagerParams); @Override @Transactional(rollbackFor = Throwable.class) void updateUser(User user); @Override @Transactional(rollbackFor = Throwable.class) void deleteUserByUuid(String userUuid); UserDao getUserDao(); void setUserDao(UserDao userDao); EventBus getEventBus(); @Required void setEventBus(EventBus eventBus); StringIdGenerator getStringIdGenerator(); @Autowired(required = false) void setStringIdGenerator(StringIdGenerator stringIdGenerator);  }
@Test(expected = IllegalArgumentException.class) public void testGetUserByEmail_defensive_expectIllegalArgumentExceptionOnNull() throws Exception { UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl(); fixture.getUserByEmail(null); fail(); }
@Test(expected = FieldValidationException.class) public void testGetUserByEmail_blackbox_expectFieldValidationExceptionOnEmptyString() throws Exception { UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl(); fixture.getUserByEmail(""); fail(); }
@Test(expected = FieldValidationException.class) public void testGetUserByEmail_blackbox_expectFieldValidationExceptionOnWrongFormat() throws Exception { UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl(); fixture.getUserByEmail("abara-cadabara"); fail(); }