public void SetUp() { IPublishedFundingContentsGeneratorResolver publishedFundingContentsGeneratorResolver = Substitute.For <IPublishedFundingContentsGeneratorResolver>(); IConfiguration configuration = Substitute.For <IConfiguration>(); _blobClient = Substitute.For <IBlobClient>(); _publishedFundingContentsGenerator = Substitute.For <IPublishedFundingContentsGenerator>(); _templateMetadataContents = new Common.TemplateMetadata.Models.TemplateMetadataContents { SchemaVersion = _schema }; publishedFundingContentsGeneratorResolver.GetService(Arg.Is(_schema)) .Returns(_publishedFundingContentsGenerator); _publishedFundingContentsPersistanceService = new PublishedFundingContentsPersistanceService( publishedFundingContentsGeneratorResolver, _blobClient, PublishingResilienceTestHelper.GenerateTestPolicies(), new PublishingEngineOptions(configuration)); _cloudBlob = Substitute.For <ICloudBlob>(); _publishedFundingPeriod = new PublishedFundingPeriod { Type = PublishedFundingPeriodType.AY, Period = "123" }; }
public PublishedFundingContentsPersistanceService( IPublishedFundingContentsGeneratorResolver publishedFundingContentsGeneratorResolver, IBlobClient blobClient, IPublishingResiliencePolicies publishingResiliencePolicies, IPublishingEngineOptions publishingEngineOptions) { Guard.ArgumentNotNull(publishedFundingContentsGeneratorResolver, nameof(publishedFundingContentsGeneratorResolver)); Guard.ArgumentNotNull(blobClient, nameof(blobClient)); Guard.ArgumentNotNull(publishingEngineOptions, nameof(publishingEngineOptions)); Guard.ArgumentNotNull(publishingResiliencePolicies?.PublishedFundingBlobRepository, nameof(publishingResiliencePolicies.PublishedFundingBlobRepository)); _publishedFundingContentsGeneratorResolver = publishedFundingContentsGeneratorResolver; _blobClient = blobClient; _publishingEngineOptions = publishingEngineOptions; _publishedFundingRepositoryPolicy = publishingResiliencePolicies.PublishedFundingBlobRepository; }
private static void RegisterSpecificationServiceComponents(IServiceCollection serviceCollection, IConfiguration configuration) { serviceCollection.AddSingleton(ctx => configuration); serviceCollection.AddScoped <ISpecificationPublishingService, SpecificationPublishingService>(); serviceCollection.AddSingleton <IProviderFundingPublishingService, ProviderFundingPublishingService>(); serviceCollection.AddSingleton <IHealthChecker, ProviderFundingPublishingService>(); serviceCollection.AddSingleton <ISpecificationIdServiceRequestValidator, PublishSpecificationValidator>(); serviceCollection.AddSingleton <IPublishedProviderIdsServiceRequestValidator, PublishedProviderIdsValidator>(); serviceCollection.AddSingleton <IPublishedProviderFundingService, PublishedProviderFundingService>(); serviceCollection.AddSingleton <ISpecificationService, SpecificationService>(); serviceCollection.AddSingleton <ICalculationsService, CalculationsService>(); serviceCollection.AddSingleton <IProviderService, ProviderService>(); serviceCollection.AddSingleton <IPublishedProviderIndexerService, PublishedProviderIndexerService>(); serviceCollection.AddSingleton <IPublishProviderExclusionCheck, PublishedProviderExclusionCheck>(); serviceCollection.AddSingleton <IFundingLineValueOverride, FundingLineValueOverride>(); serviceCollection.AddSingleton <IPublishedFundingDateService, PublishedFundingDateService>(); serviceCollection.AddSingleton <IPublishedFundingDataService, PublishedFundingDataService>(); serviceCollection.AddSingleton <IPublishedProviderContentPersistanceService, PublishedProviderContentPersistanceService>(); serviceCollection.AddSingleton <ICreateRefreshFundingJobs, RefreshFundingJobCreation>(); serviceCollection.AddSingleton <ICreateApproveAllFundingJobs, ApproveAllFundingJobCreation>(); serviceCollection.AddSingleton <ICreateApproveBatchFundingJobs, ApproveBatchFundingJobCreation>(); serviceCollection.AddSingleton <ICreateAllPublishProviderFundingJobs, AllPublishProviderFundingJobCreation>(); serviceCollection.AddSingleton <ICreatePublishIntegrityJob, PublishIntegrityCheckJobCreation>(); serviceCollection.AddSingleton <ICreateBatchPublishProviderFundingJobs, BatchPublishProviderFundingJobCreation>(); serviceCollection.AddSingleton <ICreateDeleteSpecificationJobs, DeleteSpecificationJobCreation>(); serviceCollection.AddSingleton <ICreateDeletePublishedProvidersJobs, DeletePublishedProvidersJobCreation>(); serviceCollection.AddSingleton <IPublishedFundingStatusUpdateService, PublishedFundingStatusUpdateService>(); serviceCollection.AddSingleton <IDeleteSpecifications, DeleteSpecificationService>(); serviceCollection.AddSingleton <IDeletePublishedProvidersService, DeletePublishedProvidersService>(); serviceCollection.AddSingleton <IDeleteFundingSearchDocumentsService, DeleteFundingSearchDocumentsService>(); serviceCollection.AddSingleton <IDeselectSpecificationForFundingService, DeselectSpecificationForFundingService>(); serviceCollection.AddSingleton <IDeletePublishedFundingBlobDocumentsService, DeletePublishedFundingBlobDocumentsService>(); serviceCollection.AddSingleton <IPublishedProviderFundingStructureService, PublishedProviderFundingStructureService>(); PolicySettings policySettings = ServiceCollectionExtensions.GetPolicySettings(configuration); OrganisationGroupResiliencePolicies organisationResiliencePolicies = CreateResiliencePolicies(policySettings); serviceCollection.AddSingleton <IOrganisationGroupResiliencePolicies>(organisationResiliencePolicies); serviceCollection.AddSingleton <IOrganisationGroupTargetProviderLookup, OrganisationGroupTargetProviderLookup>(); serviceCollection.AddSingleton <IOrganisationGroupGenerator, OrganisationGroupGenerator>(); serviceCollection.AddSingleton <IJobsRunning, JobsRunning>(); serviceCollection.AddSingleton <ICalculationPrerequisiteCheckerService, CalculationPrerequisiteCheckerService>(); serviceCollection.AddScoped <IPrerequisiteCheckerLocator, PrerequisiteCheckerLocator>(); serviceCollection.AddScoped <IPrerequisiteChecker, RefreshPrerequisiteChecker>(); serviceCollection.AddScoped <IPrerequisiteChecker, PublishAllPrerequisiteChecker>(); serviceCollection.AddScoped <IPrerequisiteChecker, PublishBatchPrerequisiteChecker>(); serviceCollection.AddScoped <IPrerequisiteChecker, ApproveAllProvidersPrerequisiteChecker>(); serviceCollection.AddScoped <IPrerequisiteChecker, ApproveBatchProvidersPrerequisiteChecker>(); serviceCollection.AddSingleton <IPublishedFundingChangeDetectorService, PublishedFundingChangeDetectorService>(); serviceCollection.AddSingleton <IPublishedFundingGenerator, PublishedFundingGenerator>(); SearchRepositorySettings searchSettings = new SearchRepositorySettings { SearchServiceName = configuration.GetValue <string>("SearchServiceName"), SearchKey = configuration.GetValue <string>("SearchServiceKey") }; serviceCollection.AddSingleton(searchSettings); serviceCollection.AddSingleton <ISearchRepository <PublishedFundingIndex>, SearchRepository <PublishedFundingIndex> >(); serviceCollection.AddSingleton <IPublishedFundingContentsPersistanceService>((ctx) => { BlobStorageOptions storageSettings = new BlobStorageOptions(); configuration.Bind("AzureStorageSettings", storageSettings); storageSettings.ContainerName = "publishedfunding"; IBlobContainerRepository blobContainerRepository = new BlobContainerRepository(storageSettings); IBlobClient blobClient = new BlobClient(blobContainerRepository); IPublishedFundingContentsGeneratorResolver publishedFundingContentsGeneratorResolver = ctx.GetService <IPublishedFundingContentsGeneratorResolver>(); ISearchRepository <PublishedFundingIndex> searchRepository = ctx.GetService <ISearchRepository <PublishedFundingIndex> >(); IPublishingResiliencePolicies publishingResiliencePolicies = ctx.GetService <IPublishingResiliencePolicies>(); return(new PublishedFundingContentsPersistanceService(publishedFundingContentsGeneratorResolver, blobClient, publishingResiliencePolicies, ctx.GetService <IPublishingEngineOptions>())); }); }