public async Task ShouldProcessTheMessageSuccesfully_WhenIndexProcessorAvailableForGiveIndexWriterType() { Message message = new Message(); string jobId = Guid.NewGuid().ToString(); message.UserProperties["jobId"] = jobId; message.UserProperties["index-writer-type"] = SearchIndexWriterTypes.ProviderCalculationResultsIndexWriter; _jobManagement.GetJobById(jobId).Returns(new JobViewModel() { Id = jobId }); _searchIndexProcessorFactory.CreateProcessor(SearchIndexWriterTypes.ProviderCalculationResultsIndexWriter) .Returns(_searchIndexProcessor); await _service.Process(message); _searchIndexProcessorFactory .Received(1) .CreateProcessor(SearchIndexWriterTypes.ProviderCalculationResultsIndexWriter); await _searchIndexProcessor .Received(1) .Process(message); }
public override async Task Process(Message message) { Guard.ArgumentNotNull(message, nameof(message)); try { string indexWriterType = message.GetUserProperty <string>("index-writer-type"); if (string.IsNullOrWhiteSpace(indexWriterType)) { string errorMessage = $"Index-writer-type missing from SearchIndexWriter job. JobId {Job.Id}"; _logger.Error(errorMessage); throw new Exception(errorMessage); } ISearchIndexProcessor processor = _searchIndexProcessorFactory.CreateProcessor(indexWriterType); await processor.Process(message); } catch (Exception exception) { _logger.Error(exception, $"Failed to run SearchIndexWriter with exception: {exception.Message}, for job id '{Job.Id}'"); throw; } }