Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: test region in migrator to skip address #1097

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace AddressRegistry.Migrator.Address.Infrastructure
using Api.BackOffice.Abstractions;
using Autofac;
using Be.Vlaanderen.Basisregisters.CommandHandling;
using Be.Vlaanderen.Basisregisters.GrAr.Legacy;
using Consumer.StreetName;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
Expand Down Expand Up @@ -186,6 +187,9 @@ await backOfficeContext
var addressId = new AddressId(Guid.Parse(aggregateId));
var addressAggregate = await addressRepo.GetAsync(addressId, token);

var streetNameId = (Guid)addressAggregate.StreetNameId;
var streetName = _consumerItems.SingleOrDefault(x => x.StreetNameId == streetNameId);

if (!addressAggregate.IsComplete)
{
if (addressAggregate.IsRemoved)
Expand All @@ -194,17 +198,18 @@ await backOfficeContext
return null;
}

if (_skipIncomplete)
var streetNameAggregate = await streamLifetimeScope
.Resolve<IStreetNames>()
.GetAsync(new StreetNameStreamId(new StreetNamePersistentLocalId(streetName.PersistentLocalId)), token);

if (_skipIncomplete || RegionFilter.IsFlemishRegion(streetNameAggregate.MigratedNisCode!))
{
return null;
}

throw new InvalidOperationException($"Incomplete but not removed Address '{aggregateId}'.");
}

var streetNameId = (Guid)addressAggregate.StreetNameId;
var streetName = _consumerItems.SingleOrDefault(x => x.StreetNameId == streetNameId);

if (streetName == null)
{
throw new InvalidOperationException($"StreetName for StreetNameId '{streetNameId}' was not found.");
Expand Down
Loading