diff --git a/src/StreetNameRegistry/Municipality/MunicipalityStreetName.cs b/src/StreetNameRegistry/Municipality/MunicipalityStreetName.cs index bab1b96b6..04939c63d 100644 --- a/src/StreetNameRegistry/Municipality/MunicipalityStreetName.cs +++ b/src/StreetNameRegistry/Municipality/MunicipalityStreetName.cs @@ -109,9 +109,11 @@ public void CorrectNames(Names namesToCorrect, Action x.Language == correctedName.Language); - // This should never happen in the normal flow, but with CRAB migration there are streetnames without names in supported every language - if(originalName is null) - throw new StreetNameNameCorrectionExceededCharacterChangeLimitException(correctedName.Name); + // This should never happen in the normal flow, but with CRAB migration there are streetnames without names in supported languages + if (originalName is null) + { + continue; + } var changeDifference = LevenshteinDistanceCalculator.CalculatePercentage(correctedName.Name, originalName.Name); diff --git a/test/StreetNameRegistry.Tests/AggregateTests/WhenCorrectingStreetNameName/GivenMunicipality.cs b/test/StreetNameRegistry.Tests/AggregateTests/WhenCorrectingStreetNameName/GivenMunicipality.cs index d6273d519..4e390628e 100644 --- a/test/StreetNameRegistry.Tests/AggregateTests/WhenCorrectingStreetNameName/GivenMunicipality.cs +++ b/test/StreetNameRegistry.Tests/AggregateTests/WhenCorrectingStreetNameName/GivenMunicipality.cs @@ -329,6 +329,47 @@ public void WithInvalidLanguage_ThenThrowsStreetNameNameLanguageNotSupportedExce $"The language '{Language.Dutch}' is not an official or facility language of municipality '{_municipalityId}'."))); } + [Fact] + public void WithOfficialLanguageNotInProposedStreetName_ThenThrowsStreetNameNameLanguageNotSupportedException() + { + var invalidStreetName = new StreetNameName("Rue de la Chapelle", Language.French); + var streetNameNames = new Names(new[] + { + new StreetNameName("Kapelstraat", Language.Dutch), + invalidStreetName + }); + + var command = Fixture.Create() + .WithStreetNameNames(streetNameNames); + + var dutchLanguageWasAdded = new MunicipalityOfficialLanguageWasAddedBuilder(Fixture) + .WithLanguage(Language.Dutch) + .Build(); + + var frenchLanguageWasAdded = new MunicipalityOfficialLanguageWasAddedBuilder(Fixture) + .WithLanguage(Language.French) + .Build(); + + var streetNameWasProposedV2 = Fixture.Create() + .WithNames(new Names([new StreetNameName("Kapestraat", Language.Dutch)])); + + // Act, assert + Assert(new Scenario() + .Given(_streamId, + Fixture.Create(), + Fixture.Create(), + dutchLanguageWasAdded, + frenchLanguageWasAdded, + streetNameWasProposedV2) + .When(command) + .Then(new Fact(_streamId, + new StreetNameNamesWereCorrected( + _municipalityId, + command.PersistentLocalId, + command.StreetNameNames)) + )); + } + [Fact] public void WithFacilityLanguageNotInProposedStreetName_ThenThrowsStreetNameNameLanguageNotSupportedException() { @@ -362,7 +403,12 @@ public void WithFacilityLanguageNotInProposedStreetName_ThenThrowsStreetNameName facilityLanguageWasAdded, streetNameWasProposedV2) .When(command) - .Throws(new StreetNameNameCorrectionExceededCharacterChangeLimitException(invalidStreetName.Name))); + .Then(new Fact(_streamId, + new StreetNameNamesWereCorrected( + _municipalityId, + command.PersistentLocalId, + command.StreetNameNames)) + )); } [Fact]