示例#1
0
        public ApproveAllCalculationsService(
            ICalculationsRepository calculationsRepository,
            ICalcsResiliencePolicies resiliencePolicies,
            ISpecificationsApiClient specificationsApiClient,
            IResultsApiClient resultsApiClient,
            ISearchRepository <CalculationIndex> searchRepository,
            ICacheProvider cacheProvider,
            ILogger logger,
            IJobManagement jobManagement) : base(jobManagement, logger)
        {
            Guard.ArgumentNotNull(calculationsRepository, nameof(calculationsRepository));
            Guard.ArgumentNotNull(specificationsApiClient, nameof(specificationsApiClient));
            Guard.ArgumentNotNull(resultsApiClient, nameof(resultsApiClient));
            Guard.ArgumentNotNull(cacheProvider, nameof(cacheProvider));
            Guard.ArgumentNotNull(searchRepository, nameof(searchRepository));
            Guard.ArgumentNotNull(resiliencePolicies?.SpecificationsApiClient, nameof(resiliencePolicies.SpecificationsApiClient));
            Guard.ArgumentNotNull(resiliencePolicies?.CacheProviderPolicy, nameof(resiliencePolicies.CacheProviderPolicy));
            Guard.ArgumentNotNull(resiliencePolicies?.ResultsApiClient, nameof(resiliencePolicies.ResultsApiClient));
            Guard.ArgumentNotNull(resiliencePolicies?.CalculationsRepository, nameof(resiliencePolicies.CalculationsRepository));
            Guard.ArgumentNotNull(logger, nameof(logger));

            _calculationsRepository = calculationsRepository;
            _logger = logger;
            _calculationRepositoryPolicy   = resiliencePolicies.CalculationsRepository;
            _specificationsApiClient       = specificationsApiClient;
            _specificationsApiClientPolicy = resiliencePolicies.SpecificationsApiClient;
            _resultsApiClient       = resultsApiClient;
            _resultsApiClientPolicy = resiliencePolicies.ResultsApiClient;
            _searchRepository       = searchRepository;
            _cacheProvider          = cacheProvider;
            _cachePolicy            = resiliencePolicies.CacheProviderPolicy;
        }
示例#2
0
        public ProviderResultsRepository(
            ICosmosRepository cosmosRepository,
            ILogger logger,
            IProviderResultCalculationsHashProvider calculationsHashProvider,
            ICalculatorResiliencePolicies calculatorResiliencePolicies,
            IResultsApiClient resultsApiClient,
            IJobManagement jobManagement)
        {
            Guard.ArgumentNotNull(cosmosRepository, nameof(cosmosRepository));
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(calculationsHashProvider, nameof(calculationsHashProvider));
            Guard.ArgumentNotNull(calculatorResiliencePolicies, nameof(calculatorResiliencePolicies));
            Guard.ArgumentNotNull(resultsApiClient, nameof(resultsApiClient));
            Guard.ArgumentNotNull(calculatorResiliencePolicies.ResultsApiClient, nameof(calculatorResiliencePolicies.ResultsApiClient));
            Guard.ArgumentNotNull(jobManagement, nameof(jobManagement));

            _cosmosRepository = cosmosRepository;
            _logger           = logger;

            _calculationsHashProvider       = calculationsHashProvider;
            _resultsApiClient               = resultsApiClient;
            _resultsApiClientPolicy         = calculatorResiliencePolicies.ResultsApiClient;
            _calculationResultsCosmosPolicy = calculatorResiliencePolicies.CalculationResultsRepository;
            _jobManagement = jobManagement;
        }
示例#3
0
 public PublishBatchPrerequisiteChecker(
     ISpecificationFundingStatusService specificationFundingStatusService,
     IJobsRunning jobsRunning,
     IJobManagement jobManagement,
     ILogger logger) : base(specificationFundingStatusService, jobsRunning, jobManagement, logger)
 {
 }
