### Question:
DefaultProviderDataAccessor implements ProviderDataAccessor { @Override @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED) public Set<String> getEmailAddressesForProjectHref(String projectHref) { Optional<Long> projectId = providerProjectRepository.findFirstByHref(projectHref).map(ProviderProjectEntity::getId); if (projectId.isPresent()) { Set<Long> userIds = providerUserProjectRelationRepository.findByProviderProjectId(projectId.get()) .stream() .map(ProviderUserProjectRelation::getProviderUserId) .collect(Collectors.toSet()); return providerUserRepository.findAllById(userIds) .stream() .map(ProviderUserEntity::getEmailAddress) .collect(Collectors.toSet()); } return Set.of(); } @Autowired  DefaultProviderDataAccessor(ProviderProjectRepository providerProjectRepository, ProviderUserProjectRelationRepository providerUserProjectRelationRepository, ProviderUserRepository providerUserRepository,
        ConfigurationAccessor configurationAccessor); @Override @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED) List<ProviderProject> getProjectsByProviderConfigName(String providerConfigName); @Override @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED) List<ProviderProject> getProjectsByProviderConfigId(Long providerConfigId); @Override void deleteProjects(Collection<ProviderProject> providerProjects); @Override @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED) Set<String> getEmailAddressesForProjectHref(String projectHref); @Override @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED) List<ProviderUserModel> getUsersByProviderConfigId(Long providerConfigId); @Override List<ProviderUserModel> getUsersByProviderConfigName(String providerConfigName); @Override void updateProjectAndUserData(Long providerConfigId, Map<ProviderProject, Set<String>> projectToUserData, Set<String> additionalRelevantUsers); static final int MAX_DESCRIPTION_LENGTH; static final int MAX_PROJECT_NAME_LENGTH; }### Answer:
@Test public void getEmailAddressesForProjectHrefTest() throws Exception { ProviderProjectEntity providerProjectEntity = new ProviderProjectEntity(name, description, href, projectOwnerEmail, 1L); providerProjectEntity.setId(1L); ProviderUserProjectRelation providerUserProjectRelation = new ProviderUserProjectRelation(2L, 1L); ProviderUserEntity providerUserEntity = new ProviderUserEntity(projectOwnerEmail, true, 1L); ProviderProjectRepository providerProjectRepository = Mockito.mock(ProviderProjectRepository.class); ProviderUserProjectRelationRepository providerUserProjectRelationRepository = Mockito.mock(ProviderUserProjectRelationRepository.class); ProviderUserRepository providerUserRepository = Mockito.mock(ProviderUserRepository.class); Mockito.when(providerProjectRepository.findFirstByHref(Mockito.any())).thenReturn(Optional.of(providerProjectEntity)); Mockito.when(providerUserProjectRelationRepository.findByProviderProjectId(Mockito.any())).thenReturn(List.of(providerUserProjectRelation)); Mockito.when(providerUserRepository.findAllById(Mockito.any())).thenReturn(List.of(providerUserEntity)); DefaultProviderDataAccessor providerDataAccessor = new DefaultProviderDataAccessor(providerProjectRepository, providerUserProjectRelationRepository, providerUserRepository, null); Set<String> emailAddresses = providerDataAccessor.getEmailAddressesForProjectHref(href); assertEquals(1, emailAddresses.size()); assertTrue(emailAddresses.contains(projectOwnerEmail)); }
@Test public void getEmailAddressesForProjectHrefEmptyTest() { ProviderProjectRepository providerProjectRepository = Mockito.mock(ProviderProjectRepository.class); Mockito.when(providerProjectRepository.findFirstByHref(Mockito.any())).thenReturn(Optional.empty()); DefaultProviderDataAccessor providerDataAccessor = new DefaultProviderDataAccessor(providerProjectRepository, null, null, null); Set<String> emailAddresses = providerDataAccessor.getEmailAddressesForProjectHref("test-href"); assertTrue(emailAddresses.isEmpty()); }