### Question:
RepositoryResourceServiceImpl implements RepositoryResourceService { @Override public Optional<RepositoryResource> findByKey( Integer projectId, Integer parentId, RepositoryResourceType resourceType, AppType appType, String key) { return repositoryResourceDao.findByRepositoryIdAndParentIdAndResourceTypeAndAppTypeAndKeyIgnoreCase( projectId, parentId, resourceType, appType, key); }  @Override RepositoryResource insert(Repository repository, RepositoryResource resource); @Override List<RepositoryResource> findChildren(Repository project, Integer parentResourceId); @Override List<String> findParentPathes(Integer resourceId); @Override Optional<RepositoryResource> findByKey(
			Integer projectId, 
			Integer parentId, 
			RepositoryResourceType resourceType,
			AppType appType,
			String key); @Override Optional<RepositoryResource> findByName(
			Integer projectId, 
			Integer parentId, 
			RepositoryResourceType resourceType,
			AppType appType, 
			String name); @Override List<RepositoryResource> findAllPages(Integer projectId, AppType appType); @Override Optional<RepositoryResource> findById(Integer resourceId); @Override List<RepositoryResource> findParentGroupsByParentPath(Integer repositoryId, String parentPath); @Override List<UncommittedFile> findChanges(Repository project); @Override void stageChanges(Repository project, String[] filePathes); @Override void unstageChanges(Repository project, String[] filePathes); @Override String commit(UserInfo user, Repository project, String commitMessage); @Override void updatePageModel(Repository repository, RepositoryResource projectResource, PageModel pageModel); @Override PageModel getPageModel(RepositoryResource page); @Override PageModel createPageModelWithStdPage(Integer pageId); @Override RepositoryResource createWebProject(Repository repository, RepositoryResource project); @Override RepositoryResource createMiniProgram(
			Repository repository, 
			RepositoryResource project,
			ApiRepo apiRepo, 
			ApiWidget appWidget, 
			ApiWidget pageWidget); @Override Optional<RepositoryResource> findProject(Integer repositoryId, String projectKey);  }### Answer:
@Test public void findByKeyAtRootNoData() { Integer repositoryId = 1; assertThat(repositoryResourceService.findByKey( repositoryId, Constant.TREE_ROOT_ID, RepositoryResourceType.PAGE, AppType.WEB, "not-exist-key")).isEmpty(); }
@Test public void findByKeyAtRootSuccess() { Integer repositoryId = 1; RepositoryResource resource = new RepositoryResource(); resource.setRepositoryId(repositoryId); resource.setKey("key1"); resource.setName("name1"); resource.setAppType(AppType.WEB); resource.setResourceType(RepositoryResourceType.PAGE); resource.setParentId(Constant.TREE_ROOT_ID); resource.setSeq(1); resource.setCreateUserId(1); resource.setCreateTime(LocalDateTime.now()); repositortResourceDao.save(resource); assertThat(repositoryResourceService.findByKey( repositoryId, Constant.TREE_ROOT_ID, RepositoryResourceType.PAGE, AppType.WEB, "key1")).isPresent(); }