示例#4
0
        public ScopedProvidersService(ICacheProvider cacheProvider,
                                      IResultsApiClient resultsApiClient,
                                      ISpecificationsApiClient specificationsApiClient,
                                      IProviderVersionService providerVersionService,
                                      IScopedProvidersServiceSettings scopedProvidersServiceSettings,
                                      IFileSystemCache fileSystemCache,
                                      IJobManagement jobManagement,
                                      IProvidersResiliencePolicies providersResiliencePolicies,
                                      ILogger logger) : base(jobManagement, logger)
        {
            Guard.ArgumentNotNull(cacheProvider, nameof(cacheProvider));
            Guard.ArgumentNotNull(resultsApiClient, nameof(resultsApiClient));
            Guard.ArgumentNotNull(specificationsApiClient, nameof(specificationsApiClient));
            Guard.ArgumentNotNull(providerVersionService, nameof(providerVersionService));
            Guard.ArgumentNotNull(scopedProvidersServiceSettings, nameof(scopedProvidersServiceSettings));
            Guard.ArgumentNotNull(fileSystemCache, nameof(fileSystemCache));
            Guard.ArgumentNotNull(jobManagement, nameof(jobManagement));
            Guard.ArgumentNotNull(providersResiliencePolicies?.SpecificationsApiClient, nameof(providersResiliencePolicies.SpecificationsApiClient));
            Guard.ArgumentNotNull(providersResiliencePolicies?.ResultsApiClient, nameof(providersResiliencePolicies.ResultsApiClient));
            Guard.ArgumentNotNull(providersResiliencePolicies?.CacheProvider, nameof(providersResiliencePolicies.CacheProvider));
            Guard.ArgumentNotNull(logger, nameof(logger));

            _cachePolicy                    = providersResiliencePolicies.CacheProvider;
            _specificationsPolicy           = providersResiliencePolicies.SpecificationsApiClient;
            _resultsPolicy                  = providersResiliencePolicies.ResultsApiClient;
            _cacheProvider                  = cacheProvider;
            _resultsApiClient               = resultsApiClient;
            _specificationsApiClient        = specificationsApiClient;
            _providerVersionService         = providerVersionService;
            _fileSystemCache                = fileSystemCache;
            _scopedProvidersServiceSettings = scopedProvidersServiceSettings;
            _jobManagement                  = jobManagement;
            _logger = logger;
        }
        public TemplatesReIndexerService(ISearchRepository <TemplateIndex> searchRepository,
                                         IPolicyResiliencePolicies policyResiliencePolicies,
                                         IPolicyRepository policyRepository,
                                         ITemplateRepository templateRepository,
                                         IJobManagement jobManagement,
                                         ILogger logger) : base(jobManagement, logger)
        {
            Guard.ArgumentNotNull(searchRepository, nameof(searchRepository));
            Guard.ArgumentNotNull(policyResiliencePolicies?.TemplatesSearchRepository,
                                  nameof(policyResiliencePolicies.TemplatesSearchRepository));
            Guard.ArgumentNotNull(policyRepository, nameof(policyRepository));
            Guard.ArgumentNotNull(policyResiliencePolicies?.PolicyRepository,
                                  nameof(policyResiliencePolicies.PolicyRepository));
            Guard.ArgumentNotNull(templateRepository, nameof(templateRepository));
            Guard.ArgumentNotNull(policyResiliencePolicies?.TemplatesRepository,
                                  nameof(policyResiliencePolicies.TemplatesRepository));
            Guard.ArgumentNotNull(jobManagement, nameof(jobManagement));
            Guard.ArgumentNotNull(logger, nameof(logger));

            _searchRepository              = searchRepository;
            _searchRepositoryResilience    = policyResiliencePolicies.TemplatesSearchRepository;
            _templatesRepository           = templateRepository;
            _templatesRepositoryResilience = policyResiliencePolicies.TemplatesRepository;
            _jobManagement = jobManagement;
            _logger        = logger;
        }
        public FundingLineCsvGenerator(IFundingLineCsvTransformServiceLocator transformServiceLocator,
                                       IPublishedFundingPredicateBuilder predicateBuilder,
                                       IBlobClient blobClient,
                                       IFileSystemAccess fileSystemAccess,
                                       IFileSystemCacheSettings fileSystemCacheSettings,
                                       IFundingLineCsvBatchProcessorServiceLocator batchProcessorServiceLocator,
                                       IPublishingResiliencePolicies policies,
                                       IJobManagement jobManagement,
                                       ILogger logger) : base(jobManagement, logger)
        {
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(blobClient, nameof(blobClient));
            Guard.ArgumentNotNull(transformServiceLocator, nameof(transformServiceLocator));
            Guard.ArgumentNotNull(predicateBuilder, nameof(predicateBuilder));
            Guard.ArgumentNotNull(fileSystemAccess, nameof(fileSystemAccess));
            Guard.ArgumentNotNull(fileSystemCacheSettings, nameof(fileSystemCacheSettings));
            Guard.ArgumentNotNull(policies?.BlobClient, nameof(policies.BlobClient));
            Guard.ArgumentNotNull(batchProcessorServiceLocator, nameof(batchProcessorServiceLocator));

            _logger = logger;
            _batchProcessorServiceLocator = batchProcessorServiceLocator;
            _blobClient = blobClient;
            _transformServiceLocator = transformServiceLocator;
            _fileSystemAccess        = fileSystemAccess;
            _fileSystemCacheSettings = fileSystemCacheSettings;
            _blobClientPolicy        = policies.BlobClient;
        }
        public async Task ProcessDeadLetteredMessage_GivenMessageAndLogIsUpdated_LogsInformation()
        {
            // Arrange
            const string jobId = "job-id-1";

            JobLog jobLog = new JobLog
            {
                Id = "job-log-id-1"
            };

            Message message = new Message();

            message.UserProperties.Add("jobId", jobId);

            IJobManagement jobManagement = CreateJobManagement();

            jobManagement
            .AddJobLog(Arg.Is(jobId), Arg.Any <JobLogUpdateModel>())
            .Returns(jobLog);

            ILogger logger = CreateLogger();

            IDeadletterService service = CreateJobHelperService(jobManagement, logger);

            // Act
            await service.Process(message);

            // Assert
            logger
            .Received(1)
            .Information(Arg.Is($"A new job log was added to inform of a dead lettered message with job log id '{jobLog.Id}' on job with id '{jobId}'"));
        }
