From fe697403fe33c0923af379dd4c90f20f5c20b8c8 Mon Sep 17 00:00:00 2001 From: Vitalie Belinschi Date: Tue, 10 Sep 2024 11:15:34 +0200 Subject: [PATCH] set ended time --- .../SettlementReports_v2/GetSettlementReportsHandler.cs | 4 +++- .../SettlementReportFinalizeHandler.cs | 8 ++++++-- .../GetSettlementReportsHandlerIntegrationTests.cs | 2 +- .../SettlementReportDownloadHandlerIntegrationTests.cs | 8 ++++---- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/source/settlement-report/SettlementReports.Application/SettlementReports_v2/GetSettlementReportsHandler.cs b/source/settlement-report/SettlementReports.Application/SettlementReports_v2/GetSettlementReportsHandler.cs index 32abdf0..5fe51d7 100644 --- a/source/settlement-report/SettlementReports.Application/SettlementReports_v2/GetSettlementReportsHandler.cs +++ b/source/settlement-report/SettlementReports.Application/SettlementReports_v2/GetSettlementReportsHandler.cs @@ -63,6 +63,8 @@ private static RequestedSettlementReportDto Map(SettlementReport report) report.GridAreaCount, 0, report.ActorId, - report.ContainsBasisData); + report.ContainsBasisData, + report.CreatedDateTime.ToDateTimeOffset(), + report.EndedDateTime?.ToDateTimeOffset()); } } diff --git a/source/settlement-report/SettlementReports.Application/SettlementReports_v2/SettlementReportFinalizeHandler.cs b/source/settlement-report/SettlementReports.Application/SettlementReports_v2/SettlementReportFinalizeHandler.cs index 8e9e186..ceb621d 100644 --- a/source/settlement-report/SettlementReports.Application/SettlementReports_v2/SettlementReportFinalizeHandler.cs +++ b/source/settlement-report/SettlementReports.Application/SettlementReports_v2/SettlementReportFinalizeHandler.cs @@ -14,20 +14,24 @@ using Energinet.DataHub.SettlementReport.Interfaces.SettlementReports_v2; using Energinet.DataHub.SettlementReport.Interfaces.SettlementReports_v2.Models; +using NodaTime; namespace Energinet.DataHub.SettlementReport.Application.SettlementReports_v2; public sealed class SettlementReportFinalizeHandler : ISettlementReportFinalizeHandler { + private readonly IClock _clock; private readonly ISettlementReportFileRepository _fileRepository; private readonly ISettlementReportRepository _repository; public SettlementReportFinalizeHandler( ISettlementReportFileRepository fileRepository, - ISettlementReportRepository repository) + ISettlementReportRepository repository, + IClock clock) { _fileRepository = fileRepository; _repository = repository; + _clock = clock; } public async Task FinalizeAsync(GeneratedSettlementReportDto generatedReport) @@ -43,7 +47,7 @@ await _fileRepository .GetAsync(generatedReport.RequestId.Id) .ConfigureAwait(false); - request.MarkAsCompleted(generatedReport); + request.MarkAsCompleted(_clock, generatedReport); await _repository .AddOrUpdateAsync(request) diff --git a/source/settlement-report/SettlementReports.IntegrationTests/Application/SettlementReports/GetSettlementReportsHandlerIntegrationTests.cs b/source/settlement-report/SettlementReports.IntegrationTests/Application/SettlementReports/GetSettlementReportsHandlerIntegrationTests.cs index 844b5fd..ed852bc 100644 --- a/source/settlement-report/SettlementReports.IntegrationTests/Application/SettlementReports/GetSettlementReportsHandlerIntegrationTests.cs +++ b/source/settlement-report/SettlementReports.IntegrationTests/Application/SettlementReports/GetSettlementReportsHandlerIntegrationTests.cs @@ -194,7 +194,7 @@ public async Task GetAsync_HasExpiredReport_ReportIsRemoved() "TestFile.csv", []); - report.MarkAsCompleted(generatedSettlementReportDto); + report.MarkAsCompleted(clockMock.Object, generatedSettlementReportDto); await using var dbContext = _wholesaleDatabaseFixture.DatabaseManager.CreateDbContext(); await dbContext.SettlementReports.AddAsync(report); diff --git a/source/settlement-report/SettlementReports.IntegrationTests/Application/SettlementReports/SettlementReportDownloadHandlerIntegrationTests.cs b/source/settlement-report/SettlementReports.IntegrationTests/Application/SettlementReports/SettlementReportDownloadHandlerIntegrationTests.cs index c97f54f..8639678 100644 --- a/source/settlement-report/SettlementReports.IntegrationTests/Application/SettlementReports/SettlementReportDownloadHandlerIntegrationTests.cs +++ b/source/settlement-report/SettlementReports.IntegrationTests/Application/SettlementReports/SettlementReportDownloadHandlerIntegrationTests.cs @@ -74,7 +74,7 @@ public async Task DownloadAsync_ReturnsStream() var userId = Guid.NewGuid(); var actorId = Guid.NewGuid(); var settlementReport = new SettlementReport.Application.SettlementReports_v2.SettlementReport(SystemClock.Instance, userId, actorId, false, requestId, _mockedSettlementReportRequest); - settlementReport.MarkAsCompleted(generatedSettlementReport); + settlementReport.MarkAsCompleted(SystemClock.Instance, generatedSettlementReport); await using var dbContext = _wholesaleDatabaseFixture.DatabaseManager.CreateDbContext(); await dbContext.SettlementReports.AddAsync(settlementReport); @@ -104,7 +104,7 @@ public async Task DownloadAsync_NoAccess_ThrowsException() var actorId = Guid.NewGuid(); var settlementReport = new SettlementReport.Application.SettlementReports_v2.SettlementReport(SystemClock.Instance, userId, actorId, false, requestId, _mockedSettlementReportRequest); - settlementReport.MarkAsCompleted(generatedSettlementReport); + settlementReport.MarkAsCompleted(SystemClock.Instance, generatedSettlementReport); await using var dbContext = _wholesaleDatabaseFixture.DatabaseManager.CreateDbContext(); await dbContext.SettlementReports.AddAsync(settlementReport); @@ -131,7 +131,7 @@ public async Task DownloadAsync_AsFAS_ReturnsStream() var actorId = Guid.NewGuid(); var settlementReport = new SettlementReport.Application.SettlementReports_v2.SettlementReport(SystemClock.Instance, userId, actorId, false, requestId, _mockedSettlementReportRequest); - settlementReport.MarkAsCompleted(generatedSettlementReport); + settlementReport.MarkAsCompleted(SystemClock.Instance, generatedSettlementReport); await using var dbContext = _wholesaleDatabaseFixture.DatabaseManager.CreateDbContext(); await dbContext.SettlementReports.AddAsync(settlementReport); @@ -160,7 +160,7 @@ public async Task DownloadAsync_HiddenReport_ThrowsException() var userId = Guid.NewGuid(); var actorId = Guid.NewGuid(); var settlementReport = new SettlementReport.Application.SettlementReports_v2.SettlementReport(SystemClock.Instance, userId, actorId, true, requestId, _mockedSettlementReportRequest); - settlementReport.MarkAsCompleted(generatedSettlementReport); + settlementReport.MarkAsCompleted(SystemClock.Instance, generatedSettlementReport); await using var dbContext = _wholesaleDatabaseFixture.DatabaseManager.CreateDbContext(); await dbContext.SettlementReports.AddAsync(settlementReport);