UserServiceImpl implements UserService { @Override public PaginatedList<User> findUsersByDisplayNamePartial(String displayNamePartial, PagerParams pagerParams) throws FieldValidationException { Preconditions.checkArgument(StringUtils.hasText(displayNamePartial), "Query text must be specified"); try { return userDao.findUserByDisplayNamePartial(displayNamePartial, pagerParams); } catch (Throwable t) { String msg = String.format("Failed to search users by partial user name '%s'", displayNamePartial); throw new UserServiceUnexpectedException(msg, t); } }  @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 testFindUsersByDisplayNamePartial_defensive_shouldThrowIllegalArgumentExceptionForInvalidQuery() throws Exception { UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl(); fixture.findUsersByDisplayNamePartial(null, null); fail(); }
@Test(expected = UserServiceUnexpectedException.class) public void testFindUsersByDisplayNamePartial_whitebox_expectUserServiceUnexpectedException() throws Exception { UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl(); fixture.findUsersByDisplayNamePartial(UserFactory.EXISTENT_USER, new PagerParams(20, 40)); fail(); }