示例#8
0
        public async Task CreateAdditionalCalculation_GivenCreateJobReturnsNull_ReturnsInternalServerError()
        {
            //Arrange
            CalculationCreateModel model = CreateCalculationCreateModel();

            Reference author = CreateAuthor();

            ICalculationsRepository calculationsRepository = CreateCalculationsRepository();

            calculationsRepository
            .CreateDraftCalculation(Arg.Any <Calculation>())
            .Returns(HttpStatusCode.OK);

            IVersionRepository <CalculationVersion> versionRepository = CreateCalculationVersionRepository();

            ISearchRepository <CalculationIndex> searchRepository = CreateSearchRepository();

            IJobManagement jobManagement = CreateJobManagement();

            jobManagement
            .QueueJob(Arg.Any <JobCreateModel>())
            .Returns((Job)null);

            ISpecificationsApiClient specificationsApiClient = CreateSpecificationsApiClient();

            specificationsApiClient
            .GetSpecificationSummaryById(Arg.Is(SpecificationId))
            .Returns(new ApiResponse <SpecificationSummary>(
                         HttpStatusCode.OK,
                         new SpecificationSummary {
                Id = SpecificationId
            }
                         ));

            ILogger logger = CreateLogger();

            CalculationService calculationService = CreateCalculationService(
                calculationsRepository: calculationsRepository,
                calculationVersionRepository: versionRepository,
                searchRepository: searchRepository,
                jobManagement: jobManagement,
                logger: logger,
                specificationsApiClient: specificationsApiClient);

            //Act
            IActionResult result = await calculationService.CreateAdditionalCalculation(SpecificationId, model, author, CorrelationId);

            //Assert
            result
            .Should()
            .BeOfType <InternalServerErrorResult>()
            .Which
            .Value
            .Should()
            .Be($"Failed to create job of type '{JobConstants.DefinitionNames.CreateInstructAllocationJob}' on specification '{SpecificationId}'");

            logger
            .Received(1)
            .Error(Arg.Is($"Failed to create job of type '{JobConstants.DefinitionNames.CreateInstructAllocationJob}' on specification '{SpecificationId}'"));
        }
