UserManagerImpl extends GenericManagerImpl<User, Long> implements UserManager, UserService { public User getUser(String userId) { return userDao.get(new Long(userId)); }  @Autowired void setPasswordEncoder(PasswordEncoder passwordEncoder); @Autowired void setUserDao(UserDao userDao); User getUser(String userId); List<User> getUsers(); User saveUser(User user); void removeUser(String userId); User getUserByUsername(String username);  }
@Test public void testGetUser() throws Exception { final User testData = new User("1"); testData.getRoles().add(new Role("user")); context.checking(new Expectations() {{ one(userDao).get(with(equal(1L))); will(returnValue(testData)); }}); User user = userManager.getUser("1"); assertTrue(user != null); assert user != null; assertTrue(user.getRoles().size() == 1); }