### Question:
DefaultUserService implements UserService { @Override public User getUserByOpenId(String openId) { return userRepository.getByOpenId(openId); } @Autowired  DefaultUserService(PageRepository pageRepository,
                              UserRepository userRepository,
                              WidgetRepository widgetRepository,
                              PageTemplateRepository pageTemplateRepository,
                              CategoryRepository categoryRepository,
                              PersonRepository personRepository); @Override UserDetails loadUserByUsername(String username); @Override User getAuthenticatedUser(); @Override void setAuthenticatedUser(String userId); @Override void clearAuthenticatedUser(); @Override @Transactional void registerNewUser(User user); @Override User getUserById(String id); @Override User getUserByUsername(String userName); @Override User getUserByEmail(String userEmail); @Override User getUserByOpenId(String openId); @Override @Transactional void updateUserProfile(User user); @Override SearchResult<User> getAll(); @Override SearchResult<User> getLimitedList(int offset, int pageSize); @Override SearchResult<Person> getLimitedListOfPersons(int offset, int pageSize); @Override SearchResult<User> getUsersByFreeTextSearch(String searchTerm, int offset, int pageSize); @Override SearchResult<Person> getPersonsByFreeTextSearch(String searchTerm, int offset, int pageSize); @Override List<Person> getAllPeople(); @Override @Transactional // TODO RAVE-300: add security check that is is called by admin or the user itself void deleteUser(String userId); @Override List<Person> getAllByAddedWidget(String widgetId); @Override void updatePassword(User newUser); @Override void sendUserNameReminder(User newUser); @Override void sendPasswordReminder(User newUser); @Override boolean isValidReminderRequest(String forgotPasswordHash, int nrOfMinutesValid); @Override @Transactional boolean addFriend(String friendUsername, String username); @Override @Transactional void removeFriend(String friendUsername, String username); @Override HashMap<String, List<Person>> getFriendsAndRequests(String username); @Override List<Person> getFriendRequestsReceived(String username); @Override @Transactional boolean acceptFriendRequest(String friendUsername, String username); @Override UserDetails loadUserDetails(OpenIDAuthenticationToken token);  }### Answer:
@Test public void getUserByOpenId_valid() { final User authUser=new UserImpl(USER_ID,USER_NAME); authUser.setOpenId(OPENID_VALID); expect(userRepository.getByOpenId(OPENID_VALID)).andReturn(authUser).anyTimes(); replay(userRepository); UserDetails result = service.getUserByOpenId(OPENID_VALID); assertThat((User)result, is(sameInstance(authUser))); verify(userRepository); }