diff --git a/source/settlement-report/SettlementReports.Application/SettlementReports_v2/ISettlementReportRepository.cs b/source/settlement-report/SettlementReports.Application/SettlementReports_v2/ISettlementReportRepository.cs index 972fff1..326264e 100644 --- a/source/settlement-report/SettlementReports.Application/SettlementReports_v2/ISettlementReportRepository.cs +++ b/source/settlement-report/SettlementReports.Application/SettlementReports_v2/ISettlementReportRepository.cs @@ -32,5 +32,5 @@ public interface ISettlementReportRepository Task> GetForJobsAsync(Guid actorId); - Task> GetNeedsNotificationSentForCompletedAndFailed(); + Task> GetPendingNotificationsForCompletedAndFailed(); } diff --git a/source/settlement-report/SettlementReports.Function/Program.cs b/source/settlement-report/SettlementReports.Function/Program.cs index ee8dd8c..529352d 100644 --- a/source/settlement-report/SettlementReports.Function/Program.cs +++ b/source/settlement-report/SettlementReports.Function/Program.cs @@ -22,11 +22,7 @@ using Microsoft.Extensions.Hosting; var host = new HostBuilder() - .ConfigureFunctionsWebApplication(worker => - { - // Http => Authentication - worker.UseUserMiddlewareForIsolatedWorker(); - }) + .ConfigureFunctionsWebApplication() .ConfigureServices((context, services) => { // Common diff --git a/source/settlement-report/SettlementReports.Infrastructure/Notifications/IntegrationEventProvider.cs b/source/settlement-report/SettlementReports.Infrastructure/Notifications/IntegrationEventProvider.cs index cc18075..7afa1fc 100644 --- a/source/settlement-report/SettlementReports.Infrastructure/Notifications/IntegrationEventProvider.cs +++ b/source/settlement-report/SettlementReports.Infrastructure/Notifications/IntegrationEventProvider.cs @@ -32,7 +32,7 @@ public IntegrationEventProvider(ISettlementReportRepository settlementReportRepo public async IAsyncEnumerable GetAsync() { var reportsForNotifications = await _settlementReportRepository - .GetNeedsNotificationSentForCompletedAndFailed() + .GetPendingNotificationsForCompletedAndFailed() .ConfigureAwait(false); foreach (var reportForNotification in reportsForNotifications) diff --git a/source/settlement-report/SettlementReports.Infrastructure/Persistence/SettlementReportRequest/SettlementReportRepository.cs b/source/settlement-report/SettlementReports.Infrastructure/Persistence/SettlementReportRequest/SettlementReportRepository.cs index 4998f11..df7b08d 100644 --- a/source/settlement-report/SettlementReports.Infrastructure/Persistence/SettlementReportRequest/SettlementReportRepository.cs +++ b/source/settlement-report/SettlementReports.Infrastructure/Persistence/SettlementReportRequest/SettlementReportRepository.cs @@ -91,7 +91,7 @@ public async Task DeleteAsync(Application.SettlementReports_v2.SettlementReport .ConfigureAwait(false); } - public async Task> GetNeedsNotificationSentForCompletedAndFailed() + public async Task> GetPendingNotificationsForCompletedAndFailed() { return await _context.SettlementReports .Where(x => x.IsNotificationSent == false && (x.Status == SettlementReportStatus.Completed || x.Status == SettlementReportStatus.Failed)) diff --git a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/Persistence/SettlementReportRepositoryTests.cs b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/Persistence/SettlementReportRepositoryTests.cs index 5150cdb..0ac28f5 100644 --- a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/Persistence/SettlementReportRepositoryTests.cs +++ b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/Persistence/SettlementReportRepositoryTests.cs @@ -325,7 +325,7 @@ await PrepareNewRequestAsync(requestFilterDto => var repository = new SettlementReportRepository(context); // act - var actual = (await repository.GetNeedsNotificationSentForCompletedAndFailed()).ToList(); + var actual = (await repository.GetPendingNotificationsForCompletedAndFailed()).ToList(); // assert Assert.Empty(actual); @@ -348,7 +348,7 @@ public async Task GetForNotificationAsync_ReturnsCorrect_WhenTheyArePresent() request.MarkAsCompleted(SystemClock.Instance, new GeneratedSettlementReportDto(new SettlementReportRequestId(request.Id.ToString()), "test.zip", [])); return request; }); - await PrepareNewRequestAsync(requestFilterDto => + var alreadySent = await PrepareNewRequestAsync(requestFilterDto => { var request = new SettlementReport.Application.SettlementReports_v2.SettlementReport( SystemClock.Instance, @@ -366,11 +366,15 @@ await PrepareNewRequestAsync(requestFilterDto => var repository = new SettlementReportRepository(context); // act - var actual = (await repository.GetNeedsNotificationSentForCompletedAndFailed()).ToList(); + var actual = (await repository.GetPendingNotificationsForCompletedAndFailed()).ToList(); + var actualSent = await repository.GetAsync(alreadySent.RequestId); // assert Assert.Single(actual); + Assert.NotNull(actualSent); Assert.Equal(expected.Id, actual[0].Id); + Assert.False(actual[0].IsNotificationSent); + Assert.True(actualSent.IsNotificationSent); } private async Task PrepareNewRequestAsync(Func? createReport = null)