コード例 #1
0
        private void AndRetrieveJobAndCheckCanBeProcessedSuccessfully(Action <JobViewModelBuilder> setUp = null)
        {
            JobViewModelBuilder jobViewModelBuilder = new JobViewModelBuilder();

            setUp?.Invoke(jobViewModelBuilder);

            _job = jobViewModelBuilder.Build();

            _jobManagement.RetrieveJobAndCheckCanBeProcessed(_jobId)
            .Returns(_job);
        }
コード例 #2
0
        private void GivenTheJobForTheJobId(Action <JobViewModelBuilder> setUp = null)
        {
            JobViewModelBuilder jobViewModelBuilder = new JobViewModelBuilder();

            setUp?.Invoke(jobViewModelBuilder);

            _job = jobViewModelBuilder.Build();

            _jobs.RetrieveJobAndCheckCanBeProcessed(_jobId)
            .Returns(_job);
        }
        public void PublishAllProviderFundingResults_GivenJobCannotBeProcessed_ThrowsException()
        {
            _jobManagement
            .RetrieveJobAndCheckCanBeProcessed(JobId)
            .Throws(new JobNotFoundException(string.Empty, JobId));

            Func <Task> invocation = WhenPublishAllProvidersMessageReceivedWithJobId;

            invocation
            .Should()
            .Throw <NonRetriableException>()
            .And
            .Message
            .Should()
            .Be($"Could not find the job with id: '{JobId}'");
        }
コード例 #4
0
        private async Task <JobViewModel> EnsureJobCanBeProcessed(string jobId)
        {
            try
            {
                return(await _jobManagement.RetrieveJobAndCheckCanBeProcessed(jobId));
            }
            catch (JobNotFoundException)
            {
                string errorMessage = $"Could not find the job with id: '{jobId}'";
                _logger.Error(errorMessage);

                throw new NonRetriableException(errorMessage);
            }
            catch (JobAlreadyCompletedException jobCompletedException)
            {
                string errorMessage = $"Received job with id: '{jobId}' is already in a completed state with status '{jobCompletedException.Job.CompletionStatus}'";
                _logger.Error(errorMessage);

                throw new NonRetriableException(errorMessage);
            }
            catch
            {
                string errorMessage = $"Job can not be run '{jobId}'";
                _logger.Error(errorMessage);

                throw new NonRetriableException(errorMessage);
            }
        }
 private void AndTheJobCanBeRun()
 {
     _jobManagement.RetrieveJobAndCheckCanBeProcessed(_jobId)
     .Returns(new JobViewModel {
         Id = _jobId
     });
 }
        private void GivenJobCanBeProcessed()
        {
            JobViewModel jobViewModel = NewJobViewModel();

            _jobManagement.RetrieveJobAndCheckCanBeProcessed(JobId)
            .Returns(jobViewModel);
        }
        protected IJobManagement CreateJobManagement()
        {
            IJobManagement jobManagement = Substitute.For <IJobManagement>();

            jobManagement
            .RetrieveJobAndCheckCanBeProcessed(JobId)
            .Returns(new JobViewModel {
                Id = JobId
            });

            return(jobManagement);
        }
コード例 #8
0
        public async Task ReIndexesAllPublishedProvidersIfJobCanBeProcessed()
        {
            Message message = new Message();

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

            _jobManagement.RetrieveJobAndCheckCanBeProcessed(JobId)
            .Returns(NewJobViewModel());

            await _service.Run(message);

            await _jobManagement
            .Received(1)
            .UpdateJobStatus(JobId, 0, 0, null, null);

            await _publishedFundingRepository
            .Received(1)
            .AllPublishedProviderBatchProcessing(Arg.Any <Func <List <PublishedProvider>, Task> >(), Arg.Is(1000), null);

            await _jobManagement
            .Received(1)
            .UpdateJobStatus(JobId, 0, 0, true, null);
        }
        public void ShouldRaiseException_WhenNoIndexWriterTypeGivenOnMessageUserProperties()
        {
            Message message = new Message();
            string  jobId   = Guid.NewGuid().ToString();

            message.UserProperties["jobId"] = jobId;
            string expectedErrorMessage = $"Index-writer-type missing from SearchIndexWriter job. JobId {jobId}";

            _jobManagement.RetrieveJobAndCheckCanBeProcessed(jobId).Returns(new JobViewModel()
            {
                Id = jobId
            });

            Func <Task> test = async() => await _service.Run(message);

            test
            .Should()
            .ThrowExactly <Exception>()
            .Which
            .Message
            .Should()
            .Be(expectedErrorMessage);
        }
コード例 #10
0
        public async Task <bool> TryStartTrackingJob(string jobId, string jobType)
        {
            try
            {
                await _jobs.RetrieveJobAndCheckCanBeProcessed(jobId);
            }
            catch (JobNotFoundException ex)
            {
                throw new NonRetriableException(ex.Message);
            }
            catch (JobAlreadyCompletedException)
            {
                return(false);
            }

            await AddJobLog(new JobLogUpdateModel
            {
                ItemsFailed    = 0,
                ItemsProcessed = 0,
                ItemsSucceeded = 0
            }, jobId);

            return(true);
        }