private void AndCalculationEngineRunningForPublishAllProviders()
        {
            string[] jobTypes = new string[] {
                JobConstants.DefinitionNames.RefreshFundingJob,
                JobConstants.DefinitionNames.ApproveAllProviderFundingJob,
                JobConstants.DefinitionNames.ApproveBatchProviderFundingJob,
                JobConstants.DefinitionNames.ReIndexPublishedProvidersJob,
                JobConstants.DefinitionNames.PublishBatchProviderFundingJob
            };

            _jobsRunning
            .GetJobTypes(Arg.Is(SpecificationId), Arg.Is <IEnumerable <string> >(_ => _.All(jt => jobTypes.Contains(jt))))
            .Returns(new[] { JobConstants.DefinitionNames.RefreshFundingJob });
        }
Exemple #2
0
        protected async Task BasePerformChecks <T>(T prereqObject, string specificationId, string jobId, string[] jobDefinitions, IEnumerable <PublishedProvider> publishedProviders = null, IEnumerable <Provider> providers = null)
        {
            IEnumerable <string> jobTypesRunning = await _jobsRunning.GetJobTypes(specificationId, jobDefinitions);

            List <string> results = new List <string>();

            if (!jobTypesRunning.IsNullOrEmpty())
            {
                results.AddRange(jobTypesRunning.Select(_ => $"{_} is still running"));
                _logger.Error(string.Join(Environment.NewLine, results));
            }

            results.AddRange(await PerformChecks(prereqObject, publishedProviders, providers) ?? new string[0]);

            if (!results.IsNullOrEmpty())
            {
                if (!string.IsNullOrEmpty(jobId))
                {
                    await _jobManagement.UpdateJobStatus(jobId, completedSuccessfully : false, outcome : string.Join(", ", results));
                }

                string errorMessage = $"Specification with id: '{specificationId} has prerequisites which aren't complete.";
                throw new JobPrereqFailedException(errorMessage, results);
            }
        }
 private void GivenCalculationEngineRunningStatusForTheSpecification(string specificationId, params string[] jobDefinitions)
 {
     _jobsRunning.GetJobTypes(specificationId, Arg.Any <string[]>())
     .Returns(jobDefinitions);
 }