Skip to content

Commit

Permalink
set ended time
Browse files Browse the repository at this point in the history
  • Loading branch information
vbelinschi committed Sep 10, 2024
1 parent d55e6b8 commit fe69740
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -43,7 +47,7 @@ await _fileRepository
.GetAsync(generatedReport.RequestId.Id)
.ConfigureAwait(false);

request.MarkAsCompleted(generatedReport);
request.MarkAsCompleted(_clock, generatedReport);

await _repository
.AddOrUpdateAsync(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit fe69740

Please sign in to comment.