RepositoryProjectService implements ProjectService { @Override @Transactional(readOnly = true) public boolean projectExists(String projectId) { return projectRepo.existsById(projectId); } @Autowired  RepositoryProjectService(ProjectRepository projectRepo,
                                    ProjectApplicationRepository applicationRepo,
                                    UserRepository userRepo,
                                    UserService userService,
                                    Clock clock); @Override @Transactional(readOnly = true) Project getProjectById(String projectId); @Override @Transactional(readOnly = true) boolean projectExists(String projectId); @Override Project save(Project project); @Override List<Project> saveAll(List<Project> projects); @Override Project createProject(Project project);  }
@Test public void projectExistsReturnsTrueForExistingProjectForId() { when(projectRepo.existsById(PROJECT_ID)).thenReturn(true); boolean actualExists = projectService.projectExists(PROJECT_ID); assertThat(actualExists).isTrue(); }
@Test public void projectExistsReturnsFalseForNotExistingProjectForId() { when(projectRepo.existsById(PROJECT_ID)).thenReturn(false); boolean actualExists = projectService.projectExists(PROJECT_ID); assertThat(actualExists).isFalse(); }