From 169c15cb8bf8f9c1ec6cc6725bdb270af87a636b Mon Sep 17 00:00:00 2001 From: Mads Magnus Due Date: Mon, 2 Dec 2024 08:45:21 +0100 Subject: [PATCH 1/8] chore: updated comment in metric test --- ...teForMeasurementPointMarketActivityRecord.cs | 5 ++++- .../MetricNameGenerationTests.cs | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/source/OutgoingMessages.Domain/DocumentWriters/RSM012/MeteredDateForMeasurementPointMarketActivityRecord.cs b/source/OutgoingMessages.Domain/DocumentWriters/RSM012/MeteredDateForMeasurementPointMarketActivityRecord.cs index 77bd0855c..066057df5 100644 --- a/source/OutgoingMessages.Domain/DocumentWriters/RSM012/MeteredDateForMeasurementPointMarketActivityRecord.cs +++ b/source/OutgoingMessages.Domain/DocumentWriters/RSM012/MeteredDateForMeasurementPointMarketActivityRecord.cs @@ -27,4 +27,7 @@ public record MeteredDateForMeasurementPointMarketActivityRecord( string EndedDateTime, IReadOnlyList Points); -public record PointActivityRecord(int Position, string? Quality, int? Quantity); +public record PointActivityRecord( + int Position, + string? Quality, + int? Quantity); diff --git a/source/Tests/Application/OutgoingMessages/MetricNameGenerationTests.cs b/source/Tests/Application/OutgoingMessages/MetricNameGenerationTests.cs index 671c64904..7aa626c11 100644 --- a/source/Tests/Application/OutgoingMessages/MetricNameGenerationTests.cs +++ b/source/Tests/Application/OutgoingMessages/MetricNameGenerationTests.cs @@ -21,7 +21,22 @@ namespace Energinet.DataHub.EDI.Tests.Application.OutgoingMessages; public class MetricNameGenerationTests { - // The following values has to be hardcoded, since they are hardcoded in the terraform defining the dashboard + // The following values have to be hardcoded, since they are hardcoded in the terraform defining the dashboard. + // When a new document type is introduced, the following needs to be inserted into to the terraform script: + // { + // "resourceMetadata": { + // "id": "${appi_sharedres_id}" + // }, + // "name": "MeteredDataForMeasurementPoint{format}", + // "aggregationType": 7, + // "namespace": "azure.applicationinsights", + // "metricVisualization": { + // "displayName": "MeteredDataForMeasurementPoint{format}" + // } + // } + // replace {format} with the supported formats for the new document type. + // and include this link to the file: https://github.com/Energinet-DataHub/dh3-infrastructure/blob/main/edi/terraform/main/dashboard-templates/edi_monitor.tpl + // Look for RejectRequestWholesaleSettlement in the script for an example. private static readonly string[] _formats = ["Json", "Xml", "Ebix" ]; private static readonly string[] _documentMetrics = [ From af49af3d2645aec4bc88370eaa73ff3f1f8d8033 Mon Sep 17 00:00:00 2001 From: Mads Magnus Due Date: Mon, 2 Dec 2024 10:43:18 +0100 Subject: [PATCH 2/8] updated --- .../OutgoingMessages/MetricNameGenerationTests.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/source/Tests/Application/OutgoingMessages/MetricNameGenerationTests.cs b/source/Tests/Application/OutgoingMessages/MetricNameGenerationTests.cs index 7aa626c11..86304355b 100644 --- a/source/Tests/Application/OutgoingMessages/MetricNameGenerationTests.cs +++ b/source/Tests/Application/OutgoingMessages/MetricNameGenerationTests.cs @@ -47,6 +47,13 @@ public class MetricNameGenerationTests "NotifyWholesaleServicesResponse", "RejectRequestWholesaleSettlement", "MeteredDataForMeasurementPoint", + "MeteredDataForMeasurementPointResponse", + ]; + + private static readonly DocumentType[] _doesNotHaveIncomingMessageResponse = + [ + DocumentType.RejectRequestWholesaleSettlement, + DocumentType.RejectRequestAggregatedMeasureData ]; private readonly string[] _loggedMessageGenerationMetric = _formats.Select( @@ -78,13 +85,15 @@ private static List AllMessageGenerationsMetricsNames() { foreach (var documentType in documentTypes) { + // Most documents are logged as an outgoing message and as a response to an incoming message names.Add(MetricNameMapper.MessageGenerationMetricName( documentType, documentFormat, false)); - if (documentType.Name.Contains("Notify")) + + // Some documents are only logged as an outgoing message + if (!_doesNotHaveIncomingMessageResponse.Contains(documentType)) { - // We're logging a response of a request as a separate message generation, even though it's the same document names.Add(MetricNameMapper.MessageGenerationMetricName( documentType, documentFormat, From 23d73bed0656049cfa738e112977806ce610259e Mon Sep 17 00:00:00 2001 From: Mads Magnus Due Date: Mon, 2 Dec 2024 10:47:19 +0100 Subject: [PATCH 3/8] updated --- .../Application/OutgoingMessages/MetricNameGenerationTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Tests/Application/OutgoingMessages/MetricNameGenerationTests.cs b/source/Tests/Application/OutgoingMessages/MetricNameGenerationTests.cs index 86304355b..5ed1cdec5 100644 --- a/source/Tests/Application/OutgoingMessages/MetricNameGenerationTests.cs +++ b/source/Tests/Application/OutgoingMessages/MetricNameGenerationTests.cs @@ -85,7 +85,7 @@ private static List AllMessageGenerationsMetricsNames() { foreach (var documentType in documentTypes) { - // Most documents are logged as an outgoing message and as a response to an incoming message + // Most documents are logged as an outgoing message and as a response to a corresponding incoming message names.Add(MetricNameMapper.MessageGenerationMetricName( documentType, documentFormat, From 9a3b9ff01d53246cb91a0767104e489465f5eb61 Mon Sep 17 00:00:00 2001 From: Mads Magnus Due Date: Mon, 2 Dec 2024 12:59:59 +0100 Subject: [PATCH 4/8] updated --- .../IncomingMessages/EbixIncomingMessageReceiver.cs | 2 +- source/B2BApi/IncomingMessages/IncomingMessageReceiver.cs | 2 +- source/BuildingBlocks.Domain/Models/DocumentType.cs | 2 +- .../BuildingBlocks.Domain/Models/IncomingDocumentType.cs | 2 +- .../WholesaleServicesRequestValidatorTests.cs | 4 ++-- .../DelegateIncomingMessage.cs | 2 +- .../UseCases/ReceiveIncomingMarketMessage.cs | 2 +- .../MeteredDateForMeasurementPointEbixMessageParser.cs | 2 +- .../MeteredDateForMeasurementPointJsonMessageParser.cs | 2 +- .../MeteredDateForMeasurementPointXmlMessageParser.cs | 2 +- .../IncomingMessages/GivenIncomingMessagesTests.cs | 8 ++++---- .../GivenIncomingMessagesWithDelegationTests.cs | 8 ++++---- .../GivenIncomingMeteredDataForMeasurementMessageTests.cs | 4 ++-- ...MeteredDateForMeasurementPointCimJsonDocumentWriter.cs | 2 +- .../MeteredDateForMeasurementPointCimXmlDocumentWriter.cs | 2 +- .../DocumentFactory/DocumentFactoryTests.cs | 2 +- source/Tests/B2CWebApi/Mappers/DocumentTypeMapperTests.cs | 2 +- 17 files changed, 25 insertions(+), 25 deletions(-) diff --git a/source/B2BApi/IncomingMessages/EbixIncomingMessageReceiver.cs b/source/B2BApi/IncomingMessages/EbixIncomingMessageReceiver.cs index cec4ef17c..6dfd59550 100644 --- a/source/B2BApi/IncomingMessages/EbixIncomingMessageReceiver.cs +++ b/source/B2BApi/IncomingMessages/EbixIncomingMessageReceiver.cs @@ -62,7 +62,7 @@ public async Task RunAsync( .ReceiveIncomingMarketMessageAsync( incomingMarketMessageStream, incomingDocumentFormat: DocumentFormat.Ebix, - IncomingDocumentType.MeteredDataForMeasurementPoint, + IncomingDocumentType.NotifyValidatedMeasureData, responseDocumentFormat: DocumentFormat.Ebix, cancellationToken) .ConfigureAwait(false); diff --git a/source/B2BApi/IncomingMessages/IncomingMessageReceiver.cs b/source/B2BApi/IncomingMessages/IncomingMessageReceiver.cs index ec318d81c..87ffc8477 100644 --- a/source/B2BApi/IncomingMessages/IncomingMessageReceiver.cs +++ b/source/B2BApi/IncomingMessages/IncomingMessageReceiver.cs @@ -137,7 +137,7 @@ private static async Task CreateResponseAsync( { { IncomingDocumentType.RequestAggregatedMeasureData, AuditLogEntityType.RequestAggregatedMeasureData }, { IncomingDocumentType.RequestWholesaleSettlement, AuditLogEntityType.RequestWholesaleServices }, - { IncomingDocumentType.MeteredDataForMeasurementPoint, AuditLogEntityType.MeteredDataForMeasurementPointReceived }, + { IncomingDocumentType.NotifyValidatedMeasureData, AuditLogEntityType.MeteredDataForMeasurementPointReceived }, }; entityTypeMapping.TryGetValue(incomingDocumentType, out var affectedEntityType); diff --git a/source/BuildingBlocks.Domain/Models/DocumentType.cs b/source/BuildingBlocks.Domain/Models/DocumentType.cs index 16343e88a..106b4ec37 100644 --- a/source/BuildingBlocks.Domain/Models/DocumentType.cs +++ b/source/BuildingBlocks.Domain/Models/DocumentType.cs @@ -20,7 +20,7 @@ public class DocumentType : EnumerationType public static readonly DocumentType RejectRequestAggregatedMeasureData = new(nameof(RejectRequestAggregatedMeasureData), MessageCategory.Aggregations); public static readonly DocumentType NotifyWholesaleServices = new(nameof(NotifyWholesaleServices), MessageCategory.Aggregations); public static readonly DocumentType RejectRequestWholesaleSettlement = new(nameof(RejectRequestWholesaleSettlement), MessageCategory.Aggregations); - public static readonly DocumentType MeteredDataForMeasurementPoint = new(nameof(MeteredDataForMeasurementPoint), MessageCategory.TimeSeries); + public static readonly DocumentType NotifyValidatedMeasureData = new(nameof(NotifyValidatedMeasureData), MessageCategory.TimeSeries); private DocumentType(string name, MessageCategory category) : base(name) diff --git a/source/BuildingBlocks.Domain/Models/IncomingDocumentType.cs b/source/BuildingBlocks.Domain/Models/IncomingDocumentType.cs index 033da05b7..af9376fe0 100644 --- a/source/BuildingBlocks.Domain/Models/IncomingDocumentType.cs +++ b/source/BuildingBlocks.Domain/Models/IncomingDocumentType.cs @@ -20,7 +20,7 @@ public class IncomingDocumentType : EnumerationType public static readonly IncomingDocumentType B2CRequestAggregatedMeasureData = new(nameof(B2CRequestAggregatedMeasureData)); public static readonly IncomingDocumentType RequestWholesaleSettlement = new(nameof(RequestWholesaleSettlement)); public static readonly IncomingDocumentType B2CRequestWholesaleSettlement = new(nameof(B2CRequestWholesaleSettlement)); - public static readonly IncomingDocumentType MeteredDataForMeasurementPoint = new(nameof(MeteredDataForMeasurementPoint)); + public static readonly IncomingDocumentType NotifyValidatedMeasureData = new(nameof(NotifyValidatedMeasureData)); private IncomingDocumentType(string name) : base(name) diff --git a/source/Edi.UnitTests/Validators/WholesaleServicesRequest/WholesaleServicesRequestValidatorTests.cs b/source/Edi.UnitTests/Validators/WholesaleServicesRequest/WholesaleServicesRequestValidatorTests.cs index a33cd8883..8aafd3036 100644 --- a/source/Edi.UnitTests/Validators/WholesaleServicesRequest/WholesaleServicesRequestValidatorTests.cs +++ b/source/Edi.UnitTests/Validators/WholesaleServicesRequest/WholesaleServicesRequestValidatorTests.cs @@ -100,8 +100,8 @@ public async Task Validate_WhenPeriodStartAndPeriodEndAreInvalidFormat_ReturnsUn var validationErrors = await _sut.ValidateAsync(request); // Assert - validationErrors.Should().HaveCount(2); - validationErrors.Select(e => e.ErrorCode).Should().BeEquivalentTo(["D66", "D66"]); + validationErrors.Should().HaveCountGreaterThanOrEqualTo(2); + validationErrors.Select(e => e.ErrorCode).Should().Contain(["D66", "D66"]); } [Fact] diff --git a/source/IncomingMessages.Application/DelegateIncomingMessage.cs b/source/IncomingMessages.Application/DelegateIncomingMessage.cs index 0f978d5af..d22d0a8db 100644 --- a/source/IncomingMessages.Application/DelegateIncomingMessage.cs +++ b/source/IncomingMessages.Application/DelegateIncomingMessage.cs @@ -156,7 +156,7 @@ private ProcessType MapToProcessType(IncomingDocumentType incomingDocumentType) { IncomingDocumentType.B2CRequestAggregatedMeasureData, ProcessType.RequestEnergyResults }, { IncomingDocumentType.RequestWholesaleSettlement, ProcessType.RequestWholesaleResults }, { IncomingDocumentType.B2CRequestWholesaleSettlement, ProcessType.RequestWholesaleResults }, - { IncomingDocumentType.MeteredDataForMeasurementPoint, ProcessType.IncomingMeteredDataForMeasurementPoint }, + { IncomingDocumentType.NotifyValidatedMeasureData, ProcessType.IncomingMeteredDataForMeasurementPoint }, }; if (documentTypeToProcessTypeMap.TryGetValue(incomingDocumentType, out var processType)) diff --git a/source/IncomingMessages.Application/UseCases/ReceiveIncomingMarketMessage.cs b/source/IncomingMessages.Application/UseCases/ReceiveIncomingMarketMessage.cs index 48953ae25..bcfe9b900 100644 --- a/source/IncomingMessages.Application/UseCases/ReceiveIncomingMarketMessage.cs +++ b/source/IncomingMessages.Application/UseCases/ReceiveIncomingMarketMessage.cs @@ -144,7 +144,7 @@ await _delegateIncomingMessage private static bool ShouldArchive(IncomingDocumentType documentType) { - return documentType != IncomingDocumentType.MeteredDataForMeasurementPoint; + return documentType != IncomingDocumentType.NotifyValidatedMeasureData; } private async Task ParseIncomingMessageAsync( diff --git a/source/IncomingMessages.Domain/MessageParsers/RSM012/MeteredDateForMeasurementPointEbixMessageParser.cs b/source/IncomingMessages.Domain/MessageParsers/RSM012/MeteredDateForMeasurementPointEbixMessageParser.cs index ba5dc7c7b..8877ebbc7 100644 --- a/source/IncomingMessages.Domain/MessageParsers/RSM012/MeteredDateForMeasurementPointEbixMessageParser.cs +++ b/source/IncomingMessages.Domain/MessageParsers/RSM012/MeteredDateForMeasurementPointEbixMessageParser.cs @@ -37,7 +37,7 @@ public class MeteredDateForMeasurementPointEbixMessageParser(EbixSchemaProvider private const string QuantityQuality = "QuantityQuality"; private const string IntervalEnergyObservation = "IntervalEnergyObservation"; - public override IncomingDocumentType DocumentType => IncomingDocumentType.MeteredDataForMeasurementPoint; + public override IncomingDocumentType DocumentType => IncomingDocumentType.NotifyValidatedMeasureData; public override DocumentFormat DocumentFormat => DocumentFormat.Ebix; diff --git a/source/IncomingMessages.Domain/MessageParsers/RSM012/MeteredDateForMeasurementPointJsonMessageParser.cs b/source/IncomingMessages.Domain/MessageParsers/RSM012/MeteredDateForMeasurementPointJsonMessageParser.cs index 53aed69ab..fdde2b333 100644 --- a/source/IncomingMessages.Domain/MessageParsers/RSM012/MeteredDateForMeasurementPointJsonMessageParser.cs +++ b/source/IncomingMessages.Domain/MessageParsers/RSM012/MeteredDateForMeasurementPointJsonMessageParser.cs @@ -38,7 +38,7 @@ public class MeteredDateForMeasurementPointJsonMessageParser(JsonSchemaProvider private const string QuantityElementName = "quantity"; private const string RegistrationDateAndOrTimeElementName = "registration_DateAndOrTime.dateTime"; - public override IncomingDocumentType DocumentType => IncomingDocumentType.MeteredDataForMeasurementPoint; + public override IncomingDocumentType DocumentType => IncomingDocumentType.NotifyValidatedMeasureData; public override DocumentFormat DocumentFormat => DocumentFormat.Json; diff --git a/source/IncomingMessages.Domain/MessageParsers/RSM012/MeteredDateForMeasurementPointXmlMessageParser.cs b/source/IncomingMessages.Domain/MessageParsers/RSM012/MeteredDateForMeasurementPointXmlMessageParser.cs index 6ffa82d2c..6b1026a0a 100644 --- a/source/IncomingMessages.Domain/MessageParsers/RSM012/MeteredDateForMeasurementPointXmlMessageParser.cs +++ b/source/IncomingMessages.Domain/MessageParsers/RSM012/MeteredDateForMeasurementPointXmlMessageParser.cs @@ -39,7 +39,7 @@ public class MeteredDateForMeasurementPointXmlMessageParser(CimXmlSchemaProvider private const string QualityElementName = "quality"; private const string RegistrationDateAndOrTimeElementName = "registration_DateAndOrTime.dateTime"; - public override IncomingDocumentType DocumentType => IncomingDocumentType.MeteredDataForMeasurementPoint; + public override IncomingDocumentType DocumentType => IncomingDocumentType.NotifyValidatedMeasureData; protected override string RootPayloadElementName => "NotifyValidatedMeasureData_MarketDocument"; diff --git a/source/IncomingMessages.IntegrationTests/IncomingMessages/GivenIncomingMessagesTests.cs b/source/IncomingMessages.IntegrationTests/IncomingMessages/GivenIncomingMessagesTests.cs index c925d35d1..c4e77590e 100644 --- a/source/IncomingMessages.IntegrationTests/IncomingMessages/GivenIncomingMessagesTests.cs +++ b/source/IncomingMessages.IntegrationTests/IncomingMessages/GivenIncomingMessagesTests.cs @@ -68,9 +68,9 @@ public static TheoryData WriteAsync( diff --git a/source/OutgoingMessages.Domain/DocumentWriters/RSM012/MeteredDateForMeasurementPointCimXmlDocumentWriter.cs b/source/OutgoingMessages.Domain/DocumentWriters/RSM012/MeteredDateForMeasurementPointCimXmlDocumentWriter.cs index 2aab3916c..248dce52b 100644 --- a/source/OutgoingMessages.Domain/DocumentWriters/RSM012/MeteredDateForMeasurementPointCimXmlDocumentWriter.cs +++ b/source/OutgoingMessages.Domain/DocumentWriters/RSM012/MeteredDateForMeasurementPointCimXmlDocumentWriter.cs @@ -27,7 +27,7 @@ public bool HandlesFormat(DocumentFormat format) public bool HandlesType(DocumentType documentType) { - return documentType == DocumentType.MeteredDataForMeasurementPoint; + return documentType == DocumentType.NotifyValidatedMeasureData; } public Task WriteAsync( diff --git a/source/OutgoingMessages.IntegrationTests/OutgoingMessages/DocumentFactory/DocumentFactoryTests.cs b/source/OutgoingMessages.IntegrationTests/OutgoingMessages/DocumentFactory/DocumentFactoryTests.cs index ceddbf08e..412766d81 100644 --- a/source/OutgoingMessages.IntegrationTests/OutgoingMessages/DocumentFactory/DocumentFactoryTests.cs +++ b/source/OutgoingMessages.IntegrationTests/OutgoingMessages/DocumentFactory/DocumentFactoryTests.cs @@ -64,7 +64,7 @@ public void Ensure_that_all_document_support_ebix(DocumentType documentType) var writer = _documentWriters.FirstOrDefault(writer => writer.HandlesType(documentType) && writer.HandlesFormat(DocumentFormat.Ebix)); - if (documentType == DocumentType.MeteredDataForMeasurementPoint) + if (documentType == DocumentType.NotifyValidatedMeasureData) { writer.Should().BeNull($"{documentType} does not support ebix"); } diff --git a/source/Tests/B2CWebApi/Mappers/DocumentTypeMapperTests.cs b/source/Tests/B2CWebApi/Mappers/DocumentTypeMapperTests.cs index f0f049a52..05bfbadc2 100644 --- a/source/Tests/B2CWebApi/Mappers/DocumentTypeMapperTests.cs +++ b/source/Tests/B2CWebApi/Mappers/DocumentTypeMapperTests.cs @@ -67,7 +67,7 @@ public void Ensure_all_DocumentTypes_are_supported() // TODO - Remove this line when all DocumentTypes are supported in B2C supportedDocumentTypes = supportedDocumentTypes - .Where(x => x != IncomingDocumentType.MeteredDataForMeasurementPoint.Name); + .Where(x => x != IncomingDocumentType.NotifyValidatedMeasureData.Name); // Act & Assert documentTypes.Should().BeEquivalentTo(supportedDocumentTypes.ToList()); From 2107f7be9ea77aab846ffabcc0f952a046584fb2 Mon Sep 17 00:00:00 2001 From: Mads Magnus Due Date: Mon, 2 Dec 2024 13:15:25 +0100 Subject: [PATCH 5/8] updated --- .../WholesaleServicesRequestValidatorTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/Edi.UnitTests/Validators/WholesaleServicesRequest/WholesaleServicesRequestValidatorTests.cs b/source/Edi.UnitTests/Validators/WholesaleServicesRequest/WholesaleServicesRequestValidatorTests.cs index 8aafd3036..117951286 100644 --- a/source/Edi.UnitTests/Validators/WholesaleServicesRequest/WholesaleServicesRequestValidatorTests.cs +++ b/source/Edi.UnitTests/Validators/WholesaleServicesRequest/WholesaleServicesRequestValidatorTests.cs @@ -83,14 +83,16 @@ public async Task Validate_WhenPeriodStartAndPeriodEndAreInvalidFormat_ReturnsUn // Arrange var now = SystemClock.Instance.GetCurrentInstant().ToDateTimeOffset(); + var startToYearsAgo = now.AddYears(-2); + var endToYearsAgo = now.AddYears(-2).AddMonths(1); var request = new WholesaleServicesRequestBuilder() .WithPeriodStart( - new LocalDateTime(now.Year - 2, now.Month, 1, 17, 45, 12) + new LocalDateTime(startToYearsAgo.Year, startToYearsAgo.Month, 1, 17, 45, 12) .InZoneStrictly(DateTimeZoneProviders.Tzdb.GetZoneOrNull("Europe/Copenhagen")!) .ToInstant() .ToString()) .WithPeriodEnd( - new LocalDateTime(now.Year - 2, now.Month + 1, 1, 8, 13, 56) + new LocalDateTime(endToYearsAgo.Year, endToYearsAgo.Month, 1, 8, 13, 56) .InZoneStrictly(DateTimeZoneProviders.Tzdb.GetZoneOrNull("Europe/Copenhagen")!) .ToInstant() .ToString()) From d5e82be51ff438045b5b63afe898555d367ca52c Mon Sep 17 00:00:00 2001 From: Mads Magnus Due Date: Mon, 2 Dec 2024 13:25:37 +0100 Subject: [PATCH 6/8] updated --- .../WholesaleServicesRequestValidatorTests.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/source/Edi.UnitTests/Validators/WholesaleServicesRequest/WholesaleServicesRequestValidatorTests.cs b/source/Edi.UnitTests/Validators/WholesaleServicesRequest/WholesaleServicesRequestValidatorTests.cs index 117951286..bec4b5fe8 100644 --- a/source/Edi.UnitTests/Validators/WholesaleServicesRequest/WholesaleServicesRequestValidatorTests.cs +++ b/source/Edi.UnitTests/Validators/WholesaleServicesRequest/WholesaleServicesRequestValidatorTests.cs @@ -83,16 +83,14 @@ public async Task Validate_WhenPeriodStartAndPeriodEndAreInvalidFormat_ReturnsUn // Arrange var now = SystemClock.Instance.GetCurrentInstant().ToDateTimeOffset(); - var startToYearsAgo = now.AddYears(-2); - var endToYearsAgo = now.AddYears(-2).AddMonths(1); var request = new WholesaleServicesRequestBuilder() .WithPeriodStart( - new LocalDateTime(startToYearsAgo.Year, startToYearsAgo.Month, 1, 17, 45, 12) + new LocalDateTime(now.Year - 2, now.Month, 1, 17, 45, 12) .InZoneStrictly(DateTimeZoneProviders.Tzdb.GetZoneOrNull("Europe/Copenhagen")!) .ToInstant() .ToString()) .WithPeriodEnd( - new LocalDateTime(endToYearsAgo.Year, endToYearsAgo.Month, 1, 8, 13, 56) + new LocalDateTime(now.Year - 2, now.Month + 1, 1, 8, 13, 56) .InZoneStrictly(DateTimeZoneProviders.Tzdb.GetZoneOrNull("Europe/Copenhagen")!) .ToInstant() .ToString()) @@ -102,8 +100,7 @@ public async Task Validate_WhenPeriodStartAndPeriodEndAreInvalidFormat_ReturnsUn var validationErrors = await _sut.ValidateAsync(request); // Assert - validationErrors.Should().HaveCountGreaterThanOrEqualTo(2); - validationErrors.Select(e => e.ErrorCode).Should().Contain(["D66", "D66"]); + validationErrors.Where(x => x.ErrorCode == "D66").Should().HaveCount(2); } [Fact] From a8e37b01b9c3c36aeae81adc56ba531a7bb8f976 Mon Sep 17 00:00:00 2001 From: Mads Magnus Due Date: Mon, 2 Dec 2024 13:38:32 +0100 Subject: [PATCH 7/8] updated --- .../OutgoingMessages/MetricNameGenerationTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/Tests/Application/OutgoingMessages/MetricNameGenerationTests.cs b/source/Tests/Application/OutgoingMessages/MetricNameGenerationTests.cs index 5ed1cdec5..b637ccf81 100644 --- a/source/Tests/Application/OutgoingMessages/MetricNameGenerationTests.cs +++ b/source/Tests/Application/OutgoingMessages/MetricNameGenerationTests.cs @@ -46,11 +46,11 @@ public class MetricNameGenerationTests "NotifyWholesaleServices", "NotifyWholesaleServicesResponse", "RejectRequestWholesaleSettlement", - "MeteredDataForMeasurementPoint", - "MeteredDataForMeasurementPointResponse", + "NotifyValidatedMeasureData", + "NotifyValidatedMeasureDataResponse", ]; - private static readonly DocumentType[] _doesNotHaveIncomingMessageResponse = + private static readonly DocumentType[] _isOnlyTriggeredByIncomingMessage = [ DocumentType.RejectRequestWholesaleSettlement, DocumentType.RejectRequestAggregatedMeasureData @@ -92,7 +92,7 @@ private static List AllMessageGenerationsMetricsNames() false)); // Some documents are only logged as an outgoing message - if (!_doesNotHaveIncomingMessageResponse.Contains(documentType)) + if (!_isOnlyTriggeredByIncomingMessage.Contains(documentType)) { names.Add(MetricNameMapper.MessageGenerationMetricName( documentType, From 323469929b31a5f703244c4e0ad160973f952a5b Mon Sep 17 00:00:00 2001 From: Mads Magnus Due Date: Mon, 2 Dec 2024 13:39:18 +0100 Subject: [PATCH 8/8] updated --- .../WholesaleServicesRequestValidatorTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/Edi.UnitTests/Validators/WholesaleServicesRequest/WholesaleServicesRequestValidatorTests.cs b/source/Edi.UnitTests/Validators/WholesaleServicesRequest/WholesaleServicesRequestValidatorTests.cs index bec4b5fe8..fa9643bb8 100644 --- a/source/Edi.UnitTests/Validators/WholesaleServicesRequest/WholesaleServicesRequestValidatorTests.cs +++ b/source/Edi.UnitTests/Validators/WholesaleServicesRequest/WholesaleServicesRequestValidatorTests.cs @@ -83,14 +83,16 @@ public async Task Validate_WhenPeriodStartAndPeriodEndAreInvalidFormat_ReturnsUn // Arrange var now = SystemClock.Instance.GetCurrentInstant().ToDateTimeOffset(); + var startToYearsAgo = now.AddYears(-2); + var endToYearsAgo = now.AddYears(-2).AddMonths(1); var request = new WholesaleServicesRequestBuilder() .WithPeriodStart( - new LocalDateTime(now.Year - 2, now.Month, 1, 17, 45, 12) + new LocalDateTime(startToYearsAgo.Year, startToYearsAgo.Month, 1, 17, 45, 12) .InZoneStrictly(DateTimeZoneProviders.Tzdb.GetZoneOrNull("Europe/Copenhagen")!) .ToInstant() .ToString()) .WithPeriodEnd( - new LocalDateTime(now.Year - 2, now.Month + 1, 1, 8, 13, 56) + new LocalDateTime(endToYearsAgo.Year, endToYearsAgo.Month, 1, 8, 13, 56) .InZoneStrictly(DateTimeZoneProviders.Tzdb.GetZoneOrNull("Europe/Copenhagen")!) .ToInstant() .ToString())