示例#9
0
        public DefinitionSpecificationRelationshipService(IDatasetRepository datasetRepository,
                                                          ILogger logger,
                                                          ISpecificationsApiClient specificationsApiClient,
                                                          IValidator <CreateDefinitionSpecificationRelationshipModel> relationshipModelValidator,
                                                          IMessengerService messengerService,
                                                          ICalcsRepository calcsRepository,
                                                          ICacheProvider cacheProvider,
                                                          IDatasetsResiliencePolicies datasetsResiliencePolicies,
                                                          IJobManagement jobManagement,
                                                          IDateTimeProvider dateTimeProvider)
        {
            Guard.ArgumentNotNull(dateTimeProvider, nameof(dateTimeProvider));
            Guard.ArgumentNotNull(datasetRepository, nameof(datasetRepository));
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(specificationsApiClient, nameof(specificationsApiClient));
            Guard.ArgumentNotNull(relationshipModelValidator, nameof(relationshipModelValidator));
            Guard.ArgumentNotNull(messengerService, nameof(messengerService));
            Guard.ArgumentNotNull(calcsRepository, nameof(calcsRepository));
            Guard.ArgumentNotNull(cacheProvider, nameof(cacheProvider));
            Guard.ArgumentNotNull(jobManagement, nameof(jobManagement));
            Guard.ArgumentNotNull(datasetsResiliencePolicies?.SpecificationsApiClient, nameof(datasetsResiliencePolicies.SpecificationsApiClient));

            _datasetRepository             = datasetRepository;
            _logger                        = logger;
            _specificationsApiClient       = specificationsApiClient;
            _relationshipModelValidator    = relationshipModelValidator;
            _messengerService              = messengerService;
            _calcsRepository               = calcsRepository;
            _cacheProvider                 = cacheProvider;
            _jobManagement                 = jobManagement;
            _dateTimeProvider              = dateTimeProvider;
            _specificationsApiClientPolicy = datasetsResiliencePolicies.SpecificationsApiClient;

            _typeIdentifierGenerator = new VisualBasicTypeIdentifierGenerator();
        }
示例#10
0
        public JobsRunning(
            IJobManagement jobManagement)
        {
            Guard.ArgumentNotNull(jobManagement, nameof(jobManagement));

            _jobManagement = jobManagement;
        }
        public ApproveService(IPublishedProviderStatusUpdateService publishedProviderStatusUpdateService,
                              IPublishedFundingDataService publishedFundingDataService,
                              IPublishedProviderIndexerService publishedProviderIndexerService,
                              IPublishingResiliencePolicies publishingResiliencePolicies,
                              IPrerequisiteCheckerLocator prerequisiteCheckerLocator,
                              IJobManagement jobManagement,
                              ILogger logger,
                              ITransactionFactory transactionFactory,
                              IPublishedProviderVersionService publishedProviderVersionService,
                              IGeneratePublishedFundingCsvJobsCreationLocator generateCsvJobsLocator) : base(jobManagement, logger)
        {
            Guard.ArgumentNotNull(generateCsvJobsLocator, nameof(generateCsvJobsLocator));
            Guard.ArgumentNotNull(prerequisiteCheckerLocator, nameof(prerequisiteCheckerLocator));
            Guard.ArgumentNotNull(publishedProviderStatusUpdateService, nameof(publishedProviderStatusUpdateService));
            Guard.ArgumentNotNull(publishedFundingDataService, nameof(publishedFundingDataService));
            Guard.ArgumentNotNull(publishedProviderIndexerService, nameof(publishedProviderIndexerService));
            Guard.ArgumentNotNull(publishingResiliencePolicies, nameof(publishingResiliencePolicies));
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(transactionFactory, nameof(transactionFactory));
            Guard.ArgumentNotNull(publishedProviderVersionService, nameof(publishedProviderVersionService));

            _publishedProviderStatusUpdateService = publishedProviderStatusUpdateService;
            _publishedFundingDataService          = publishedFundingDataService;
            _publishedProviderIndexerService      = publishedProviderIndexerService;
            _prerequisiteCheckerLocator           = prerequisiteCheckerLocator;
            _logger = logger;
            _generateCsvJobsLocator          = generateCsvJobsLocator;
            _transactionFactory              = transactionFactory;
            _publishedProviderVersionService = publishedProviderVersionService;
        }
