public async Task CreateAllocationLineResultStatusUpdateJobs_GivenJobIdButJobResponseIsNotFound_LogsAndDoesNotProcess() { //Arrange Message message = new Message(); message.UserProperties.Add("jobId", jobId); ILogger logger = CreateLogger(); ApiResponse <JobViewModel> apiResponse = new ApiResponse <JobViewModel>(HttpStatusCode.NotFound); IJobsApiClient jobsApiClient = CreateJobsApiClient(); jobsApiClient .GetJobById(jobId) .Returns(apiResponse); PublishedResultsService publishedResultsService = CreateResultsService(logger, jobsApiClient: jobsApiClient); //Act await publishedResultsService.CreateAllocationLineResultStatusUpdateJobs(message); //Assert logger .Received(1) .Error(Arg.Is($"Could not find the job with id: '{jobId}'")); await jobsApiClient .DidNotReceive() .AddJobLog(Arg.Is(jobId), Arg.Any <JobLogUpdateModel>()); }
public async Task CreateInstructGenerateAggregationsAllocationJob_GivenJobCreated_LogsInformation() { //Arrange JobNotification jobNotification = CreateJobNotification(); string json = JsonConvert.SerializeObject(jobNotification); Message message = new Message(Encoding.UTF8.GetBytes(json)); Job job = new Job { Id = "job-id-1" }; IJobsApiClient jobsApiClient = CreateJobsApiClient(); jobsApiClient .CreateJob(Arg.Any <JobCreateModel>()) .Returns(job); ILogger logger = CreateLogger(); JobService jobService = CreateJobService(jobsApiClient, logger); //Act await jobService.CreateInstructAllocationJob(message); //Assert logger .Received(1) .Information(Arg.Is($"Created new job of type: '{JobConstants.DefinitionNames.CreateInstructAllocationJob}' with id: '{job.Id}'")); }
private static CalculationService CreateCalculationService( ICalculationsRepository calculationsRepository = null, ILogger logger = null, ISearchRepository <CalculationIndex> searchRepository = null, IValidator <Calculation> calcValidator = null, IBuildProjectsService buildProjectsService = null, ISpecificationRepository specificationRepository = null, ICacheProvider cacheProvider = null, ICalcsResiliencePolicies resiliencePolicies = null, IVersionRepository <CalculationVersion> calculationVersionRepository = null, IJobsApiClient jobsApiClient = null, ISourceCodeService sourceCodeService = null, IFeatureToggle featureToggle = null, IBuildProjectsRepository buildProjectsRepository = null, ICalculationCodeReferenceUpdate calculationCodeReferenceUpdate = null) { return(new CalculationService (calculationsRepository ?? CreateCalculationsRepository(), logger ?? CreateLogger(), searchRepository ?? CreateSearchRepository(), calcValidator ?? CreateCalculationValidator(), buildProjectsService ?? CreateBuildProjectsService(), specificationRepository ?? CreateSpecificationRepository(), cacheProvider ?? CreateCacheProvider(), resiliencePolicies ?? CalcsResilienceTestHelper.GenerateTestPolicies(), calculationVersionRepository ?? CreateCalculationVersionRepository(), jobsApiClient ?? CreateJobsApiClient(), sourceCodeService ?? CreateSourceCodeService(), featureToggle ?? CreateFeatureToggle(), buildProjectsRepository ?? CreateBuildProjectsRepository(), calculationCodeReferenceUpdate ?? CreateCalculationCodeReferenceUpdate())); }
public async Task GetJobDetails_ReturnsJobViewModel() { IJobsApiClient jobsApiClient = Substitute.For <IJobsApiClient>(); JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies { JobsApiClient = Policy.NoOpAsync() }; IMessengerService messengerService = Substitute.For <IMessengerService>(); ILogger logger = Substitute.For <ILogger>(); JobViewModel jvm = new JobViewModel { CompletionStatus = null }; ApiResponse <JobViewModel> jobApiResponse = new ApiResponse <JobViewModel>(HttpStatusCode.OK, jvm); jobsApiClient .GetJobById(Arg.Any <string>()) .Returns(jobApiResponse); JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService); string jobId = "3456"; //Act JobViewModel viewModel = await jobManagement.GetJobById(jobId); //Assert viewModel .Should() .Be(jvm); }
public void CreateInstructGenerateAggregationsAllocationJob_GivenCreatingJobReturnsNull_ThrowsException() { //Arrange JobNotification jobNotification = CreateJobNotification(); string json = JsonConvert.SerializeObject(jobNotification); Message message = new Message(Encoding.UTF8.GetBytes(json)); IJobsApiClient jobsApiClient = CreateJobsApiClient(); jobsApiClient .CreateJob(Arg.Any <JobCreateModel>()) .Returns((Job)null); ILogger logger = CreateLogger(); JobService jobService = CreateJobService(jobsApiClient, logger); //Act Func <Task> test = () => jobService.CreateInstructAllocationJob(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 async Task UpdateJobStatus_ApiResponseSuccess_Runs() { //Arrange IJobsApiClient jobsApiClient = Substitute.For <IJobsApiClient>(); JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies { JobsApiClient = Policy.NoOpAsync() }; IMessengerService messengerService = Substitute.For <IMessengerService>(); ILogger logger = Substitute.For <ILogger>(); ApiResponse <JobLog> jobLogApiResponse = new ApiResponse <JobLog>(HttpStatusCode.OK, new JobLog()); jobsApiClient .AddJobLog(Arg.Any <string>(), Arg.Any <JobLogUpdateModel>()) .Returns(jobLogApiResponse); JobLogUpdateModel updateModel = new JobLogUpdateModel(); JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService); string jobId = "3456"; //Act await jobManagement.UpdateJobStatus(jobId, updateModel); //Assert await jobsApiClient .Received(1) .AddJobLog(jobId, updateModel); logger .Received(0) .Write(Arg.Any <LogEventLevel>(), Arg.Any <string>()); }
public async Task RefreshPublishResults_GivenSingleSpecificationId_ShouldReturnNoContentResult() { // Arrange const string specificationId1 = "123"; HttpRequest httpRequest = Substitute.For <HttpRequest>(); ISpecificationsRepository mockSpecificationsRepository = Substitute.For <ISpecificationsRepository>(); mockSpecificationsRepository.GetSpecificationById(Arg.Any <string>()).Returns(new Specification()); SpecificationCalculationExecutionStatus expectedSpecificationStatusCall1 = new SpecificationCalculationExecutionStatus(specificationId1, 0, CalculationProgressStatus.NotStarted); ICacheProvider mockCacheProvider = Substitute.For <ICacheProvider>(); IJobsApiClient jobsApiClient = CreateJobsApiClient(); SpecificationsService specificationsService = CreateService(specificationsRepository: mockSpecificationsRepository, cacheProvider: mockCacheProvider, jobsApiClient: jobsApiClient); httpRequest.Query.Returns(new QueryCollection(new Dictionary <string, StringValues>() { { "specificationId", new StringValues($"{specificationId1}") } })); // Act IActionResult actionResultReturned = await specificationsService.RefreshPublishedResults(httpRequest); // Assert actionResultReturned.Should().BeOfType <NoContentResult>(); await mockCacheProvider.Received().SetAsync($"{CalculationProgressPrependKey}{specificationId1}", expectedSpecificationStatusCall1, TimeSpan.FromHours(6), false); await jobsApiClient.Received(1).CreateJob(Arg.Is <JobCreateModel>(j => j.JobDefinitionId == JobConstants.DefinitionNames.PublishProviderResultsJob && j.SpecificationId == specificationId1 && j.Trigger.Message == $"Refreshing published provider results for specification")); }
public JobsController(IJobsApiClient jobsApiClient, IMapper mapper) { Guard.ArgumentNotNull(jobsApiClient, nameof(jobsApiClient)); _jobsApiClient = jobsApiClient; _mapper = mapper; }
public CosmosDbScalingService( ILogger logger, ICosmosDbScalingRepositoryProvider cosmosDbScalingRepositoryProvider, IJobsApiClient jobsApiClient, ICacheProvider cacheProvider, ICosmosDbScalingConfigRepository cosmosDbScalingConfigRepository, ICosmosDbScallingResilliencePolicies cosmosDbScallingResilliencePolicies, ICosmosDbScalingRequestModelBuilder cosmosDbScalingRequestModelBuilder, ICosmosDbThrottledEventsFilter cosmosDbThrottledEventsFilter) { Guard.ArgumentNotNull(logger, nameof(logger)); Guard.ArgumentNotNull(cosmosDbScalingRepositoryProvider, nameof(cosmosDbScalingRepositoryProvider)); Guard.ArgumentNotNull(jobsApiClient, nameof(jobsApiClient)); Guard.ArgumentNotNull(cacheProvider, nameof(cacheProvider)); Guard.ArgumentNotNull(cosmosDbScalingRepositoryProvider, nameof(cosmosDbScalingRepositoryProvider)); Guard.ArgumentNotNull(cosmosDbScallingResilliencePolicies, nameof(cosmosDbScallingResilliencePolicies)); Guard.ArgumentNotNull(cosmosDbScalingRequestModelBuilder, nameof(cosmosDbScalingRequestModelBuilder)); Guard.ArgumentNotNull(cosmosDbThrottledEventsFilter, nameof(cosmosDbThrottledEventsFilter)); _logger = logger; _cosmosDbScalingRepositoryProvider = cosmosDbScalingRepositoryProvider; _cacheProvider = cacheProvider; _cosmosDbScalingConfigRepository = cosmosDbScalingConfigRepository; _cosmosDbScalingRequestModelBuilder = cosmosDbScalingRequestModelBuilder; _jobsApiClient = jobsApiClient; _scalingRepositoryPolicy = cosmosDbScallingResilliencePolicies.ScalingRepository; _cacheProviderPolicy = cosmosDbScallingResilliencePolicies.CacheProvider; _scalingConfigRepositoryPolicy = cosmosDbScallingResilliencePolicies.ScalingConfigRepository; _jobsApiClientPolicy = cosmosDbScallingResilliencePolicies.JobsApiClient; _cosmosDbThrottledEventsFilter = cosmosDbThrottledEventsFilter; }
public async Task ProcessDeadLetteredMessage_GivenMessageButAddingLogCausesException_LogsAnError() { // Arrange const string jobId = "job-id-1"; Message message = new Message(); message.UserProperties.Add("jobId", jobId); IJobsApiClient jobsApiClient = CreateJobsApiClient(); jobsApiClient .When(x => x.AddJobLog(Arg.Is(jobId), Arg.Any <JobLogUpdateModel>())) .Do(x => { throw new Exception(); }); ILogger logger = CreateLogger(); IJobHelperService service = CreateJobHelperService(jobsApiClient, logger); // Act await service.ProcessDeadLetteredMessage(message); // Assert logger .Received(1) .Error(Arg.Any <Exception>(), Arg.Is($"Failed to add a job log for job id '{jobId}'")); }
public async Task ProcessDeadLetteredMessage_GivenMessageAndLogIsUpdated_LogsInformation() { // Arrange const string jobId = "job-id-1"; JobLog jobLog = new JobLog { Id = "job-log-id-1" }; ApiResponse <JobLog> jobLogResponse = new ApiResponse <JobLog>(HttpStatusCode.OK, jobLog); Message message = new Message(); message.UserProperties.Add("jobId", jobId); IJobsApiClient jobsApiClient = CreateJobsApiClient(); jobsApiClient .AddJobLog(Arg.Is(jobId), Arg.Any <JobLogUpdateModel>()) .Returns(jobLogResponse); ILogger logger = CreateLogger(); IJobHelperService service = CreateJobHelperService(jobsApiClient, logger); // Act await service.ProcessDeadLetteredMessage(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}'")); }
public CalculationProviderResultsPageModel( ICalculationProviderResultsSearchService resultsSearchService, ICalculationsApiClient calculationsApiClient, ISpecsApiClient specsApiClient, IMapper mapper, IDatasetsApiClient datasetsClient, ILogger logger, IJobsApiClient jobsApiClient, IFeatureToggle featureToggle) { Guard.ArgumentNotNull(resultsSearchService, nameof(resultsSearchService)); Guard.ArgumentNotNull(calculationsApiClient, nameof(calculationsApiClient)); Guard.ArgumentNotNull(specsApiClient, nameof(specsApiClient)); Guard.ArgumentNotNull(mapper, nameof(mapper)); Guard.ArgumentNotNull(datasetsClient, nameof(datasetsClient)); Guard.ArgumentNotNull(logger, nameof(logger)); Guard.ArgumentNotNull(jobsApiClient, nameof(jobsApiClient)); Guard.ArgumentNotNull(featureToggle, nameof(featureToggle)); _mapper = mapper; _resultsSearchService = resultsSearchService; _calculationsApiClient = calculationsApiClient; _specsClient = specsApiClient; _datasetsClient = datasetsClient; _jobsClient = jobsApiClient; _logger = logger; ShowExceptionCountAndFacet = featureToggle.IsExceptionMessagesEnabled(); }
public async Task AddJobLog_Called_ReturnsJobLog() { string jobId = "5678"; IJobsApiClient jobsApiClient = Substitute.For <IJobsApiClient>(); JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies { JobsApiClient = Policy.NoOpAsync() }; IMessengerService messengerService = Substitute.For <IMessengerService>(); ILogger logger = Substitute.For <ILogger>(); JobLog jobLog = new JobLog { JobId = jobId }; ApiResponse <JobLog> jobLogApiResponse = new ApiResponse <JobLog>(HttpStatusCode.OK, jobLog); JobLogUpdateModel jobLogUpdateModel = new JobLogUpdateModel(); jobsApiClient .AddJobLog(jobId, jobLogUpdateModel) .Returns(jobLogApiResponse); JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService); //Act JobLog result = await jobManagement.AddJobLog(jobId, jobLogUpdateModel); Assert.AreEqual(result, jobLog); await jobsApiClient .Received(1) .AddJobLog(jobId, jobLogUpdateModel); }
public async Task UpdateJobStatusInternal_ApiResponseFailure_Logs(ApiResponse <JobLog> jobLogApiResponse) { //Arrange IJobsApiClient jobsApiClient = Substitute.For <IJobsApiClient>(); JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies { JobsApiClient = Policy.NoOpAsync() }; IMessengerService messengerService = Substitute.For <IMessengerService>(); ILogger logger = Substitute.For <ILogger>(); jobsApiClient .AddJobLog(Arg.Any <string>(), Arg.Any <JobLogUpdateModel>()) .Returns(jobLogApiResponse); JobLogUpdateModel updateModel = new JobLogUpdateModel(); JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService); string jobId = "3456"; //Act await jobManagement.UpdateJobStatus(jobId, updateModel); //Assert await jobsApiClient .Received(1) .AddJobLog(jobId, updateModel); logger .Received(1) .Write(LogEventLevel.Error, $"Failed to add a job log for job id '{jobId}'"); }
public async Task WaitForJobsToCompleteWithJobsFailed_ReturnsFalse(bool useServiceBus) { IJobsApiClient jobsApiClient = Substitute.For <IJobsApiClient>(); JobManagementResiliencePolicies policies = new JobManagementResiliencePolicies { JobsApiClient = Policy.NoOpAsync() }; IMessengerService messengerService = null; if (useServiceBus) { messengerService = Substitute.For <IMessengerService, IServiceBusService>(); } else { messengerService = Substitute.For <IMessengerService, IQueueService>(); } ILogger logger = Substitute.For <ILogger>(); JobManagement jobManagement = new JobManagement(jobsApiClient, logger, policies, messengerService); string jobId = "3456"; jobsApiClient .GetLatestJobsForSpecification("specificationId", Arg.Is <string[]>(_ => _.Single() == "PopulateScopedProviders")) .Returns(new ApiResponse <IDictionary <string, JobSummary> >(HttpStatusCode.OK, new Dictionary <string, JobSummary> { { string.Empty, new JobSummary { RunningStatus = RunningStatus.Completed, CompletionStatus = CompletionStatus.Failed, JobId = jobId } } })); messengerService .ReceiveMessage("topic/Subscriptions/correlationId", Arg.Any <Predicate <JobSummary> >(), TimeSpan.FromMilliseconds(600000)) .Returns(new JobSummary { CompletionStatus = CompletionStatus.Failed }); //Act bool jobsComplete = await jobManagement.QueueJobAndWait(async() => await Task.Run(() => { return(true); }), "PopulateScopedProviders", "specificationId", "correlationId", "topic"); //Assert if (useServiceBus) { await((IServiceBusService)messengerService) .Received(1) .CreateSubscription("topic", "correlationId", Arg.Is <TimeSpan>(_ => _.Days == 1)); await messengerService .Received(1) .ReceiveMessage("topic/Subscriptions/correlationId", Arg.Any <Predicate <JobSummary> >(), TimeSpan.FromMilliseconds(600000)); } jobsComplete .Should() .BeFalse(); }
private IJobHelperService CreateJobHelperService(IJobsApiClient jobsApiClient, ILogger logger = null) { IJobHelperResiliencePolicies resiliencePolicies = Substitute.For <IJobHelperResiliencePolicies>(); resiliencePolicies.JobsApiClient.Returns(Polly.Policy.NoOpAsync()); return(new JobHelperService(jobsApiClient ?? CreateJobsApiClient(), resiliencePolicies, logger ?? CreateLogger())); }
public async Task SelectSpecificationForFunding_GivenValidSpecification_ReturnsNoContentResult() { // Arrange IQueryCollection queryStringValues = new QueryCollection(new Dictionary <string, StringValues> { { "specificationId", new StringValues(SpecificationId) } }); HttpRequest request = Substitute.For <HttpRequest>(); request .Query .Returns(queryStringValues); Specification specification = CreateSpecification(); ILogger logger = CreateLogger(); ISpecificationsRepository specificationsRepository = CreateSpecificationsRepository(); specificationsRepository .GetSpecificationById(Arg.Is(SpecificationId)) .Returns(specification); specificationsRepository .UpdateSpecification(Arg.Is(specification)) .Returns(HttpStatusCode.OK); IJobsApiClient jobsApiClient = CreateJobsApiClient(); ICacheProvider cacheProvider = CreateCacheProvider(); SpecificationsService service = CreateService( logs: logger, specificationsRepository: specificationsRepository, jobsApiClient: jobsApiClient, cacheProvider: cacheProvider); // Act IActionResult result = await service.SelectSpecificationForFunding(request); // Assert result .Should() .BeOfType <NoContentResult>(); await jobsApiClient .Received(1) .CreateJob(Arg.Is <JobCreateModel>(j => j.JobDefinitionId == JobConstants.DefinitionNames.PublishProviderResultsJob && j.SpecificationId == SpecificationId && j.Trigger.Message == $"Selecting specification for funding")); await cacheProvider .Received(1) .RemoveAsync <SpecificationSummary>($"{CacheKeys.SpecificationSummaryById}{specification.Id}"); await cacheProvider .Received(1) .RemoveAsync <SpecificationCurrentVersion>($"{CacheKeys.SpecificationCurrentVersionById}{specification.Id}"); }
public JobHelperService(IJobsApiClient jobsApiClient, IJobHelperResiliencePolicies resiliencePolicies, ILogger logger) { Guard.ArgumentNotNull(jobsApiClient, nameof(jobsApiClient)); Guard.ArgumentNotNull(resiliencePolicies, nameof(resiliencePolicies)); Guard.ArgumentNotNull(logger, nameof(logger)); _jobsApiClient = jobsApiClient; _jobsApiClientPolicy = resiliencePolicies.JobsApiClient; _logger = logger; }
public PublishedFundingUndoJobCreation(IJobsApiClient jobs, IPublishingResiliencePolicies resilience, ILogger logger) { Guard.ArgumentNotNull(jobs, nameof(jobs)); Guard.ArgumentNotNull(resilience?.JobsApiClient, nameof(resilience.JobsApiClient)); Guard.ArgumentNotNull(logger, nameof(logger)); _jobs = jobs; _resilience = resilience.JobsApiClient; _logger = logger; }
public JobManagement(IJobsApiClient jobsApiClient, ILogger logger, IJobManagementResiliencePolicies jobManagementResiliencePolicies) { Guard.ArgumentNotNull(jobsApiClient, nameof(jobsApiClient)); Guard.ArgumentNotNull(logger, nameof(logger)); Guard.ArgumentNotNull(jobManagementResiliencePolicies, nameof(jobManagementResiliencePolicies)); _jobsApiClient = jobsApiClient; _logger = logger; _jobsApiClientPolicy = jobManagementResiliencePolicies.JobsApiClient; }
protected static IJobManagement CreateJobManagement( IJobsApiClient jobsApiClient = null, ILogger logger = null, IMessengerService messengerService = null) { return(new JobManagement(jobsApiClient ?? CreateJobsApiClient(), logger ?? CreateLogger(), new JobManagementResiliencePolicies { JobsApiClient = NoOpPolicy.NoOpAsync() }, messengerService ?? CreateMessengerService())); }
public void CreateAllocationLineResultStatusUpdateJobs_GivenJobFoundButModelNotFoundInCache_LogsAndThrowsException() { //Arrange const string cacheKey = "cache-key"; Message message = new Message(); message.UserProperties.Add("jobId", jobId); ILogger logger = CreateLogger(); JobViewModel job = new JobViewModel { Id = jobId, Properties = new Dictionary <string, string> { { "cache-key", cacheKey } } }; ApiResponse <JobViewModel> apiResponse = new ApiResponse <JobViewModel>(HttpStatusCode.OK, job); IJobsApiClient jobsApiClient = CreateJobsApiClient(); jobsApiClient .GetJobById(jobId) .Returns(apiResponse); ICacheProvider cacheProvider = CreateCacheProvider(); cacheProvider .GetAsync <UpdatePublishedAllocationLineResultStatusModel>(Arg.Is(cacheKey)) .Returns((UpdatePublishedAllocationLineResultStatusModel)null); PublishedResultsService publishedResultsService = CreateResultsService(logger, jobsApiClient: jobsApiClient, cacheProvider: cacheProvider); //Act Func <Task> test = async() => await publishedResultsService.CreateAllocationLineResultStatusUpdateJobs(message); //Assert test .Should() .ThrowExactly <Exception>() .Which .Message .Should() .Be($"Could not find the update model in cache with cache key: '{cacheKey}'"); logger .Received(1) .Error(Arg.Is($"Could not find the update model in cache with cache key: '{cacheKey}'")); }
public async Task RegenerateProviderSourceDatasets_GivenSpecificationId_ThenCallJobServiceToProcess() { // Arrange IQueryCollection queryStringValues = new QueryCollection(new Dictionary <string, StringValues> { { "specificationId", new StringValues(SpecificationId) }, }); HttpRequest request = Substitute.For <HttpRequest>(); request.Query.Returns(queryStringValues); IDatasetRepository datasetRepository = CreateDatasetsRepository(); datasetRepository .GetDefinitionSpecificationRelationshipsByQuery(Arg.Any <Expression <Func <DefinitionSpecificationRelationship, bool> > >()) .Returns(new List <DefinitionSpecificationRelationship> { new DefinitionSpecificationRelationship { DatasetVersion = new DatasetRelationshipVersion { Id = "DSRV1", Version = 1 }, Specification = new Common.Models.Reference { Id = SpecificationId, Name = "SpecAbc" } } }); datasetRepository .GetDatasetsByQuery(Arg.Any <Expression <Func <Dataset, bool> > >()) .Returns(new List <Dataset> { new Dataset { Id = "DS1" } }); IJobsApiClient jobsApiClient = CreateJobsApiClient(); DatasetService service = CreateDatasetService(datasetRepository: datasetRepository, jobsApiClient: jobsApiClient); // Act await service.RegenerateProviderSourceDatasets(request); // Assert await jobsApiClient .Received(1) .CreateJob(Arg.Is <JobCreateModel>(j => j.JobDefinitionId == "MapDatasetJob" && j.Properties.ContainsKey("session-id") && j.Properties["session-id"] == SpecificationId)); }
static TemplateSearchService CreateTemplateSearchService( ILogger logger = null, ISearchRepository <TemplateIndex> searchRepository = null, IJobsApiClient jobsApiClient = null) { return(new TemplateSearchService( logger ?? CreateLogger(), searchRepository ?? CreateSearchRepository(), new PolicyResiliencePolicies { JobsApiClient = Polly.Policy.NoOpAsync() }, jobsApiClient ?? CreateJobsApiClient())); }
public ProcessDatasetService( IDatasetRepository datasetRepository, IExcelDatasetReader excelDatasetReader, ICacheProvider cacheProvider, ICalcsRepository calcsRepository, IBlobClient blobClient, IMessengerService messengerService, IProvidersResultsRepository providersResultsRepository, IResultsRepository resultsRepository, IProviderService providerService, IVersionRepository <ProviderSourceDatasetVersion> sourceDatasetsVersionRepository, ILogger logger, ITelemetry telemetry, IDatasetsResiliencePolicies datasetsResiliencePolicies, IDatasetsAggregationsRepository datasetsAggregationsRepository, IFeatureToggle featureToggle, IJobsApiClient jobsApiClient) { Guard.ArgumentNotNull(datasetRepository, nameof(datasetRepository)); Guard.ArgumentNotNull(excelDatasetReader, nameof(excelDatasetReader)); Guard.ArgumentNotNull(cacheProvider, nameof(cacheProvider)); Guard.ArgumentNotNull(messengerService, nameof(messengerService)); Guard.ArgumentNotNull(calcsRepository, nameof(calcsRepository)); Guard.ArgumentNotNull(providersResultsRepository, nameof(providersResultsRepository)); Guard.ArgumentNotNull(resultsRepository, nameof(resultsRepository)); Guard.ArgumentNotNull(providerService, nameof(providerService)); Guard.ArgumentNotNull(logger, nameof(logger)); Guard.ArgumentNotNull(telemetry, nameof(telemetry)); Guard.ArgumentNotNull(datasetsAggregationsRepository, nameof(datasetsAggregationsRepository)); Guard.ArgumentNotNull(featureToggle, nameof(featureToggle)); Guard.ArgumentNotNull(jobsApiClient, nameof(jobsApiClient)); _datasetRepository = datasetRepository; _excelDatasetReader = excelDatasetReader; _cacheProvider = cacheProvider; _calcsRepository = calcsRepository; _blobClient = blobClient; _providersResultsRepository = providersResultsRepository; _resultsRepository = resultsRepository; _providerService = providerService; _sourceDatasetsVersionRepository = sourceDatasetsVersionRepository; _logger = logger; _telemetry = telemetry; _providerResultsRepositoryPolicy = datasetsResiliencePolicies.ProviderResultsRepository; _datasetsAggregationsRepository = datasetsAggregationsRepository; _featureToggle = featureToggle; _jobsApiClient = jobsApiClient; _jobsApiClientPolicy = datasetsResiliencePolicies.JobsApiClient; _messengerService = messengerService; }
public JobManagement(IJobsApiClient jobsApiClient, ILogger logger, IJobManagementResiliencePolicies jobManagementResiliencePolicies, IMessengerService messengerService) { Guard.ArgumentNotNull(jobsApiClient, nameof(jobsApiClient)); Guard.ArgumentNotNull(logger, nameof(logger)); Guard.ArgumentNotNull(jobManagementResiliencePolicies, nameof(jobManagementResiliencePolicies)); Guard.ArgumentNotNull(messengerService, nameof(messengerService)); _jobsApiClient = jobsApiClient; _logger = logger; _jobsApiClientPolicy = jobManagementResiliencePolicies.JobsApiClient; _messengerService = messengerService; }
public void SetUp() { _datasetRepository = CreateDatasetsRepository(); _jobsApiClient = CreateJobsApiClient(); _messengerService = CreateMessengerService(); _jobManagement = CreateJobManagement(_jobsApiClient, _logger, _messengerService); _logger = CreateLogger(); _service = CreateProcessDatasetService( datasetRepository: _datasetRepository, jobManagement: _jobManagement, messengerService: _messengerService, logger: _logger); _message = new Message(); }
public TemplateSearchService(ILogger logger, ISearchRepository <TemplateIndex> searchRepository, IPolicyResiliencePolicies resiliencePolicies, IJobsApiClient jobs) { Guard.ArgumentNotNull(searchRepository, nameof(searchRepository)); Guard.ArgumentNotNull(jobs, nameof(jobs)); Guard.ArgumentNotNull(resiliencePolicies, nameof(resiliencePolicies)); Guard.ArgumentNotNull(resiliencePolicies?.JobsApiClient, nameof(resiliencePolicies.JobsApiClient)); Guard.ArgumentNotNull(logger, nameof(logger)); _logger = logger; _searchRepository = searchRepository; _jobs = jobs; _jobsClientPolicy = resiliencePolicies.JobsApiClient; }
static PublishedResultsService CreateResultsService(ILogger logger = null, IMapper mapper = null, ITelemetry telemetry = null, ICalculationResultsRepository resultsRepository = null, ISpecificationsRepository specificationsRepository = null, IResultsResiliencePolicies resiliencePolicies = null, IPublishedProviderResultsAssemblerService publishedProviderResultsAssemblerService = null, IPublishedProviderResultsRepository publishedProviderResultsRepository = null, ICacheProvider cacheProvider = null, ISearchRepository <AllocationNotificationFeedIndex> allocationNotificationFeedSearchRepository = null, IProfilingApiClient profilingApiClient = null, IMessengerService messengerService = null, IVersionRepository <PublishedAllocationLineResultVersion> publishedProviderResultsVersionRepository = null, IPublishedAllocationLineLogicalResultVersionService publishedAllocationLineLogicalResultVersionService = null, IFeatureToggle featureToggle = null, IJobsApiClient jobsApiClient = null, IPublishedProviderResultsSettings publishedProviderResultsSettings = null, IProviderChangesRepository providerChangesRepository = null, IProviderVariationsService providerVariationsService = null, IProviderVariationsStorageRepository providerVariationsStorageRepository = null) { ISpecificationsRepository specsRepo = specificationsRepository ?? CreateSpecificationsRepository(); return(new PublishedResultsService( logger ?? CreateLogger(), mapper ?? CreateMapper(), telemetry ?? CreateTelemetry(), resultsRepository ?? CreateResultsRepository(), specsRepo, resiliencePolicies ?? ResultsResilienceTestHelper.GenerateTestPolicies(), publishedProviderResultsAssemblerService ?? CreateResultsAssembler(), publishedProviderResultsRepository ?? CreatePublishedProviderResultsRepository(), cacheProvider ?? CreateCacheProvider(), allocationNotificationFeedSearchRepository ?? CreateAllocationNotificationFeedSearchRepository(), profilingApiClient ?? CreateProfilingRepository(), messengerService ?? CreateMessengerService(), publishedProviderResultsVersionRepository ?? CreatePublishedProviderResultsVersionRepository(), publishedAllocationLineLogicalResultVersionService ?? CreatePublishedAllocationLineLogicalResultVersionService(), featureToggle ?? CreateFeatureToggle(), jobsApiClient ?? CreateJobsApiClient(), publishedProviderResultsSettings ?? CreatePublishedProviderResultsSettings(), providerChangesRepository ?? CreateProviderChangesRepository(), providerVariationsService ?? CreateProviderVariationsService(CreateProviderVariationAssemblerService(), specsRepo), providerVariationsStorageRepository ?? CreateProviderVariationsStorageRepository() )); }
public BuildProjectsService( ILogger logger, ITelemetry telemetry, IProviderResultsRepository providerResultsRepository, ISpecificationRepository specificationsRepository, ICacheProvider cacheProvider, ICalculationsRepository calculationsRepository, IFeatureToggle featureToggle, IJobsApiClient jobsApiClient, ICalcsResiliencePolicies resiliencePolicies, EngineSettings engineSettings, ISourceCodeService sourceCodeService, IDatasetRepository datasetRepository, IBuildProjectsRepository buildProjectsRepository) { Guard.ArgumentNotNull(logger, nameof(logger)); Guard.ArgumentNotNull(telemetry, nameof(telemetry)); Guard.ArgumentNotNull(providerResultsRepository, nameof(providerResultsRepository)); Guard.ArgumentNotNull(specificationsRepository, nameof(specificationsRepository)); Guard.ArgumentNotNull(cacheProvider, nameof(cacheProvider)); Guard.ArgumentNotNull(calculationsRepository, nameof(calculationsRepository)); Guard.ArgumentNotNull(featureToggle, nameof(featureToggle)); Guard.ArgumentNotNull(jobsApiClient, nameof(jobsApiClient)); Guard.ArgumentNotNull(resiliencePolicies, nameof(resiliencePolicies)); Guard.ArgumentNotNull(engineSettings, nameof(engineSettings)); Guard.ArgumentNotNull(sourceCodeService, nameof(sourceCodeService)); Guard.ArgumentNotNull(datasetRepository, nameof(datasetRepository)); Guard.ArgumentNotNull(buildProjectsRepository, nameof(buildProjectsRepository)); _logger = logger; _telemetry = telemetry; _providerResultsRepository = providerResultsRepository; _specificationsRepository = specificationsRepository; _cacheProvider = cacheProvider; _calculationsRepository = calculationsRepository; _featureToggle = featureToggle; _jobsApiClient = jobsApiClient; _jobsApiClientPolicy = resiliencePolicies.JobsApiClient; _engineSettings = engineSettings; _sourceCodeService = sourceCodeService; _datasetRepository = datasetRepository; _datasetRepositoryPolicy = resiliencePolicies.DatasetsRepository; _buildProjectsRepository = buildProjectsRepository; _buildProjectsRepositoryPolicy = resiliencePolicies.BuildProjectRepositoryPolicy; }