diff --git a/src/AssociationRegistry.Admin.AddressSync/AddressSyncService.cs b/src/AssociationRegistry.Admin.AddressSync/AddressSyncService.cs index 451c74569..786aa53e4 100644 --- a/src/AssociationRegistry.Admin.AddressSync/AddressSyncService.cs +++ b/src/AssociationRegistry.Admin.AddressSync/AddressSyncService.cs @@ -1,9 +1,9 @@ namespace AssociationRegistry.Admin.AddressSync; -using Grar.AddressSync; using Grar.Models; using Infrastructure.Notifications; using Marten; +using MessageHandling.Sqs.AddressSync; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Notifications; diff --git a/src/AssociationRegistry.Admin.AddressSync/AssociationRegistry.Admin.AddressSync.csproj b/src/AssociationRegistry.Admin.AddressSync/AssociationRegistry.Admin.AddressSync.csproj index 1c895e2af..2b64e2567 100644 --- a/src/AssociationRegistry.Admin.AddressSync/AssociationRegistry.Admin.AddressSync.csproj +++ b/src/AssociationRegistry.Admin.AddressSync/AssociationRegistry.Admin.AddressSync.csproj @@ -52,5 +52,9 @@ + + + + diff --git a/src/AssociationRegistry.Admin.AddressSync/ITeSynchroniserenLocatiesFetcher.cs b/src/AssociationRegistry.Admin.AddressSync/ITeSynchroniserenLocatiesFetcher.cs index 672c099de..aa9f294d6 100644 --- a/src/AssociationRegistry.Admin.AddressSync/ITeSynchroniserenLocatiesFetcher.cs +++ b/src/AssociationRegistry.Admin.AddressSync/ITeSynchroniserenLocatiesFetcher.cs @@ -1,7 +1,7 @@ namespace AssociationRegistry.Admin.AddressSync; -using Grar.AddressSync; using Marten; +using Messages; public interface ITeSynchroniserenLocatiesFetcher { diff --git a/src/AssociationRegistry.Admin.AddressSync/MessageHandling/Sqs/AddressSync/TeSynchroniserenLocatieAdresMessageHandler.cs b/src/AssociationRegistry.Admin.AddressSync/MessageHandling/Sqs/AddressSync/TeSynchroniserenLocatieAdresMessageHandler.cs new file mode 100644 index 000000000..80d582024 --- /dev/null +++ b/src/AssociationRegistry.Admin.AddressSync/MessageHandling/Sqs/AddressSync/TeSynchroniserenLocatieAdresMessageHandler.cs @@ -0,0 +1,14 @@ +namespace AssociationRegistry.Admin.AddressSync.MessageHandling.Sqs.AddressSync; + +using Messages; +using Wolverine; + +public class TeSynchroniserenLocatieAdresMessageHandler(IMessageBus messageBus) +{ + public async Task Handle(TeSynchroniserenLocatieAdresMessage message, CancellationToken cancellationToken) + { + var command = message.ToCommand(); + + await messageBus.InvokeAsync(command, cancellationToken); + } +} diff --git a/src/AssociationRegistry.Admin.AddressSync/Program.cs b/src/AssociationRegistry.Admin.AddressSync/Program.cs index b10fb6070..a3089343b 100644 --- a/src/AssociationRegistry.Admin.AddressSync/Program.cs +++ b/src/AssociationRegistry.Admin.AddressSync/Program.cs @@ -3,8 +3,8 @@ using Destructurama; using EventStore; using Grar; -using Grar.AddressSync; using Infrastructure.Extensions; +using MessageHandling.Sqs.AddressSync; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; diff --git a/src/AssociationRegistry.Admin.AddressSync/TeSynchroniserenLocatiesFetcher.cs b/src/AssociationRegistry.Admin.AddressSync/TeSynchroniserenLocatiesFetcher.cs index 3e5e0443c..01f867d00 100644 --- a/src/AssociationRegistry.Admin.AddressSync/TeSynchroniserenLocatiesFetcher.cs +++ b/src/AssociationRegistry.Admin.AddressSync/TeSynchroniserenLocatiesFetcher.cs @@ -1,10 +1,10 @@ namespace AssociationRegistry.Admin.AddressSync; using Grar; -using Grar.AddressSync; using Grar.Exceptions; using Grar.Models; using Marten; +using Messages; using Microsoft.Extensions.Logging; using Schema.Detail; using System.Diagnostics.Contracts; diff --git a/src/AssociationRegistry.Admin.Api/AdresMatch/AdresMatchController.cs b/src/AssociationRegistry.Admin.Api/AdresMatch/AdresMatchController.cs index e0283ef12..3a81fc2ce 100644 --- a/src/AssociationRegistry.Admin.Api/AdresMatch/AdresMatchController.cs +++ b/src/AssociationRegistry.Admin.Api/AdresMatch/AdresMatchController.cs @@ -2,8 +2,9 @@ using Asp.Versioning; using Be.Vlaanderen.Basisregisters.Api; -using Grar.AddressMatch; using Marten; +using MessageHandling.Sqs.AddressMatch; +using Messages; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Schema.Detail; diff --git a/src/AssociationRegistry.Admin.Api/AssociationRegistry.Admin.Api.csproj b/src/AssociationRegistry.Admin.Api/AssociationRegistry.Admin.Api.csproj index 6fb893dc5..13c2487b7 100755 --- a/src/AssociationRegistry.Admin.Api/AssociationRegistry.Admin.Api.csproj +++ b/src/AssociationRegistry.Admin.Api/AssociationRegistry.Admin.Api.csproj @@ -68,6 +68,7 @@ + diff --git a/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/WolverineExtensions.cs b/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/WolverineExtensions.cs index 1a62fc3b2..0febe011c 100644 --- a/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/WolverineExtensions.cs +++ b/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/WolverineExtensions.cs @@ -3,10 +3,10 @@ using Acties.GrarConsumer; using Amazon.Runtime; using EventStore; -using Grar.AddressMatch; using Hosts.Configuration; using JasperFx.CodeGeneration; using MessageHandling.Postgres.Dubbels; +using MessageHandling.Sqs.AddressMatch; using Messages; using Serilog; using Vereniging; diff --git a/src/AssociationRegistry.Admin.Api/MessageHandling/Sqs/AddressMatch/TeAdresMatchenLocatieMessageHandler.cs b/src/AssociationRegistry.Admin.Api/MessageHandling/Sqs/AddressMatch/TeAdresMatchenLocatieMessageHandler.cs new file mode 100644 index 000000000..835e89ca3 --- /dev/null +++ b/src/AssociationRegistry.Admin.Api/MessageHandling/Sqs/AddressMatch/TeAdresMatchenLocatieMessageHandler.cs @@ -0,0 +1,14 @@ +namespace AssociationRegistry.Admin.Api.MessageHandling.Sqs.AddressMatch; + +using Messages; +using Wolverine; + +public class TeAdresMatchenLocatieMessageHandler(IMessageBus messageBus) +{ + public async Task Handle(TeAdresMatchenLocatieMessage message, CancellationToken cancellationToken) + { + var command = message.ToCommand(); + + await messageBus.InvokeAsync(command, cancellationToken); + } +} diff --git a/src/AssociationRegistry.Admin.Api/Program.cs b/src/AssociationRegistry.Admin.Api/Program.cs index c1968d697..47b673902 100755 --- a/src/AssociationRegistry.Admin.Api/Program.cs +++ b/src/AssociationRegistry.Admin.Api/Program.cs @@ -22,7 +22,6 @@ namespace AssociationRegistry.Admin.Api; using Formats; using Framework; using Grar; -using Grar.AddressMatch; using Grar.GrarUpdates; using Grar.GrarUpdates.Fusies; using Grar.GrarUpdates.Fusies.TeHeradresserenLocaties; @@ -51,6 +50,7 @@ namespace AssociationRegistry.Admin.Api; using Lamar.Microsoft.DependencyInjection; using Magda; using Marten; +using MessageHandling.Sqs.AddressMatch; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Diagnostics; diff --git a/src/AssociationRegistry/Acties/ProbeerAdresTeMatchen/ProbeerAdresTeMatchenCommand.cs b/src/AssociationRegistry/Acties/ProbeerAdresTeMatchen/ProbeerAdresTeMatchenCommand.cs new file mode 100644 index 000000000..20cca90d9 --- /dev/null +++ b/src/AssociationRegistry/Acties/ProbeerAdresTeMatchen/ProbeerAdresTeMatchenCommand.cs @@ -0,0 +1,3 @@ +namespace AssociationRegistry.Acties.ProbeerAdresTeMatchen; + +public record ProbeerAdresTeMatchenCommand(string VCode, int LocatieId); diff --git a/src/AssociationRegistry/Grar/AddressMatch/TeAdresMatchenLocatieMessageHandler.cs b/src/AssociationRegistry/Acties/ProbeerAdresTeMatchen/ProbeerAdresTeMatchenCommandHandler.cs similarity index 63% rename from src/AssociationRegistry/Grar/AddressMatch/TeAdresMatchenLocatieMessageHandler.cs rename to src/AssociationRegistry/Acties/ProbeerAdresTeMatchen/ProbeerAdresTeMatchenCommandHandler.cs index 3e9e4e9ee..4eb6c1253 100644 --- a/src/AssociationRegistry/Grar/AddressMatch/TeAdresMatchenLocatieMessageHandler.cs +++ b/src/AssociationRegistry/Acties/ProbeerAdresTeMatchen/ProbeerAdresTeMatchenCommandHandler.cs @@ -1,21 +1,23 @@ -namespace AssociationRegistry.Grar.AddressMatch; +namespace AssociationRegistry.Acties.ProbeerAdresTeMatchen; using EventStore; using Framework; +using Grar; using Microsoft.Extensions.Logging; using NodaTime; using Vereniging; +using Vereniging.Exceptions; -public class TeAdresMatchenLocatieMessageHandler +public class ProbeerAdresTeMatchenCommandHandler { - private readonly ILogger _logger; + private readonly ILogger _logger; private readonly IGrarClient _grarClient; private readonly IVerenigingsRepository _verenigingsRepository; - public TeAdresMatchenLocatieMessageHandler( + public ProbeerAdresTeMatchenCommandHandler( IVerenigingsRepository verenigingsRepository, IGrarClient grarClient, - ILogger logger) + ILogger logger) { _verenigingsRepository = verenigingsRepository; _grarClient = grarClient; @@ -23,16 +25,16 @@ public TeAdresMatchenLocatieMessageHandler( } public async Task Handle( - TeAdresMatchenLocatieMessage teAdresMatchenLocatieMessage, + ProbeerAdresTeMatchenCommand command, CancellationToken cancellationToken = default) { - _logger.LogInformation($"Handle {nameof(TeAdresMatchenLocatieMessageHandler)}"); + _logger.LogInformation($"Handle {nameof(ProbeerAdresTeMatchenCommandHandler)}"); try { - var vereniging = await _verenigingsRepository.Load(VCode.Hydrate(teAdresMatchenLocatieMessage.VCode), allowDubbeleVereniging: true); + var vereniging = await _verenigingsRepository.Load(VCode.Hydrate(command.VCode), allowDubbeleVereniging: true); - await vereniging.ProbeerAdresTeMatchen(_grarClient, teAdresMatchenLocatieMessage.LocatieId, cancellationToken); + await vereniging.ProbeerAdresTeMatchen(_grarClient, command.LocatieId, cancellationToken); await _verenigingsRepository.Save( vereniging, @@ -44,9 +46,9 @@ await _verenigingsRepository.Save( { throw new UnexpectedAggregateVersionDuringSyncException(); } - catch (AssociationRegistry.Vereniging.Exceptions.VerenigingIsVerwijderd) + catch (VerenigingIsVerwijderd) { - _logger.LogWarning("Kon de locatie niet adresmatchen wegens verwijderde vereniging met VCode: {VCode}.", teAdresMatchenLocatieMessage.VCode); + _logger.LogWarning("Kon de locatie niet adresmatchen wegens verwijderde vereniging met VCode: {VCode}.", command.VCode); } catch (Exception ex) { diff --git a/src/AssociationRegistry/Acties/RegistreerFeitelijkeVereniging/RegistreerFeitelijkeVerenigingCommandHandler.cs b/src/AssociationRegistry/Acties/RegistreerFeitelijkeVereniging/RegistreerFeitelijkeVerenigingCommandHandler.cs index a02462f3c..783388e62 100644 --- a/src/AssociationRegistry/Acties/RegistreerFeitelijkeVereniging/RegistreerFeitelijkeVerenigingCommandHandler.cs +++ b/src/AssociationRegistry/Acties/RegistreerFeitelijkeVereniging/RegistreerFeitelijkeVerenigingCommandHandler.cs @@ -1,11 +1,11 @@ namespace AssociationRegistry.Acties.RegistreerFeitelijkeVereniging; -using Grar; -using Grar.AddressMatch; using DuplicateVerenigingDetection; using Events; using Framework; +using Grar; using Marten; +using Messages; using Microsoft.Extensions.Logging; using ResultNet; using Vereniging; diff --git a/src/AssociationRegistry/Acties/SyncAdresLocaties/SyncAdresLocatiesCommand.cs b/src/AssociationRegistry/Acties/SyncAdresLocaties/SyncAdresLocatiesCommand.cs new file mode 100644 index 000000000..c425349e5 --- /dev/null +++ b/src/AssociationRegistry/Acties/SyncAdresLocaties/SyncAdresLocatiesCommand.cs @@ -0,0 +1,5 @@ +namespace AssociationRegistry.Acties.SyncAdresLocaties; + +using Grar.Models; + +public record SyncAdresLocatiesCommand(string VCode, List LocatiesWithAdres, string IdempotenceKey); diff --git a/src/AssociationRegistry/Acties/SyncAdresLocaties/SyncAdresLocatiesCommandHandler.cs b/src/AssociationRegistry/Acties/SyncAdresLocaties/SyncAdresLocatiesCommandHandler.cs new file mode 100644 index 000000000..939e0d5f9 --- /dev/null +++ b/src/AssociationRegistry/Acties/SyncAdresLocaties/SyncAdresLocatiesCommandHandler.cs @@ -0,0 +1,37 @@ +namespace AssociationRegistry.Acties.SyncAdresLocaties; + +using EventStore; +using Framework; +using Grar; +using Microsoft.Extensions.Logging; +using NodaTime; +using Vereniging; + +public class SyncAdresLocatiesCommandHandler( + IVerenigingsRepository repository, + IGrarClient grarClient, + ILogger logger) +{ + public async Task Handle(SyncAdresLocatiesCommand locatiesCommand, CancellationToken cancellationToken) + { + logger.LogInformation($"Handle {nameof(SyncAdresLocatiesCommandHandler)}"); + + try + { + var vereniging = await repository.Load(VCode.Hydrate(locatiesCommand.VCode), allowDubbeleVereniging: true); + + await vereniging.SyncAdresLocaties(locatiesCommand.LocatiesWithAdres, locatiesCommand.IdempotenceKey, grarClient); + + await repository.Save( + vereniging, + new CommandMetadata(EventStore.DigitaalVlaanderenOvoNumber, + SystemClock.Instance.GetCurrentInstant(), + Guid.NewGuid()), + cancellationToken); + } + catch (Exception ex) + { + logger.LogError(ex, message: "Fout bij het synchroniseren van vereniging {VCode}", locatiesCommand.VCode); + } + } +} diff --git a/src/AssociationRegistry/Acties/VoegLocatieToe/VoegLocatieToeCommandHandler.cs b/src/AssociationRegistry/Acties/VoegLocatieToe/VoegLocatieToeCommandHandler.cs index b179d3803..f46d31113 100644 --- a/src/AssociationRegistry/Acties/VoegLocatieToe/VoegLocatieToeCommandHandler.cs +++ b/src/AssociationRegistry/Acties/VoegLocatieToe/VoegLocatieToeCommandHandler.cs @@ -1,10 +1,10 @@ namespace AssociationRegistry.Acties.VoegLocatieToe; -using AssociationRegistry.Grar; -using AssociationRegistry.Grar.AddressMatch; using Events; using Framework; +using Grar; using Marten; +using Messages; using Vereniging; using Wolverine.Marten; diff --git a/src/AssociationRegistry/Acties/WijzigLocatie/WijzigLocatieCommandHandler.cs b/src/AssociationRegistry/Acties/WijzigLocatie/WijzigLocatieCommandHandler.cs index 96d9459ad..17165927b 100644 --- a/src/AssociationRegistry/Acties/WijzigLocatie/WijzigLocatieCommandHandler.cs +++ b/src/AssociationRegistry/Acties/WijzigLocatie/WijzigLocatieCommandHandler.cs @@ -1,9 +1,9 @@ namespace AssociationRegistry.Acties.WijzigLocatie; -using AssociationRegistry.Grar; -using AssociationRegistry.Grar.AddressMatch; using Framework; +using Grar; using Marten; +using Messages; using Vereniging; using Wolverine.Marten; diff --git a/src/AssociationRegistry/Grar/AddressMatch/TeAdresMatchenLocatieMessage.cs b/src/AssociationRegistry/Grar/AddressMatch/TeAdresMatchenLocatieMessage.cs deleted file mode 100644 index 29c91d253..000000000 --- a/src/AssociationRegistry/Grar/AddressMatch/TeAdresMatchenLocatieMessage.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace AssociationRegistry.Grar.AddressMatch; - -public record TeAdresMatchenLocatieMessage(string VCode, int LocatieId); diff --git a/src/AssociationRegistry/Grar/AddressSync/TeSynchroniserenLocatieAdresMessage.cs b/src/AssociationRegistry/Grar/AddressSync/TeSynchroniserenLocatieAdresMessage.cs deleted file mode 100644 index c72b35505..000000000 --- a/src/AssociationRegistry/Grar/AddressSync/TeSynchroniserenLocatieAdresMessage.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace AssociationRegistry.Grar.AddressSync; - -using Models; - -public record TeSynchroniserenLocatieAdresMessage(string VCode, List LocatiesWithAdres, string IdempotenceKey); diff --git a/src/AssociationRegistry/Grar/AddressSync/TeSynchroniserenLocatieAdresMessageHandler.cs b/src/AssociationRegistry/Grar/AddressSync/TeSynchroniserenLocatieAdresMessageHandler.cs deleted file mode 100644 index 3f2666c35..000000000 --- a/src/AssociationRegistry/Grar/AddressSync/TeSynchroniserenLocatieAdresMessageHandler.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace AssociationRegistry.Grar.AddressSync; - -using EventStore; -using Framework; -using Microsoft.Extensions.Logging; -using NodaTime; -using Vereniging; - -public class TeSynchroniserenLocatieAdresMessageHandler(IVerenigingsRepository repository, IGrarClient grarClient, ILogger logger) -{ - public async Task Handle(TeSynchroniserenLocatieAdresMessage message, CancellationToken cancellationToken) - { - logger.LogInformation($"Handle {nameof(TeSynchroniserenLocatieAdresMessageHandler)}"); - - try - { - var vereniging = await repository.Load(VCode.Hydrate(message.VCode), allowDubbeleVereniging: true); - - await vereniging.SyncAdresLocaties(message.LocatiesWithAdres, message.IdempotenceKey, grarClient); - - await repository.Save( - vereniging, - new CommandMetadata(EventStore.DigitaalVlaanderenOvoNumber, - SystemClock.Instance.GetCurrentInstant(), - Guid.NewGuid()), - cancellationToken); - } - catch (Exception ex) - { - logger.LogError(ex, "Fout bij het synchroniseren van vereniging {VCode}", message.VCode); - } - } -} diff --git a/src/AssociationRegistry/Messages/AanvaardDubbeleVerenigingMessage.cs b/src/AssociationRegistry/Messages/AanvaardDubbeleVerenigingMessage.cs index f0997bb00..b0123919b 100644 --- a/src/AssociationRegistry/Messages/AanvaardDubbeleVerenigingMessage.cs +++ b/src/AssociationRegistry/Messages/AanvaardDubbeleVerenigingMessage.cs @@ -1,10 +1,9 @@ namespace AssociationRegistry.Messages; using Acties.AanvaardDubbel; -using AssociationRegistry.Vereniging; public record AanvaardDubbeleVerenigingMessage(string VCode, string VCodeDubbeleVereniging) { public AanvaardDubbeleVerenigingCommand ToCommand() - => new(AssociationRegistry.Vereniging.VCode.Create(VCode), AssociationRegistry.Vereniging.VCode.Create(VCodeDubbeleVereniging)); + => new(Vereniging.VCode.Create(VCode), Vereniging.VCode.Create(VCodeDubbeleVereniging)); } diff --git a/src/AssociationRegistry/Messages/TeAdresMatchenLocatieMessage.cs b/src/AssociationRegistry/Messages/TeAdresMatchenLocatieMessage.cs new file mode 100644 index 000000000..7fabe74cb --- /dev/null +++ b/src/AssociationRegistry/Messages/TeAdresMatchenLocatieMessage.cs @@ -0,0 +1,9 @@ +namespace AssociationRegistry.Messages; + +using Acties.ProbeerAdresTeMatchen; + +public record TeAdresMatchenLocatieMessage(string VCode, int LocatieId) +{ + public ProbeerAdresTeMatchenCommand ToCommand() + => new(VCode, LocatieId); +} diff --git a/src/AssociationRegistry/Messages/TeSynchroniserenLocatieAdresMessage.cs b/src/AssociationRegistry/Messages/TeSynchroniserenLocatieAdresMessage.cs new file mode 100644 index 000000000..7315250ae --- /dev/null +++ b/src/AssociationRegistry/Messages/TeSynchroniserenLocatieAdresMessage.cs @@ -0,0 +1,10 @@ +namespace AssociationRegistry.Messages; + +using Acties.SyncAdresLocaties; +using Grar.Models; + +public record TeSynchroniserenLocatieAdresMessage(string VCode, List LocatiesWithAdres, string IdempotenceKey) +{ + public SyncAdresLocatiesCommand ToCommand() + => new(VCode, LocatiesWithAdres, IdempotenceKey); +} diff --git a/src/AssociationRegistry/Vereniging/Vereniging.cs b/src/AssociationRegistry/Vereniging/Vereniging.cs index 8ed3e7f35..c8ffee011 100644 --- a/src/AssociationRegistry/Vereniging/Vereniging.cs +++ b/src/AssociationRegistry/Vereniging/Vereniging.cs @@ -236,7 +236,7 @@ public void MarkeerAlsDubbelVan(VCode isDubbelVan) { Throw.If(isDubbelVan.Equals(VCode)); - Throw.If(State.CorresponderendeVCodes.Any()); + Throw.If(State.IsAuthentiekeVereniging); AddEvent(VerenigingWerdGemarkeerdAlsDubbelVan.With(VCode, isDubbelVan)); } diff --git a/src/AssociationRegistry/Vereniging/VerenigingState.cs b/src/AssociationRegistry/Vereniging/VerenigingState.cs index 3e3415bea..e96517993 100644 --- a/src/AssociationRegistry/Vereniging/VerenigingState.cs +++ b/src/AssociationRegistry/Vereniging/VerenigingState.cs @@ -43,6 +43,7 @@ public string Identity public List HandledIdempotenceKeys { get; set; } = new(); public bool IsVerwijderd { get; set; } public bool IsDubbel => VerenigingStatus == VerenigingStatus.Dubbel; + public bool IsAuthentiekeVereniging => CorresponderendeVCodes.Length != 0; public string[] CorresponderendeVCodes { get; set; } = []; public VerenigingStatus VerenigingStatus { get; set; } public VerenigingStatus VorigeVerenigingStatus { get; set; } diff --git a/test/AssociationRegistry.Test.Admin.AddressSync/AddressSyncServiceTests.cs b/test/AssociationRegistry.Test.Admin.AddressSync/AddressSyncServiceTests.cs index 4d4c64a44..ba75e2888 100644 --- a/test/AssociationRegistry.Test.Admin.AddressSync/AddressSyncServiceTests.cs +++ b/test/AssociationRegistry.Test.Admin.AddressSync/AddressSyncServiceTests.cs @@ -2,14 +2,15 @@ using AssociationRegistry.Admin.AddressSync; using AssociationRegistry.Admin.AddressSync.Infrastructure.Notifications; +using AssociationRegistry.Admin.AddressSync.MessageHandling.Sqs.AddressSync; using Grar; -using Grar.AddressSync; using Marten; using Microsoft.Extensions.Hosting.Internal; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Notifications; using Vereniging; +using Wolverine; public class AddressSyncServiceTests { @@ -27,10 +28,7 @@ public async Task Given_TeSynchroniserenLocatiesFetcher_Throws_Then_A_Notificati .ThrowsAsync(new Exception()); var addressSyncService = new AddressSyncService(store, - new TeSynchroniserenLocatieAdresMessageHandler( - Mock.Of(), - Mock.Of(), - NullLogger.Instance), + new TeSynchroniserenLocatieAdresMessageHandler(Mock.Of()), teSynchroniserenLocatiesFetcher.Object, notifier.Object, NullLogger.Instance, diff --git a/test/AssociationRegistry.Test.Admin.AddressSync/TeSynchroniserenLocatiesFetcherTests.cs b/test/AssociationRegistry.Test.Admin.AddressSync/TeSynchroniserenLocatiesFetcherTests.cs index 9f5cde85a..610c40b63 100644 --- a/test/AssociationRegistry.Test.Admin.AddressSync/TeSynchroniserenLocatiesFetcherTests.cs +++ b/test/AssociationRegistry.Test.Admin.AddressSync/TeSynchroniserenLocatiesFetcherTests.cs @@ -8,10 +8,10 @@ namespace AssociationRegistry.Test.Admin.AddressSync; using FluentAssertions; using Framework.Customizations; using Grar; -using Grar.AddressSync; using Grar.Exceptions; using Grar.Models; using Marten; +using Messages; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Vereniging; diff --git a/test/AssociationRegistry.Test.Admin.Api/Commands/FeitelijkeVereniging/When_RegistreerFeitelijkeVereniging/CommandHandling/With_Locatie_With_AdresId.cs b/test/AssociationRegistry.Test.Admin.Api/Commands/FeitelijkeVereniging/When_RegistreerFeitelijkeVereniging/CommandHandling/With_Locatie_With_AdresId.cs index f2332fc73..3c86811d4 100644 --- a/test/AssociationRegistry.Test.Admin.Api/Commands/FeitelijkeVereniging/When_RegistreerFeitelijkeVereniging/CommandHandling/With_Locatie_With_AdresId.cs +++ b/test/AssociationRegistry.Test.Admin.Api/Commands/FeitelijkeVereniging/When_RegistreerFeitelijkeVereniging/CommandHandling/With_Locatie_With_AdresId.cs @@ -8,9 +8,9 @@ using Events; using Framework.Fakes; using Grar; -using Grar.AddressMatch; using Grar.Models; using Marten; +using Messages; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Vereniging; diff --git a/test/AssociationRegistry.Test.Admin.Api/Commands/VerenigingOfAnyKind/When_Adding_Locatie/CommandHandling/Given_A_Locatie_With_AdresId.cs b/test/AssociationRegistry.Test.Admin.Api/Commands/VerenigingOfAnyKind/When_Adding_Locatie/CommandHandling/Given_A_Locatie_With_AdresId.cs index daca01cd1..82828b252 100644 --- a/test/AssociationRegistry.Test.Admin.Api/Commands/VerenigingOfAnyKind/When_Adding_Locatie/CommandHandling/Given_A_Locatie_With_AdresId.cs +++ b/test/AssociationRegistry.Test.Admin.Api/Commands/VerenigingOfAnyKind/When_Adding_Locatie/CommandHandling/Given_A_Locatie_With_AdresId.cs @@ -8,9 +8,9 @@ namespace AssociationRegistry.Test.Admin.Api.Commands.VerenigingOfAnyKind.When_A using Common.Scenarios.CommandHandling; using Events; using Grar; -using Grar.AddressMatch; using Grar.Models; using Marten; +using Messages; using Moq; using Vereniging; using Wolverine; diff --git a/test/AssociationRegistry.Test.Admin.Api/Commands/VerenigingOfAnyKind/When_Wijzig_Locatie/CommandHandling/Given_A_Locatie_With_AdresId.cs b/test/AssociationRegistry.Test.Admin.Api/Commands/VerenigingOfAnyKind/When_Wijzig_Locatie/CommandHandling/Given_A_Locatie_With_AdresId.cs index cc4a17506..fbea91efd 100644 --- a/test/AssociationRegistry.Test.Admin.Api/Commands/VerenigingOfAnyKind/When_Wijzig_Locatie/CommandHandling/Given_A_Locatie_With_AdresId.cs +++ b/test/AssociationRegistry.Test.Admin.Api/Commands/VerenigingOfAnyKind/When_Wijzig_Locatie/CommandHandling/Given_A_Locatie_With_AdresId.cs @@ -9,10 +9,10 @@ namespace AssociationRegistry.Test.Admin.Api.Commands.VerenigingOfAnyKind.When_W using Common.Scenarios.CommandHandling; using Events; using Grar; -using Grar.AddressMatch; using Grar.Models; using Grar.Models.PostalInfo; using Marten; +using Messages; using Moq; using Vereniging; using Wolverine; diff --git a/test/AssociationRegistry.Test.E2E/When_Messages_Are_Queued/Via_SQS/When_Sending_An_Incorrect_Message_On_The_Adres_Match_Queue.cs b/test/AssociationRegistry.Test.E2E/When_Messages_Are_Queued/Via_SQS/When_Sending_An_Incorrect_Message_On_The_Adres_Match_Queue.cs index 9cb54203d..5b4999f8b 100644 --- a/test/AssociationRegistry.Test.E2E/When_Messages_Are_Queued/Via_SQS/When_Sending_An_Incorrect_Message_On_The_Adres_Match_Queue.cs +++ b/test/AssociationRegistry.Test.E2E/When_Messages_Are_Queued/Via_SQS/When_Sending_An_Incorrect_Message_On_The_Adres_Match_Queue.cs @@ -1,12 +1,12 @@ namespace AssociationRegistry.Test.E2E.When_Messages_Are_Queued.Via_SQS; using Amazon.SQS.Model; -using Grar.AddressMatch; using Hosts.Configuration; using AssociationRegistry.Test.Common.AutoFixture; using Framework.ApiSetup; using AutoFixture; using FluentAssertions; +using Messages; using Xunit; using Xunit.Abstractions; diff --git a/test/AssociationRegistry.Test/Dubbels/Allow_Loading_DubbeleVereniging/When_Handling_TeAdresMatchenLocatieMessage.cs b/test/AssociationRegistry.Test/Dubbels/Allow_Loading_DubbeleVereniging/When_Handling_ProbeerAdresTeMatchenCommand.cs similarity index 54% rename from test/AssociationRegistry.Test/Dubbels/Allow_Loading_DubbeleVereniging/When_Handling_TeAdresMatchenLocatieMessage.cs rename to test/AssociationRegistry.Test/Dubbels/Allow_Loading_DubbeleVereniging/When_Handling_ProbeerAdresTeMatchenCommand.cs index 3d6ac34fa..7077b060b 100644 --- a/test/AssociationRegistry.Test/Dubbels/Allow_Loading_DubbeleVereniging/When_Handling_TeAdresMatchenLocatieMessage.cs +++ b/test/AssociationRegistry.Test/Dubbels/Allow_Loading_DubbeleVereniging/When_Handling_ProbeerAdresTeMatchenCommand.cs @@ -1,23 +1,23 @@ namespace AssociationRegistry.Test.Dubbels.Allow_Loading_DubbeleVereniging; -using AssociationRegistry.Grar; -using AssociationRegistry.Grar.AddressMatch; -using AssociationRegistry.Vereniging; +using Acties.ProbeerAdresTeMatchen; using AutoFixture; +using Grar; using Microsoft.Extensions.Logging.Abstractions; using Moq; +using Vereniging; using Xunit; -public class When_Handling_TeAdresMatchenLocatieMessage : When_Loading_With_Dubbels_TestBase +public class When_Handling_ProbeerAdresTeMatchenCommand : When_Loading_With_Dubbels_TestBase { [Fact] public async Task Then_It_Should_Have_Loaded_AllowDubbels() { await VerifyVerenigingWasLoadedWithAllowDubbeleVereniging(async repositoryMock => { - var sut = new TeAdresMatchenLocatieMessageHandler(repositoryMock, Mock.Of(), NullLogger.Instance); + var sut = new ProbeerAdresTeMatchenCommandHandler(repositoryMock, Mock.Of(), NullLogger.Instance); - await sut.Handle(_fixture.Create() with + await sut.Handle(_fixture.Create() with { VCode = _fixture.Create(), }, CancellationToken.None); diff --git a/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_AddressIsNullFromGrar.cs b/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_AddressIsNullFromGrar.cs index 5e2d834ca..963bd9ac6 100644 --- a/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_AddressIsNullFromGrar.cs +++ b/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_AddressIsNullFromGrar.cs @@ -1,13 +1,14 @@ namespace AssociationRegistry.Test.Locaties.Adressen.When_SynchroniserenLocatieAdres; -using AssociationRegistry.Events; -using AssociationRegistry.Grar; -using AssociationRegistry.Grar.AddressSync; -using AssociationRegistry.Grar.Models; -using AssociationRegistry.Test.Common.AutoFixture; -using AssociationRegistry.Test.Common.Framework; -using AssociationRegistry.Test.Common.Scenarios.CommandHandling; +using Acties.SyncAdresLocaties; using AutoFixture; +using Common.AutoFixture; +using Common.Framework; +using Common.Scenarios.CommandHandling; +using Events; +using Grar; +using Grar.Models; +using Messages; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Xunit; @@ -29,7 +30,7 @@ public async Task Then_ShouldHaveSaved() var locatie = scenario.Locaties.First(); - var message = fixture.Create() with + var command = fixture.Create() with { LocatiesWithAdres = new List { new(locatie.LocatieId, Adres: null) }, @@ -37,10 +38,10 @@ public async Task Then_ShouldHaveSaved() IdempotenceKey = "123456789", }; - var messageHandler = new TeSynchroniserenLocatieAdresMessageHandler(verenigingRepositoryMock, grarClientMock.Object, - new NullLogger()); + var commandHandler = new SyncAdresLocatiesCommandHandler(verenigingRepositoryMock, grarClientMock.Object, + new NullLogger()); - await messageHandler.Handle(message, CancellationToken.None); + await commandHandler.Handle(command, CancellationToken.None); verenigingRepositoryMock.ShouldHaveSaved(new AdresWerdOntkoppeldVanAdressenregister( scenario.VCode.Value, diff --git a/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_InactiveAddressFromGrar.cs b/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_InactiveAddressFromGrar.cs index b8d7964c5..3eda2036c 100644 --- a/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_InactiveAddressFromGrar.cs +++ b/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_InactiveAddressFromGrar.cs @@ -1,13 +1,13 @@ namespace AssociationRegistry.Test.Locaties.Adressen.When_SynchroniserenLocatieAdres; -using AssociationRegistry.Events; -using AssociationRegistry.Grar; -using AssociationRegistry.Grar.AddressSync; -using AssociationRegistry.Grar.Models; -using AssociationRegistry.Test.Common.AutoFixture; -using AssociationRegistry.Test.Common.Framework; -using AssociationRegistry.Test.Common.Scenarios.CommandHandling; +using Acties.SyncAdresLocaties; using AutoFixture; +using Common.AutoFixture; +using Common.Framework; +using Common.Scenarios.CommandHandling; +using Events; +using Grar; +using Grar.Models; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Xunit; @@ -37,7 +37,7 @@ public async Task Then_An_AdresWerdOntkoppeldVanAdressenregister_Was_Saved() var locatie = scenario.Locaties.First(); - var message = fixture.Create() with + var command = fixture.Create() with { LocatiesWithAdres = new List { new(locatie.LocatieId, mockedAdresDetail) }, @@ -45,10 +45,10 @@ public async Task Then_An_AdresWerdOntkoppeldVanAdressenregister_Was_Saved() IdempotenceKey = "123456789", }; - var messageHandler = new TeSynchroniserenLocatieAdresMessageHandler(verenigingRepositoryMock, grarClientMock.Object, - new NullLogger()); + var commandHandler = new SyncAdresLocatiesCommandHandler(verenigingRepositoryMock, grarClientMock.Object, + new NullLogger()); - await messageHandler.Handle(message, CancellationToken.None); + await commandHandler.Handle(command, CancellationToken.None); verenigingRepositoryMock.ShouldHaveSaved( new AdresWerdOntkoppeldVanAdressenregister(scenario.VCode.Value, diff --git a/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_No_Changes_Then_No_Event.cs b/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_No_Changes_Then_No_Event.cs index eb2675555..e5f90baa2 100644 --- a/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_No_Changes_Then_No_Event.cs +++ b/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_No_Changes_Then_No_Event.cs @@ -1,13 +1,14 @@ namespace AssociationRegistry.Test.Locaties.Adressen.When_SynchroniserenLocatieAdres; -using AssociationRegistry.Events; -using AssociationRegistry.Grar; -using AssociationRegistry.Grar.AddressSync; -using AssociationRegistry.Grar.Models; -using AssociationRegistry.Test.Common.AutoFixture; -using AssociationRegistry.Test.Common.Framework; -using AssociationRegistry.Test.Common.Scenarios.CommandHandling; +using Acties.SyncAdresLocaties; using AutoFixture; +using Common.AutoFixture; +using Common.Framework; +using Common.Scenarios.CommandHandling; +using Events; +using Grar; +using Grar.Models; +using Messages; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Xunit; @@ -52,7 +53,7 @@ public async Task Then_A_LocatieWerdToegevoegd_Event_Is_Saved() grarClientMock.Setup(x => x.GetAddressById("123", CancellationToken.None)) .ReturnsAsync(mockedAdresDetail); - var message = fixture.Create() with + var command = fixture.Create() with { LocatiesWithAdres = new List { new(locatie.LocatieId, mockedAdresDetail) }, @@ -60,10 +61,10 @@ public async Task Then_A_LocatieWerdToegevoegd_Event_Is_Saved() IdempotenceKey = "123456789", }; - var messageHandler = new TeSynchroniserenLocatieAdresMessageHandler(verenigingRepositoryMock, grarClientMock.Object, - new NullLogger()); + var commandHandler = new SyncAdresLocatiesCommandHandler(verenigingRepositoryMock, grarClientMock.Object, + new NullLogger()); - await messageHandler.Handle(message, CancellationToken.None); + await commandHandler.Handle(command, CancellationToken.None); verenigingRepositoryMock.ShouldNotHaveAnySaves(); verenigingRepositoryMock.ShouldNotHaveSaved(); diff --git a/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_NonExistingLocatie.cs b/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_NonExistingLocatie.cs index db71a575e..156d0c60d 100644 --- a/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_NonExistingLocatie.cs +++ b/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_NonExistingLocatie.cs @@ -1,12 +1,13 @@ namespace AssociationRegistry.Test.Locaties.Adressen.When_SynchroniserenLocatieAdres; -using AssociationRegistry.Grar; -using AssociationRegistry.Grar.AddressSync; -using AssociationRegistry.Grar.Models; -using AssociationRegistry.Test.Common.AutoFixture; -using AssociationRegistry.Test.Common.Framework; -using AssociationRegistry.Test.Common.Scenarios.CommandHandling; +using Acties.SyncAdresLocaties; using AutoFixture; +using Common.AutoFixture; +using Common.Framework; +using Common.Scenarios.CommandHandling; +using Grar; +using Grar.Models; +using Messages; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Xunit; @@ -38,7 +39,7 @@ public async Task Then_An_AdresWerdOntkoppeldVanAdressenregister_Was_Saved() var nonExistingLocatieId = locatieId * -1; - var message = fixture.Create() with + var command = fixture.Create() with { LocatiesWithAdres = new List { new(nonExistingLocatieId, mockedAdresDetail) }, @@ -46,10 +47,10 @@ public async Task Then_An_AdresWerdOntkoppeldVanAdressenregister_Was_Saved() IdempotenceKey = "123456789", }; - var messageHandler = new TeSynchroniserenLocatieAdresMessageHandler(verenigingRepositoryMock, grarClientMock.Object, - new NullLogger()); + var commandHandler = new SyncAdresLocatiesCommandHandler(verenigingRepositoryMock, grarClientMock.Object, + new NullLogger()); - await messageHandler.Handle(message, CancellationToken.None); + await commandHandler.Handle(command, CancellationToken.None); verenigingRepositoryMock.ShouldNotHaveAnySaves(); } diff --git a/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_TeSyncroniseren_LocatieAdres.cs b/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_TeSyncroniseren_LocatieAdres.cs index 77614539d..2c0bd8be5 100644 --- a/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_TeSyncroniseren_LocatieAdres.cs +++ b/test/AssociationRegistry.Test/Locaties/Adressen/When_SynchroniserenLocatieAdres/With_TeSyncroniseren_LocatieAdres.cs @@ -1,13 +1,13 @@ namespace AssociationRegistry.Test.Locaties.Adressen.When_SynchroniserenLocatieAdres; -using AssociationRegistry.Events; -using AssociationRegistry.Grar; -using AssociationRegistry.Grar.AddressSync; -using AssociationRegistry.Grar.Models; -using AssociationRegistry.Test.Common.AutoFixture; -using AssociationRegistry.Test.Common.Framework; -using AssociationRegistry.Test.Common.Scenarios.CommandHandling; +using Acties.SyncAdresLocaties; using AutoFixture; +using Common.AutoFixture; +using Common.Framework; +using Common.Scenarios.CommandHandling; +using Events; +using Grar; +using Grar.Models; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Xunit; @@ -37,7 +37,7 @@ public async Task Then_A_AdresWerdGewijzigdInHetAdressenregiser() var locatieId = scenario.Locaties.First().LocatieId; - var message = fixture.Create() with + var command = fixture.Create() with { LocatiesWithAdres = new List { new(locatieId, mockedAdresDetail) }, @@ -45,16 +45,16 @@ public async Task Then_A_AdresWerdGewijzigdInHetAdressenregiser() IdempotenceKey = "123456789", }; - var messageHandler = new TeSynchroniserenLocatieAdresMessageHandler(verenigingRepositoryMock, grarClientMock.Object, - new NullLogger()); + var commandHandler = new SyncAdresLocatiesCommandHandler(verenigingRepositoryMock, grarClientMock.Object, + new NullLogger()); - await messageHandler.Handle(message, CancellationToken.None); + await commandHandler.Handle(command, CancellationToken.None); verenigingRepositoryMock.ShouldHaveSaved( new AdresWerdGewijzigdInAdressenregister(scenario.VCode.Value, locatieId, mockedAdresDetail.AdresId, mockedAdresDetail.ToAdresUitAdressenregister(), - message.IdempotenceKey) + command.IdempotenceKey) ); } }