### Question:
DefaultProviderDataAccessor implements ProviderDataAccessor { @Override public List<ProviderUserModel> getUsersByProviderConfigName(String providerConfigName) { if (StringUtils.isBlank(providerConfigName)) { return List.of(); } try { Optional<Long> optionalProviderConfigId = configurationAccessor.getProviderConfigurationByName(providerConfigName) .map(ConfigurationModel::getConfigurationId); if (optionalProviderConfigId.isPresent()) { return getUsersByProviderConfigId(optionalProviderConfigId.get()); } } catch (AlertDatabaseConstraintException ignored) { } return List.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 getUsersByProviderConfigNameOptionalEmptyTest() throws Exception { ConfigurationAccessor configurationAccessor = Mockito.mock(ConfigurationAccessor.class); Mockito.when(configurationAccessor.getProviderConfigurationByName(Mockito.any())).thenReturn(Optional.empty()); DefaultProviderDataAccessor providerDataAccessor = new DefaultProviderDataAccessor(null, null, null, configurationAccessor); List<ProviderUserModel> providerUserModelList = providerDataAccessor.getUsersByProviderConfigName("providerConfigName-test"); assertTrue(providerUserModelList.isEmpty()); }
@Test public void getUsersByProviderConfigNameTest() throws Exception { ConfigurationModel configurationModel = createConfigurationModel(); ProviderUserEntity providerUserEntity = new ProviderUserEntity(projectOwnerEmail, true, 1L); ProviderProjectRepository providerProjectRepository = Mockito.mock(ProviderProjectRepository.class); ProviderUserRepository providerUserRepository = Mockito.mock(ProviderUserRepository.class); ConfigurationAccessor configurationAccessor = Mockito.mock(ConfigurationAccessor.class); Mockito.when(configurationAccessor.getProviderConfigurationByName(Mockito.any())).thenReturn(Optional.of(configurationModel)); Mockito.when(providerUserRepository.findByProviderConfigId(Mockito.any())).thenReturn(List.of(providerUserEntity)); DefaultProviderDataAccessor providerDataAccessor = new DefaultProviderDataAccessor(providerProjectRepository, null, providerUserRepository, configurationAccessor); List<ProviderUserModel> providerUserModelList = providerDataAccessor.getUsersByProviderConfigName("providerConfigName-test"); assertEquals(1, providerUserModelList.size()); ProviderUserModel providerUserModel = providerUserModelList.get(0); assertEquals(projectOwnerEmail, providerUserModel.getEmailAddress()); assertTrue(providerUserModel.getOptOut()); }
@Test public void getUsersByProviderConfigNameBlankTest() { DefaultProviderDataAccessor providerDataAccessor = new DefaultProviderDataAccessor(null, null, null, null); List<ProviderUserModel> providerUserModelList = providerDataAccessor.getUsersByProviderConfigName(""); assertTrue(providerUserModelList.isEmpty()); }