Skip to content

Commit

Permalink
fix: update parcel geometry when ParcelWasCorrectedFromRetiredToRealized
Browse files Browse the repository at this point in the history
  • Loading branch information
jvandaal authored and ArneD committed Feb 14, 2025
1 parent 999331f commit 07b380d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ await context
.ParcelConsumerItemsWithCount.FindAsync([Guid.Parse(message.ParcelId)], cancellationToken: ct);

parcel!.Status = ParcelStatus.Realized;
var extendedWkbGeometry = message.ExtendedWkbGeometry.ToByteArray();
parcel.ExtendedWkbGeometry = extendedWkbGeometry;
parcel.SetGeometry(wkbReader.Read(extendedWkbGeometry));

var buildingPersistentLocalIds = await GetBuildingPersistentLocalIdsToInvalidate(parcel.Geometry);

context.BuildingsToInvalidate.AddRange(buildingPersistentLocalIds.Select(x => new BuildingToInvalidate
{
BuildingPersistentLocalId = x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ await Then(async context =>
}

[Fact]
public async Task ParcelWasCorrectedFromRetiredToRealized_SetsParcelStatusToRealized()
public async Task ParcelWasCorrectedFromRetiredToRealized_SetsParcelStatusToRealizedAndUpdatesGeometry()
{
var parcelId = Fixture.Create<Guid>().ToString("D");
var capakey = Fixture.Create<Guid>().ToString("D");
Expand All @@ -368,12 +368,13 @@ public async Task ParcelWasCorrectedFromRetiredToRealized_SetsParcelStatusToReal
))
.Create();

var expectedGeometry = GeometryHelper.SecondValidPolygon.AsBinary();
var parcelWasCorrectedFromRetiredToRealized = Fixture
.Build<ParcelWasCorrectedFromRetiredToRealized>()
.FromFactory(() => new ParcelWasCorrectedFromRetiredToRealized(
parcelId,
capakey,
GeometryHelper.ValidPolygon.AsBinary().ToHexString(),
expectedGeometry.ToHexString(),
Fixture.Create<Provenance>()
))
.Create();
Expand All @@ -384,7 +385,7 @@ public async Task ParcelWasCorrectedFromRetiredToRealized_SetsParcelStatusToReal
.SetupSequence(x => x.GetUnderlyingBuildings(It.IsAny<Geometry>()))
.Returns(Array.Empty<int>())
.Returns(Array.Empty<int>())
.Returns(new[] { underlyingBuildingId });
.Returns([underlyingBuildingId]);

Given(parcelWasImported, parcelWasRetiredV2, parcelWasCorrectedFromRetiredToRealized);

Expand All @@ -396,6 +397,7 @@ await Then(async context =>
parcel.Should().NotBeNull();
parcel!.CaPaKey.Should().Be(parcelWasCorrectedFromRetiredToRealized.CaPaKey);
parcel.Status.Should().Be(ParcelStatus.Realized);
parcel.ExtendedWkbGeometry.Should().BeEquivalentTo(expectedGeometry);
parcel.IsRemoved.Should().Be(parcel.IsRemoved);

var buildingsToInvalidate = context.BuildingsToInvalidate.Local.ToList();
Expand Down

0 comments on commit 07b380d

Please sign in to comment.