From 74c77796118d14f7e35718e26d32708b55740a45 Mon Sep 17 00:00:00 2001 From: Koen Metsu Date: Tue, 9 Jan 2024 17:27:25 +0100 Subject: [PATCH] fix: or-2035 fix registreer request, check extra field in validationproblemdetails --- .../With_Html_Fields.cs | 15 ++++++-- .../AdminApiAutoFixtureCustomizations.cs | 34 ++++++++++++------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/test/AssociationRegistry.Test.Admin.Api/FeitelijkeVereniging/When_RegistreerFeitelijkeVereniging/With_Html_Fields.cs b/test/AssociationRegistry.Test.Admin.Api/FeitelijkeVereniging/When_RegistreerFeitelijkeVereniging/With_Html_Fields.cs index af6e7ca3e..dca332e94 100644 --- a/test/AssociationRegistry.Test.Admin.Api/FeitelijkeVereniging/When_RegistreerFeitelijkeVereniging/With_Html_Fields.cs +++ b/test/AssociationRegistry.Test.Admin.Api/FeitelijkeVereniging/When_RegistreerFeitelijkeVereniging/With_Html_Fields.cs @@ -1,8 +1,10 @@ namespace AssociationRegistry.Test.Admin.Api.FeitelijkeVereniging.When_RegistreerFeitelijkeVereniging; using AssociationRegistry.Admin.Api.Constants; +using AssociationRegistry.Admin.Api.Verenigingen.Common; using AssociationRegistry.Admin.Api.Verenigingen.Registreer.FeitelijkeVereniging.RequetsModels; using AutoFixture; +using Be.Vlaanderen.Basisregisters.BasicApiProblem; using Fixtures; using FluentAssertions; using Framework; @@ -24,12 +26,19 @@ public IEnumerator GetEnumerator() yield return new object[] { request1 }; var request2 = autoFixture.Create(); - request2.HoofdactiviteitenVerenigingsloket = new[] { "" }; + request2.HoofdactiviteitenVerenigingsloket = new[] { "" }; yield return new object[] { request2 }; var request3 = autoFixture.Create(); - request3.KorteNaam = "Click here"; + request3.KorteNaam = "Click here"; + + var request4 = autoFixture.Create(); + var contactgegeven = autoFixture.Create(); + contactgegeven.Beschrijving = "
";
+        request4.Contactgegevens = request4.Contactgegevens.Append(contactgegeven).ToArray();
+
+        yield return new object[] { request4 };
 
         yield return new object[] { request3 };
     }
@@ -56,6 +65,8 @@ public async Task Then_it_returns_a_bad_request_response(RegistreerFeitelijkeVer
     {
         var response = await _fixture.DefaultClient.RegistreerFeitelijkeVereniging(GetJsonBody(request));
         response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
+        var body = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync());
+        body.ValidationErrors.Should().ContainKey(ExceptionMessages.UnsupportedContent); // TODO: OF EEN ANDER VELD
     }
 
     private string GetJsonBody(RegistreerFeitelijkeVerenigingRequest request)
diff --git a/test/AssociationRegistry.Test.Admin.Api/Framework/AdminApiAutoFixtureCustomizations.cs b/test/AssociationRegistry.Test.Admin.Api/Framework/AdminApiAutoFixtureCustomizations.cs
index d54f619e5..00193d4cb 100644
--- a/test/AssociationRegistry.Test.Admin.Api/Framework/AdminApiAutoFixtureCustomizations.cs
+++ b/test/AssociationRegistry.Test.Admin.Api/Framework/AdminApiAutoFixtureCustomizations.cs
@@ -83,20 +83,28 @@ private static void CustomizeRegistreerFeitelijkeVerenigingRequest(this IFixture
     {
         fixture.Customize(
             composer => composer.FromFactory(
-                _ => new RegistreerFeitelijkeVerenigingRequest
+                _ =>
                 {
-                    Contactgegevens = fixture.CreateMany().ToArray(),
-                    Locaties = fixture.CreateMany().DistinctBy(l => l.Locatietype).ToArray(),
-                    Startdatum = fixture.Create(),
-                    Naam = fixture.Create(),
-                    Doelgroep = fixture.Create(),
-                    Vertegenwoordigers = fixture.CreateMany().ToArray(),
-                    HoofdactiviteitenVerenigingsloket = fixture.CreateMany()
-                                                               .Select(x => x.Code)
-                                                               .Distinct()
-                                                               .ToArray(),
-                    KorteBeschrijving = fixture.Create(),
-                    KorteNaam = fixture.Create(),
+                    var datum = fixture.Create();
+                    var startDatum = new DateOnly(new Random().Next(1970, DateTime.Now.Year), datum.Value.Month, datum.Value.Day);
+                    var request = new RegistreerFeitelijkeVerenigingRequest();
+
+                    request.Contactgegevens = fixture.CreateMany().ToArray();
+                    request.Locaties = fixture.CreateMany().DistinctBy(l => l.Locatietype).ToArray();
+                    request.Startdatum = startDatum;
+                    request.Naam = fixture.Create();
+                    request.Doelgroep = fixture.Create();
+                    request.Vertegenwoordigers = fixture.CreateMany().ToArray();
+
+                    request.HoofdactiviteitenVerenigingsloket = fixture.CreateMany()
+                                                                       .Select(x => x.Code)
+                                                                       .Distinct()
+                                                                       .ToArray();
+
+                    request.KorteBeschrijving = fixture.Create();
+                    request.KorteNaam = fixture.Create();
+
+                    return request;
                 }).OmitAutoProperties());
     }