From 963b09cf87f57c40626938bd947a63aec3aaf819 Mon Sep 17 00:00:00 2001 From: jvandaal Date: Mon, 3 Jun 2024 11:26:43 +0200 Subject: [PATCH] fix: use consumed event provenance timestamp for command --- .../Projections/MunicipalityKafkaProjection.cs | 3 +-- .../StreetNameConsumerKafkaProjectionsTests.cs | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/StreetNameRegistry.Consumer/Projections/MunicipalityKafkaProjection.cs b/src/StreetNameRegistry.Consumer/Projections/MunicipalityKafkaProjection.cs index 3adb0a501..bff063ee5 100644 --- a/src/StreetNameRegistry.Consumer/Projections/MunicipalityKafkaProjection.cs +++ b/src/StreetNameRegistry.Consumer/Projections/MunicipalityKafkaProjection.cs @@ -5,7 +5,6 @@ namespace StreetNameRegistry.Consumer.Projections using Be.Vlaanderen.Basisregisters.GrAr.Contracts.MunicipalityRegistry; using Be.Vlaanderen.Basisregisters.GrAr.Provenance; using Be.Vlaanderen.Basisregisters.ProjectionHandling.Connector; - using NodaTime; using NodaTime.Text; using StreetNameRegistry.Municipality; using StreetNameRegistry.Municipality.Commands; @@ -237,7 +236,7 @@ public static IHasCommandProvenance GetCommand(IQueueMessage message) private static Provenance FromProvenance(Contracts.Provenance provenance, Modification modification = Modification.Update) => new Provenance( - SystemClock.Instance.GetCurrentInstant(), + InstantPattern.General.Parse(provenance.Timestamp).Value, Enum.Parse(provenance.Application), new Reason(provenance.Reason), new Operator(string.Empty), diff --git a/test/StreetNameRegistry.Tests/ProjectionTests/StreetNameConsumerKafkaProjectionsTests.cs b/test/StreetNameRegistry.Tests/ProjectionTests/StreetNameConsumerKafkaProjectionsTests.cs index 50924d06f..a89807fc6 100644 --- a/test/StreetNameRegistry.Tests/ProjectionTests/StreetNameConsumerKafkaProjectionsTests.cs +++ b/test/StreetNameRegistry.Tests/ProjectionTests/StreetNameConsumerKafkaProjectionsTests.cs @@ -115,7 +115,11 @@ public async Task GivenMunicipalityWasRegistered_ThenImportMunicipality() await Then(async _ => { _mockCommandHandler.Verify( - x => x.Handle(It.Is(x => x is ImportMunicipality), CancellationToken.None), + x => x.Handle( + It.Is(y => + y is ImportMunicipality + && y.Provenance.Timestamp.ToString() == @event.Provenance.Timestamp), + CancellationToken.None), Times.Once); await Task.CompletedTask; });