示例#12
0
        public CalculationEngineRunningChecker(
            IJobManagement jobManagement)
        {
            Guard.ArgumentNotNull(jobManagement, nameof(jobManagement));

            _jobManagement = jobManagement;
        }
示例#13
0
        public ProviderSnapshotDataLoadService(ILogger logger,
                                               ISpecificationsApiClient specificationsApiClient,
                                               IProviderVersionService providerVersionService,
                                               IProvidersResiliencePolicies resiliencePolicies,
                                               IFundingDataZoneApiClient fundingDataZoneApiClient,
                                               IMapper mapper,
                                               IJobManagement jobManagement) : base(jobManagement, logger)
        {
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(specificationsApiClient, nameof(specificationsApiClient));
            Guard.ArgumentNotNull(providerVersionService, nameof(providerVersionService));
            Guard.ArgumentNotNull(resiliencePolicies?.SpecificationsApiClient, nameof(resiliencePolicies.SpecificationsApiClient));
            Guard.ArgumentNotNull(resiliencePolicies?.FundingDataZoneApiClient, nameof(resiliencePolicies.FundingDataZoneApiClient));
            Guard.ArgumentNotNull(fundingDataZoneApiClient, nameof(fundingDataZoneApiClient));
            Guard.ArgumentNotNull(mapper, nameof(mapper));
            Guard.ArgumentNotNull(jobManagement, nameof(jobManagement));

            _logger = logger;
            _specificationsApiClient        = specificationsApiClient;
            _providerVersionService         = providerVersionService;
            _specificationsApiClientPolicy  = resiliencePolicies.SpecificationsApiClient;
            _fundingDataZoneApiClientPolicy = resiliencePolicies.FundingDataZoneApiClient;
            _fundingDataZoneApiClient       = fundingDataZoneApiClient;
            _mapper        = mapper;
            _jobManagement = jobManagement;
        }
