public async Task Run_Logs_Debug_Message() { var request = new AppealFileExtractRequest(new AppealFile()); await _sut.Run(request); _logger.Verify(x => x.Log(LogLevel.Debug, It.IsAny <EventId>(), It.IsAny <It.IsAnyType>(), It.IsAny <Exception>(), It.IsAny <Func <It.IsAnyType, Exception, string> >()), Times.AtLeastOnce); }
public async Task Run_Downloads_and_Saves_Appeal_File_Into_BlobStorage() { var appealfile = new AppealFile { ApplicationId = _applicationId, FileName = "file.pdf" }; var request = new AppealFileExtractRequest(appealfile); await _sut.Run(request); _applyApiClient.Verify(x => x.DownloadAppealFile(_applicationId, appealfile.FileName), Times.Once); _blobClient.Verify(x => x.UploadAsync(It.IsAny <Stream>(), true, It.IsAny <CancellationToken>()), Times.Once); }
public async Task Run([ServiceBusTrigger("%AppealFileExtractQueue%", Connection = "DASServiceBusConnectionString")] AppealFileExtractRequest fileToExtract) { _logger.LogDebug($"Saving appeal file into Datamart for application {fileToExtract.ApplicationId} and filename: {fileToExtract.FileName}"); var blobContainerClient = await _datamartBlobStorageFactory.GetAppealBlobContainerClient(); try { await using var filestream = await _applyApiClient.DownloadAppealFile(fileToExtract.ApplicationId, fileToExtract.FileName); var blobName = $"{fileToExtract.ApplicationId}/Appeal/{fileToExtract.FileName}"; var blobClient = blobContainerClient.GetBlobClient(blobName); await blobClient.UploadAsync(filestream, overwrite : true); _logger.LogInformation($"Saved appeal file into Datamart for application {fileToExtract.ApplicationId} and filename: {fileToExtract.FileName}. Data-mart path: {blobName}"); } catch (Exception ex) { _logger.LogError(ex, $"Unable to save appeal file into Datamart for application {fileToExtract.ApplicationId} and filename: {fileToExtract.FileName}"); throw; } }