-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: or-1972 delete vereniging from index when VerenigingIsGestopt
- Loading branch information
1 parent
8011e4e
commit 32e3b87
Showing
10 changed files
with
131 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
test/AssociationRegistry.Test.Admin.Api/WhenDetectingDuplicates/Given_A_Stopzetting.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
namespace AssociationRegistry.Test.Admin.Api.WhenDetectingDuplicates; | ||
|
||
using AssociationRegistry.Admin.Api.Verenigingen.Common; | ||
using AssociationRegistry.Admin.Api.Verenigingen.Registreer.FeitelijkeVereniging.RequetsModels; | ||
using AutoFixture; | ||
using Events; | ||
using Fixtures; | ||
using Fixtures.Scenarios.EventsInDb; | ||
using FluentAssertions; | ||
using Framework; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using System.Net; | ||
using Vereniging; | ||
using Xunit; | ||
using Xunit.Categories; | ||
using Adres = AssociationRegistry.Admin.Api.Verenigingen.Common.Adres; | ||
|
||
[Collection(nameof(AdminApiCollection))] | ||
[Category("AdminApi")] | ||
[IntegrationTest] | ||
public class Given_A_Stopzetting | ||
{ | ||
|
||
private readonly AdminApiClient _adminApiClient; | ||
private readonly Fixture _fixture; | ||
private readonly V047_FeitelijkeVerenigingWerdGeregistreerd_WithMinimalFields_ForDuplicateDetection_WithAnalyzer _scenario; | ||
|
||
public Given_A_Stopzetting(EventsInDbScenariosFixture fixture) | ||
{ | ||
_fixture = new Fixture().CustomizeAdminApi(); | ||
_adminApiClient = fixture.AdminApiClient; | ||
_scenario = fixture.V047FeitelijkeVerenigingWerdGeregistreerdWithMinimalFieldsForDuplicateDetectionWithAnalyzer; | ||
} | ||
|
||
[Theory] | ||
[InlineData("V9999052", "Vereniging van Technologïeënthusiasten: Inováçie & Ëntwikkeling")] | ||
public async Task? Then_The_Stopped_Duplicate_IsNotDetected( | ||
string duplicatesShouldNotContainThisVCode, | ||
string naam) | ||
{ | ||
var request = CreateRegistreerFeitelijkeVerenigingRequest(duplicatesShouldNotContainThisVCode, naam); | ||
|
||
var response = await _adminApiClient.RegistreerFeitelijkeVereniging(JsonConvert.SerializeObject(request)); | ||
response.StatusCode.Should().Be(HttpStatusCode.Conflict); | ||
|
||
var responseContent = await response.Content.ReadAsStringAsync(); | ||
|
||
var vCodes = ExtractDuplicateVCode(responseContent); | ||
|
||
vCodes.Should().NotContain(duplicatesShouldNotContainThisVCode); | ||
} | ||
|
||
private RegistreerFeitelijkeVerenigingRequest CreateRegistreerFeitelijkeVerenigingRequest(string vCode, string naam) | ||
{ | ||
var @event = _scenario.EventsPerVCode | ||
.Single(t => t.Item1.Value == vCode) | ||
.Item2 | ||
.First() as FeitelijkeVerenigingWerdGeregistreerd; | ||
|
||
return new RegistreerFeitelijkeVerenigingRequest | ||
{ | ||
Naam = naam, | ||
Startdatum = null, | ||
KorteNaam = "", | ||
KorteBeschrijving = "", | ||
Locaties = new[] | ||
{ | ||
new ToeTeVoegenLocatie | ||
{ | ||
Locatietype = Locatietype.Correspondentie, | ||
Adres = new Adres | ||
{ | ||
Straatnaam = _fixture.Create<string>(), | ||
Huisnummer = _fixture.Create<string>(), | ||
Postcode = @event.Locaties.First().Adres.Postcode, | ||
Gemeente = @event.Locaties.First().Adres.Gemeente, | ||
Land = _fixture.Create<string>(), | ||
}, | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
private static IEnumerable<string> ExtractDuplicateVCode(string responseContent) | ||
=> JObject.Parse(responseContent) | ||
.SelectTokens("$.mogelijkeDuplicateVerenigingen[*].vCode") | ||
.Select(x => x.ToString()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters