-
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-1759 add naamwerdgewijzigd to publiek detail
- Loading branch information
1 parent
45bd5fe
commit 3902a7b
Showing
10 changed files
with
335 additions
and
7 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
24 changes: 24 additions & 0 deletions
24
...ociationRegistry.Public.ProjectionHost/Infrastructure/Extensions/IEnumerableExtensions.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,24 @@ | ||
namespace AssociationRegistry.Public.ProjectionHost.Infrastructure.Extensions; | ||
|
||
public static class IEnumerableExtensions | ||
{ | ||
public static IEnumerable<T> UpdateSingle<T>(this IEnumerable<T> collection, Func<T, bool> identityFunc, Func<T, T> update) | ||
{ | ||
var array = collection as T[] ?? collection.ToArray(); | ||
var objectToUpdate = array.Single(identityFunc); | ||
var updatedObject = update(objectToUpdate); | ||
return array | ||
.Where(t1 => !identityFunc(t1)) | ||
.Append(updatedObject); | ||
} | ||
|
||
public static IEnumerable<T> UpdateSingleWith<T>(this IEnumerable<T> collection, Func<T, bool> identityFunc, Func<T, T> update) | ||
{ | ||
var array = collection as T[] ?? collection.ToArray(); | ||
var objectToUpdate = array.Single(identityFunc); | ||
var updatedObject = update(objectToUpdate); | ||
return array | ||
.Where(t1 => !identityFunc(t1)) | ||
.Append(updatedObject); | ||
} | ||
} |
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
72 changes: 72 additions & 0 deletions
72
...ents/Scenarios/V018_AfdelingWerdGeregistreerd_MetBestaandeMoeder_VoorNaamWerdGewijzigd.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,72 @@ | ||
namespace AssociationRegistry.Test.Public.Api.Fixtures.GivenEvents.Scenarios; | ||
|
||
using AssociationRegistry.Framework; | ||
using AutoFixture; | ||
using Events; | ||
using EventStore; | ||
using Framework; | ||
using Vereniging; | ||
|
||
public class V018_AfdelingWerdGeregistreerd_MetBestaandeMoeder_VoorNaamWerdGewijzigd : IScenario | ||
{ | ||
public readonly VerenigingMetRechtspersoonlijkheidWerdGeregistreerd MoederWerdGeregistreerd; | ||
public readonly AfdelingWerdGeregistreerd AfdelingWerdGeregistreerd; | ||
public readonly NaamWerdGewijzigd NaamWerdGewijzigd; | ||
public readonly CommandMetadata Metadata; | ||
|
||
public V018_AfdelingWerdGeregistreerd_MetBestaandeMoeder_VoorNaamWerdGewijzigd() | ||
{ | ||
var fixture = new Fixture().CustomizePublicApi(); | ||
|
||
VCodeMoeder = "V9999018"; | ||
NaamMoeder = "De coolste moeder"; | ||
|
||
VCode = VCode.Create("V9999019"); | ||
NaamAfdeling = "De coolste afdeling"; | ||
|
||
MoederWerdGeregistreerd = fixture.Create<VerenigingMetRechtspersoonlijkheidWerdGeregistreerd>() with | ||
{ | ||
VCode = VCodeMoeder, | ||
Naam = NaamMoeder, | ||
Rechtsvorm = "SVON" | ||
}; | ||
|
||
KboNummerMoeder = MoederWerdGeregistreerd.KboNummer; | ||
|
||
AfdelingWerdGeregistreerd = fixture.Create<AfdelingWerdGeregistreerd>() with | ||
{ | ||
VCode = VCode, | ||
Moedervereniging = new AfdelingWerdGeregistreerd.MoederverenigingsData(KboNummerMoeder, VCodeMoeder, NaamMoeder), | ||
Locaties = Array.Empty<Registratiedata.Locatie>(), | ||
Naam = "De minder coole afdeling", | ||
KorteNaam = string.Empty, | ||
Startdatum = null, | ||
KorteBeschrijving = string.Empty, | ||
Contactgegevens = Array.Empty<Registratiedata.Contactgegeven>(), | ||
Vertegenwoordigers = Array.Empty<Registratiedata.Vertegenwoordiger>(), | ||
HoofdactiviteitenVerenigingsloket = Array.Empty<Registratiedata.HoofdactiviteitVerenigingsloket>(), | ||
}; | ||
|
||
NaamWerdGewijzigd = fixture.Create<NaamWerdGewijzigd>() with | ||
{ | ||
VCode = VCode, | ||
Naam = NaamAfdeling | ||
}; | ||
|
||
Metadata = fixture.Create<CommandMetadata>() with { ExpectedVersion = null }; | ||
} | ||
|
||
public string KboNummerMoeder { get; set; } | ||
public string NaamMoeder { get; set; } | ||
public string NaamAfdeling { get; set; } | ||
public string VCodeMoeder { get; set; } | ||
public VCode VCode { get; set; } | ||
public StreamActionResult Result { get; set; } = null!; | ||
|
||
public IEvent[] GetEvents() | ||
=> new IEvent[] | ||
{ MoederWerdGeregistreerd, AfdelingWerdGeregistreerd, NaamWerdGewijzigd }; | ||
|
||
public CommandMetadata GetCommandMetadata() | ||
=> Metadata; | ||
} |
67 changes: 67 additions & 0 deletions
67
...n_MoederWerdGeregistreerd_And_Then_AfdelingWerdGeregistreerd_AndThen_NaamWerdGewijzigd.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,67 @@ | ||
namespace AssociationRegistry.Test.Public.Api.When_Retrieving_Detail; | ||
|
||
using Fixtures; | ||
using Fixtures.GivenEvents; | ||
using Fixtures.GivenEvents.Scenarios; | ||
using FluentAssertions; | ||
using Microsoft.Net.Http.Headers; | ||
using System.Net; | ||
using templates; | ||
using Test.Framework; | ||
using Xunit; | ||
using Xunit.Categories; | ||
|
||
[Collection(nameof(PublicApiCollection))] | ||
[Category("AdminApi")] | ||
[IntegrationTest] | ||
public class Given_MoederWerdGeregistreerd_And_Then_AfdelingWerdGeregistreerd_AndThen_NaamWerdGewijzigd | ||
{ | ||
private readonly PublicApiClient _apiClient; | ||
private readonly V018_AfdelingWerdGeregistreerd_MetBestaandeMoeder_VoorNaamWerdGewijzigd _scenario; | ||
|
||
public Given_MoederWerdGeregistreerd_And_Then_AfdelingWerdGeregistreerd_AndThen_NaamWerdGewijzigd(GivenEventsFixture fixture) | ||
{ | ||
_scenario = fixture.V018AfdelingWerdGeregistreerdMetBestaandeMoederVoorNaamWerdGewijzigd; | ||
_apiClient = fixture.PublicApiClient; | ||
} | ||
|
||
[Fact] | ||
public async Task Then_we_get_a_successful_response_if_sequence_is_equal_or_greater_than_expected_sequence() | ||
=> (await _apiClient.GetDetail(_scenario.VCode)) | ||
.Should().BeSuccessful(); | ||
|
||
[Fact] | ||
public async Task Then_we_get_a_successful_response_if_no_sequence_provided() | ||
=> (await _apiClient.GetDetail(_scenario.VCode)) | ||
.Should().BeSuccessful(); | ||
|
||
|
||
[Fact] | ||
public async Task Then_we_get_a_detail_afdeling_response() | ||
{ | ||
var response = await _apiClient.GetDetail(_scenario.VCode); | ||
var content = await response.Content.ReadAsStringAsync(); | ||
|
||
var expected = new DetailVerenigingResponseTemplate() | ||
.FromEvent(_scenario.AfdelingWerdGeregistreerd) | ||
.WithNaam(_scenario.NaamWerdGewijzigd.Naam) | ||
.WithDatumLaatsteAanpassing(_scenario.Metadata.Tijdstip); | ||
|
||
content.Should().BeEquivalentJson(expected); | ||
} | ||
|
||
[Fact] | ||
public async Task Then_we_get_a_detail_moeder_response() | ||
{ | ||
var response = await _apiClient.GetDetail(_scenario.MoederWerdGeregistreerd.VCode); | ||
|
||
var content = await response.Content.ReadAsStringAsync(); | ||
|
||
var expected = new DetailVerenigingResponseTemplate() | ||
.FromEvent(_scenario.MoederWerdGeregistreerd) | ||
.WithDatumLaatsteAanpassing(_scenario.Metadata.Tijdstip) | ||
.HeeftAfdeling(_scenario.AfdelingWerdGeregistreerd.VCode, _scenario.NaamWerdGewijzigd.Naam); | ||
|
||
content.Should().BeEquivalentJson(expected); | ||
} | ||
} |
Oops, something went wrong.