UserServiceImpl implements UserService { @Override public User getUserByUuid(String userUuid) throws UserNotFoundException { Assert.hasText(userUuid, "userUuid must be provided"); User foundUser; try { foundUser = userDao.findUserByUuid(userUuid); } catch (Throwable t) { String msg = String.format("Failed to find user '%s'", userUuid); throw new UserServiceUnexpectedException(msg, t); } if (foundUser == null) { throw new UserNotFoundException(userUuid); } 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 testGetUserByUuid_defensive_expectIllegalArgumentExceptionInsteadOfNpe1() throws Exception { UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl(); fixture.getUserByUuid(null); fail(); }
@Test(expected = IllegalArgumentException.class) public void testGetUserByUuid_defensive_expectIllegalArgumentExceptionInsteadOfNpe2() throws Exception { UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl(); fixture.getUserByUuid(""); fail(); }