示例#14
0
        protected BasePublishingCsvGenerator(
            IJobManagement jobManagement,
            IFileSystemAccess fileSystemAccess,
            IBlobClient blobClient,
            IPublishingResiliencePolicies policies,
            ICsvUtils csvUtils,
            ILogger logger,
            IFileSystemCacheSettings fileSystemCacheSettings,
            IPublishedProviderCsvTransformServiceLocator publishedProviderCsvTransformServiceLocator) : base(jobManagement, logger)
        {
            Guard.ArgumentNotNull(fileSystemAccess, nameof(fileSystemAccess));
            Guard.ArgumentNotNull(blobClient, nameof(blobClient));
            Guard.ArgumentNotNull(policies?.BlobClient, nameof(policies.BlobClient));
            Guard.ArgumentNotNull(csvUtils, nameof(csvUtils));
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(fileSystemCacheSettings, nameof(fileSystemCacheSettings));
            Guard.ArgumentNotNull(publishedProviderCsvTransformServiceLocator, nameof(publishedProviderCsvTransformServiceLocator));

            _fileSystemAccess        = fileSystemAccess;
            _blobClient              = blobClient;
            _blobClientPolicy        = policies.BlobClient;
            _csvUtils                = csvUtils;
            _fileSystemCacheSettings = fileSystemCacheSettings;
            _publishedProviderCsvTransformServiceLocator = publishedProviderCsvTransformServiceLocator;
            _logger = logger;
        }
        public async Task CreateInstructGenerateAggregationsAllocationJob_GivenJobCreated_LogsInformation()
        {
            //Arrange
            JobSummary jobNotification = CreateJobSummary();

            string json = JsonConvert.SerializeObject(jobNotification);

            Message message = new Message(Encoding.UTF8.GetBytes(json));

            Job job = new Job
            {
                Id = "job-id-1"
            };

            IJobManagement jobManagement = CreateJobManagement();

            jobManagement
            .QueueJob(Arg.Any <JobCreateModel>())
            .Returns(job);

            ILogger logger = CreateLogger();

            JobService jobService = CreateJobService(jobManagement, logger);

            //Act
            await jobService.Process(message);

            //Assert
            logger
            .Received(1)
            .Information(Arg.Is($"Created new job of type: '{JobConstants.DefinitionNames.CreateInstructAllocationJob}' with id: '{job.Id}'"));
        }
        public void CreateInstructGenerateAggregationsAllocationJob_GivenCreatingJobReturnsNull_ThrowsException()
        {
            //Arrange
            JobSummary jobNotification = CreateJobSummary();

            string json = JsonConvert.SerializeObject(jobNotification);

            Message message = new Message(Encoding.UTF8.GetBytes(json));

            IJobManagement jobManagement = CreateJobManagement();

            jobManagement
            .QueueJob(Arg.Any <JobCreateModel>())
            .Returns((Job)null);

            ILogger logger = CreateLogger();

            JobService jobService = CreateJobService(jobManagement, logger);

            //Act
            Func <Task> test = () => jobService.Process(message);

            //Assert
            test
            .Should()
            .ThrowExactly <Exception>()
            .Which
            .Message
            .Should()
            .Be($"Failed to create new job of type: '{JobConstants.DefinitionNames.CreateInstructAllocationJob}'");

            logger
            .Received(1)
            .Error(Arg.Is($"Failed to create new job of type: '{JobConstants.DefinitionNames.CreateInstructAllocationJob}'"));
        }
        public DeletePublishedProvidersService(ICreateDeletePublishedProvidersJobs jobs,
                                               IPublishedFundingRepository publishedFundingRepository,
                                               IPublishingResiliencePolicies publishedFundingResilience,
                                               IJobManagement jobManagement,
                                               IDeleteFundingSearchDocumentsService deleteFundingSearchDocumentsService,
                                               IDeletePublishedFundingBlobDocumentsService deletePublishedFundingBlobDocumentsService,
                                               IDeselectSpecificationForFundingService deselectSpecificationForFundingService,
                                               ILogger logger) : base(jobManagement, logger)
        {
            Guard.ArgumentNotNull(jobs, nameof(jobs));
            Guard.ArgumentNotNull(publishedFundingRepository, nameof(publishedFundingRepository));
            Guard.ArgumentNotNull(publishedFundingResilience?.PublishedFundingRepository, nameof(publishedFundingResilience.PublishedFundingRepository));
            Guard.ArgumentNotNull(publishedFundingResilience?.BlobClient, nameof(publishedFundingResilience.BlobClient));
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(deletePublishedFundingBlobDocumentsService, nameof(deletePublishedFundingBlobDocumentsService));
            Guard.ArgumentNotNull(deleteFundingSearchDocumentsService, nameof(deleteFundingSearchDocumentsService));
            Guard.ArgumentNotNull(deselectSpecificationForFundingService, nameof(deleteFundingSearchDocumentsService));

            _jobs = jobs;
            _publishedFundingRepository = publishedFundingRepository;
            _logger = logger;
            _deselectSpecificationForFundingService     = deselectSpecificationForFundingService;
            _deleteFundingSearchDocumentsService        = deleteFundingSearchDocumentsService;
            _deletePublishedFundingBlobDocumentsService = deletePublishedFundingBlobDocumentsService;
            _publishedFundingRepositoryPolicy           = publishedFundingResilience.PublishedFundingRepository;
        }
