private async Task <IEnumerable <PublishedProvider> > GetPublishedProvidersForApproval(string specificationId, string[] publishedProviderIds = null)
        {
            _logger.Information("Fetching published providers for funding approval");

            Stopwatch existingPublishedProvidersStopwatch      = Stopwatch.StartNew();
            IEnumerable <PublishedProvider> publishedProviders =
                await _publishedFundingDataService.GetPublishedProvidersForApproval(specificationId, publishedProviderIds);

            existingPublishedProvidersStopwatch.Stop();
            _logger.Information($"Fetched {publishedProviders.Count()} published providers for approval in {existingPublishedProvidersStopwatch.ElapsedMilliseconds} ms");

            return(publishedProviders);
        }
Esempio n. 2
0
        public void SetUp()
        {
            _logger        = Substitute.For <ILogger>();
            _jobManagement = Substitute.For <IJobManagement>();
            _jobsRunning   = Substitute.For <IJobsRunning>();
            _prerequisiteCheckerLocator = Substitute.For <IPrerequisiteCheckerLocator>();
            _prerequisiteCheckerLocator.GetPreReqChecker(PrerequisiteCheckerType.ApproveAllProviders)
            .Returns(new ApproveAllProvidersPrerequisiteChecker(_jobsRunning, _jobManagement, _logger));
            _prerequisiteCheckerLocator.GetPreReqChecker(PrerequisiteCheckerType.ApproveBatchProviders)
            .Returns(new ApproveBatchProvidersPrerequisiteChecker(_jobsRunning, _jobManagement, _logger));
            _publishedFundingDataService          = Substitute.For <IPublishedFundingDataService>();
            _publishedProviderStatusUpdateService = Substitute.For <IPublishedProviderStatusUpdateService>();
            _publishedProviderIndexerService      = Substitute.For <IPublishedProviderIndexerService>();
            _generateCsvJobsLocator        = Substitute.For <IGeneratePublishedFundingCsvJobsCreationLocator>();
            _transactionResiliencePolicies = new TransactionResiliencePolicies {
                TransactionPolicy = Policy.NoOpAsync()
            };
            _transactionFactory = new TransactionFactory(_logger, _transactionResiliencePolicies);
            _publishedProviderVersionService = Substitute.For <IPublishedProviderVersionService>();

            _approveService = new ApproveService(_publishedProviderStatusUpdateService,
                                                 _publishedFundingDataService,
                                                 _publishedProviderIndexerService,
                                                 new ResiliencePolicies
            {
                PublishedFundingRepository = Policy.NoOpAsync()
            },
                                                 _prerequisiteCheckerLocator,
                                                 _jobManagement,
                                                 _logger,
                                                 _transactionFactory,
                                                 _publishedProviderVersionService,
                                                 _generateCsvJobsLocator);

            _jobId         = NewRandomString();
            _correlationId = NewRandomString();
            _userId        = NewRandomString();
            _userName      = NewRandomString();

            _message = new Message();

            SetUserProperty("user-id", _userId);
            SetUserProperty("user-name", _userName);
            SetUserProperty("jobId", null);

            _publishedFundingDataService.GetPublishedProvidersForApproval(Arg.Any <string>(), Arg.Any <string[]>())
            .Returns(new[] { new PublishedProvider() });
        }
Esempio n. 3
0
 private void AndTheSpecificationHasTheHeldUnApprovedPublishedProviders(string specificationId, string[] publishedProviderIds = null, params PublishedProvider[] publishedProviders)
 {
     _publishedFundingDataService.GetPublishedProvidersForApproval(specificationId, Arg.Is <string[]>(_ => _ == null || _.SequenceEqual(publishedProviderIds)))
     .Returns(publishedProviders);
 }