### Question:
UserServiceImpl implements UserService { @Override @Transactional(readOnly = false) public User save(User user) { if (user.getId() != null) { final User oldUser = userDao.findOne(user.getId()); oldUser.setPostings(user.getPostings()); user.getPostings().clear(); } return userDao.save(user); }  @Override Page<User> getAllUser(); @Override Page<User> getUser(int skip, int count, Order... order); @Override Page<User> getUser(Pageable page); @Override @Transactional(readOnly = false) User save(User user); @Override User read(Long userId); @Override @Transactional(readOnly = false) void delete(Long userId); @Override long getNrOfUsers(); @Override List<Post> getPostingSelectOptions();  }### Answer:
@Test public void testSave() { final User aUser = new User(); when(userDao.save(any(User.class))).thenReturn(aUser); final User testUser = userService.save(new User()); assertThat(testUser).isEqualTo(aUser); verify(userDao, times(1)).save(any(User.class)); }