示例#18
0
        public void SetUp()
        {
            _policies = Substitute.For <IPoliciesApiClient>();
            _jobs     = Substitute.For <IJobManagement>();

            _userId   = NewRandomString();
            _userName = NewRandomString();

            _user = NewReference(_ => _.WithId(_userId)
                                 .WithName(_userName));

            _correlationId = NewRandomString();

            _action = new QueueCreateSpecificationJobAction(_policies,
                                                            _jobs,
                                                            new SpecificationsResiliencePolicies
            {
                JobsApiClient     = Policy.NoOpAsync(),
                PoliciesApiClient = Policy.NoOpAsync()
            },
                                                            Substitute.For <ILogger>());

            _jobs.QueueJob(Arg.Any <JobCreateModel>())
            .Returns(new Job());    //default instance as we assert was called but have null checks in the test now
        }
        public void SetUp()
        {
            _deletePublishedProviders   = Substitute.For <ICreateDeletePublishedProvidersJobs>();
            _publishedFundingRepository = Substitute.For <IPublishedFundingRepository>();
            _jobManagement = Substitute.For <IJobManagement>();
            _deletePublishedFundingBlobDocumentsService = Substitute.For <IDeletePublishedFundingBlobDocumentsService>();
            _deselectSpecificationForFundingService     = Substitute.For <IDeselectSpecificationForFundingService>();
            _deleteFundingSearchDocumentsService        = Substitute.For <IDeleteFundingSearchDocumentsService>();

            _service = new DeletePublishedProvidersService(_deletePublishedProviders,
                                                           _publishedFundingRepository,
                                                           new ResiliencePolicies
            {
                PublishedProviderSearchRepository = Policy.NoOpAsync(),
                BlobClient = Policy.NoOpAsync(),
                PublishedFundingRepository = Policy.NoOpAsync(),
                SpecificationsApiClient    = Policy.NoOpAsync()
            },
                                                           _jobManagement,
                                                           _deleteFundingSearchDocumentsService,
                                                           _deletePublishedFundingBlobDocumentsService,
                                                           _deselectSpecificationForFundingService,
                                                           Substitute.For <ILogger>());

            _fundingPeriodId = NewRandomString();
            _fundingStreamId = NewRandomString();
            _jobId           = NewRandomString();
        }
示例#20
0
        public void SetUp()
        {
            _jobs  = Substitute.For <IJobManagement>();
            _jobId = NewRandomString();

            _tracker = new JobTracker(_jobs);
        }
        public TestResultsService(ITestResultsRepository testResultsRepository,
                                  ISearchRepository <TestScenarioResultIndex> searchRepository,
                                  IMapper mapper,
                                  ILogger logger,
                                  ITelemetry telemetry,
                                  ITestRunnerResiliencePolicies policies,
                                  IProvidersApiClient providersApiClient,
                                  IJobManagement jobManagement) : base(jobManagement, logger)
        {
            Guard.ArgumentNotNull(searchRepository, nameof(searchRepository));
            Guard.ArgumentNotNull(testResultsRepository, nameof(testResultsRepository));
            Guard.ArgumentNotNull(mapper, nameof(mapper));
            Guard.ArgumentNotNull(logger, nameof(logger));
            Guard.ArgumentNotNull(telemetry, nameof(telemetry));
            Guard.ArgumentNotNull(policies?.TestResultsRepository, nameof(policies.TestResultsRepository));
            Guard.ArgumentNotNull(policies?.TestResultsSearchRepository, nameof(policies.TestResultsSearchRepository));
            Guard.ArgumentNotNull(providersApiClient, nameof(providersApiClient));

            _testResultsRepository = testResultsRepository;
            _searchRepository      = searchRepository;
            _mapper                  = mapper;
            _logger                  = logger;
            _telemetry               = telemetry;
            _testResultsPolicy       = policies.TestResultsRepository;
            _testResultsSearchPolicy = policies.TestResultsSearchRepository;
            _providersApiClient      = providersApiClient;
        }
 public GeneratePublishedFundingCsvJobCreation(IJobManagement jobs, ILogger logger)
     : base(jobs,
            logger,
            JobConstants.DefinitionNames.GeneratePublishedFundingCsvJob,
            "New Csv file generation triggered by publishing change")
 {
 }
        public async Task ProcessDeadLetteredMessage_GivenMessageButAddingLogCausesException_LogsAnError()
        {
            // Arrange
            const string jobId = "job-id-1";

            Message message = new Message();

            message.UserProperties.Add("jobId", jobId);

            IJobManagement jobManagement = CreateJobManagement();

            jobManagement
            .When(x => x.AddJobLog(Arg.Is(jobId), Arg.Any <JobLogUpdateModel>()))
            .Do(x => { throw new Exception(); });

            ILogger logger = CreateLogger();

            IDeadletterService service = CreateJobHelperService(jobManagement, logger);

            // Act
            await service.Process(message);

            // Assert
            logger
            .Received(1)
            .Error(Arg.Any <Exception>(), Arg.Is($"Failed to add a job log for job id '{jobId}'"));
        }
        public DeadletterService(IJobManagement jobManagement, ILogger logger)
        {
            Guard.ArgumentNotNull(jobManagement, nameof(jobManagement));
            Guard.ArgumentNotNull(logger, nameof(logger));

            _jobManagement = jobManagement;
            _logger        = logger;
        }
