### Question:
CtripUserService implements UserService { @Override public UserInfo findByUserId(String userId) { List<UserInfo> userInfoList = this.findByUserIds(Lists.newArrayList(userId)); if (CollectionUtils.isEmpty(userInfoList)) { return null; } return userInfoList.get(0); } CtripUserService(PortalConfig portalConfig); @Override List<UserInfo> searchUsers(String keyword, int offset, int limit); @Override UserInfo findByUserId(String userId); List<UserInfo> findByUserIds(List<String> userIds);  }### Answer:
@Test public void testFindByUserId() throws Exception { String someUserId = "someUserId"; String someName = "someName"; String someEmail = "someEmail"; CtripUserService.UserServiceResponse someUserResponse = assembleUserServiceResponse(someUserId, someName, someEmail); Map<String, List<CtripUserService.UserServiceResponse>> resultMap = ImmutableMap.of("result", Lists.newArrayList(someUserResponse)); ResponseEntity<Map<String, List<CtripUserService.UserServiceResponse>>> someResponse = new ResponseEntity<>(resultMap, HttpStatus.OK); when(restTemplate.exchange(eq(someUserServiceUrl), eq(HttpMethod.POST), any(HttpEntity.class), eq(someResponseType))).thenReturn(someResponse); UserInfo user = ctripUserService.findByUserId(someUserId); compareUserInfoAndUserServiceResponse(someUserResponse, user); }