@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()); }
@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(); }
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(); } }
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); }
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); }
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; }