示例#25
0
        public void SetUp()
        {
            _jobs            = Substitute.For <IJobManagement>();
            _specificationId = NewRandomString();
            _jobTypes        = new string[] { JobConstants.DefinitionNames.CreateInstructAllocationJob };

            _calculationEngineRunningChecker = new CalculationEngineRunningChecker(_jobs);
        }
示例#26
0
 public SearchIndexWriterService(ILogger logger, IJobManagement jobManagement, ISearchIndexProcessorFactory searchIndexProcessorFactory) : base(jobManagement, logger)
 {
     Guard.ArgumentNotNull(logger, nameof(logger));
     Guard.ArgumentNotNull(jobManagement, nameof(jobManagement));
     Guard.ArgumentNotNull(searchIndexProcessorFactory, nameof(searchIndexProcessorFactory));
     _logger = logger;
     _searchIndexProcessorFactory = searchIndexProcessorFactory;
 }
示例#27
0
        public void SetUp()
        {
            _jobs   = Substitute.For <IJobManagement>();
            _logger = Substitute.For <ILogger>();

            _jobCreation = new DeletePublishedProvidersJobCreation(_jobs,
                                                                   _logger);
        }
 public void Setup()
 {
     _logger        = Substitute.For <ILogger>();
     _jobManagement = Substitute.For <IJobManagement>();
     _searchIndexProcessorFactory = Substitute.For <ISearchIndexProcessorFactory>();
     _service = new SearchIndexWriterService(_logger, _jobManagement, _searchIndexProcessorFactory);
     _searchIndexProcessor = Substitute.For <ISearchIndexProcessor>();
 }
示例#29
0
        public async Task QueueCsvGenerationMessages_GivenSpecificationSummariesFoundAndHasNewResults_CreatesNewMessage()
        {
            //Arrange
            IEnumerable <SpecModel.SpecificationSummary> specificationSummaries = new[]
            {
                new SpecModel.SpecificationSummary {
                    Id = specificationId
                }
            };

            ISpecificationsApiClient specificationsApiClient = CreateSpecificationsApiClient();

            specificationsApiClient
            .GetSpecificationSummaries()
            .Returns(new ApiResponse <IEnumerable <SpecModel.SpecificationSummary> >(HttpStatusCode.OK, specificationSummaries));

            ICalculationResultsRepository calculationResultsRepository = CreateResultsRepository();

            calculationResultsRepository
            .CheckHasNewResultsForSpecificationIdAndTime(
                Arg.Is(specificationId),
                Arg.Any <DateTimeOffset>())
            .Returns(true);

            ILogger logger = CreateLogger();

            IJobManagement jobManagement = CreateJobManagement();

            IBlobClient blobClient = CreateBlobClient();

            blobClient
            .DoesBlobExistAsync($"{CalculationResultsReportFilePrefix}-{specificationId}", CalcsResultsContainerName)
            .Returns(true);

            ResultsService resultsService = CreateResultsService(
                logger,
                specificationsApiClient: specificationsApiClient,
                resultsRepository: calculationResultsRepository,
                jobManagement: jobManagement,
                blobClient: blobClient);

            //Act
            await resultsService.QueueCsvGenerationMessages();

            //Assert
            await
            jobManagement
            .Received(1)
            .QueueJob(
                Arg.Is <JobCreateModel>(_ =>
                                        _.JobDefinitionId == JobConstants.DefinitionNames.GenerateCalcCsvResultsJob &&
                                        _.Properties["specification-id"] == specificationId));

            logger
            .Received()
            .Information($"Found new calculation results for specification id '{specificationId}'");
        }
示例#30
0
        protected JobProcessingService(IJobManagement jobManagement,
                                       ILogger logger)
        {
            Guard.ArgumentNotNull(jobManagement, nameof(jobManagement));
            Guard.ArgumentNotNull(logger, nameof(logger));

            _jobManagement = jobManagement;
            _logger        = logger;
        }