### Question:
RepositoryServiceImpl implements RepositoryService { @Override public Optional<Repository> find(String userName, String repositoryName) { return userService.findByLoginName(userName).flatMap(user -> { return repositoryDao.findByCreateUserIdAndName(user.getId(), repositoryName); }).map(project -> { project.setCreateUserName(userName); return project; }); }  @Override Optional<Repository> find(String userName, String repositoryName); @Override Repository createRepository(UserInfo user, Repository project); @Override List<Repository> findCanAccessRepositoriesByUserId(Integer userId); @Override Optional<GitCommitInfo> findLatestCommitInfo(Repository repository, String relativeFilePath); @Override Optional<Repository> findById(Integer repositoryId);  }### Answer:
@Test public void find_no_data() { Optional<Repository> projectOption = repositoryService.find("not-exist-owner", "not-exist-name"); assertThat(projectOption).isEmpty(); }
@Test public void find_success() { UserInfo userInfo = new UserInfo(); userInfo.setLoginName("user_name"); userInfo.setAvatarUrl("avatar_url"); userInfo.setEmail("email"); userInfo.setMobile("mobile"); userInfo.setCreateTime(LocalDateTime.now()); Integer userId = userDao.save(userInfo).getId(); Repository project = new Repository(); project.setName("project_name"); project.setIsPublic(true); project.setLastActiveTime(LocalDateTime.now()); project.setCreateUserId(userId); project.setCreateTime(LocalDateTime.now()); repositoryDao.save(project); Optional<Repository> projectOption = repositoryService.find("user_name", "project_name"); assertThat(projectOption).isPresent(); assertThat(projectOption.get().getCreateUserName()).isEqualTo("user_name"); }