From 0487762cf6e55b29aefdb6ef82cdcb7d2629972c Mon Sep 17 00:00:00 2001 From: Koen Metsu Date: Wed, 25 Sep 2024 13:38:12 +0200 Subject: [PATCH] feat: or-2535 clear legal entity type when clearing kbo state --- docker-compose.yml | 3 + .../Organisation/State/KboState.cs | 1 + .../OrganisationHandlerTests.cs | 65 ++++++++++++++++++- 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 01c0dc52e..9946ed3bd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,9 @@ services: environment: discovery.type: 'single-node' DISABLE_SECURITY_PLUGIN: true + cluster.routing.allocation.disk.watermark.low: 97% + cluster.routing.allocation.disk.watermark.high: 98% + cluster.routing.allocation.disk.watermark.flood_stage: 99% ports: - "9200:9200" - "9600:9600" diff --git a/src/OrganisationRegistry/Organisation/State/KboState.cs b/src/OrganisationRegistry/Organisation/State/KboState.cs index e9e1d8e72..60f9f7994 100644 --- a/src/OrganisationRegistry/Organisation/State/KboState.cs +++ b/src/OrganisationRegistry/Organisation/State/KboState.cs @@ -22,6 +22,7 @@ public void Clear() KboRegisteredOffice = null; KboFormalNameLabel = null; KboLegalFormOrganisationClassification = null; + LegalEntityTypeCode = null; } public KboState() diff --git a/test/OrganisationRegistry.ElasticSearch.Tests/OrganisationHandlerTests.cs b/test/OrganisationRegistry.ElasticSearch.Tests/OrganisationHandlerTests.cs index 6657f19e5..41ff3c730 100644 --- a/test/OrganisationRegistry.ElasticSearch.Tests/OrganisationHandlerTests.cs +++ b/test/OrganisationRegistry.ElasticSearch.Tests/OrganisationHandlerTests.cs @@ -277,6 +277,70 @@ await _eventProcessor.Handle( }); } + [Fact] + public async void LegalEntityTypeAdded() + { + var scenario = new OrganisationScenario(Guid.NewGuid()); + var forcedKboTermination = false; + scenario.AddCustomization(new ParameterNameArg("forcedKboTermination", forcedKboTermination)); + + var organisationValidity = scenario.Create() ?? scenario.Create(); + + var initialiseProjection = scenario.Create(); + var organisationCreated = scenario.Create(); + var coupledWithKbo = scenario.Create(); + var legalEntityTypeAdded = scenario.Create(); + + await _eventProcessor.Handle( + new List + { + initialiseProjection.ToEnvelope(), + organisationCreated.ToEnvelope(), + coupledWithKbo.ToEnvelope(), + legalEntityTypeAdded.ToEnvelope(), + } + ); + + await _fixture.Elastic.ReadClient.Indices.RefreshAsync(Indices.Index()); + var organisation = _fixture.Elastic.ReadClient.Get(organisationCreated.OrganisationId); + + organisation.Source.LegalEntityType.Should().BeEquivalentTo(new LegalEntityType( + legalEntityTypeAdded.LegalEntityTypeCode, + legalEntityTypeAdded.LegalEntityTypeDescription)); + } + + [Fact] + public async void KboCouplingCancelled() + { + var scenario = new OrganisationScenario(Guid.NewGuid()); + var forcedKboTermination = false; + scenario.AddCustomization(new ParameterNameArg("forcedKboTermination", forcedKboTermination)); + + var organisationValidity = scenario.Create() ?? scenario.Create(); + + var initialiseProjection = scenario.Create(); + var organisationCreated = scenario.Create(); + var coupledWithKbo = scenario.Create(); + var legalEntityTypeAdded = scenario.Create(); + var couplingCancelled = scenario.Create(); + + await _eventProcessor.Handle( + new List + { + initialiseProjection.ToEnvelope(), + organisationCreated.ToEnvelope(), + coupledWithKbo.ToEnvelope(), + legalEntityTypeAdded.ToEnvelope(), + couplingCancelled.ToEnvelope(), + } + ); + + await _fixture.Elastic.ReadClient.Indices.RefreshAsync(Indices.Index()); + var organisation = _fixture.Elastic.ReadClient.Get(organisationCreated.OrganisationId); + + organisation.Source.LegalEntityType.Should().BeNull(); + } + [Fact] public async void OrganisationTerminated() { @@ -310,7 +374,6 @@ await _eventProcessor.Handle( organisation.Source.Validity.Start.Should().Be(organisationCreated.ValidFrom); organisation.Source.KboNumber.Should().Be(coupledWithKbo.KboNumber); organisation.Source.Validity.End.Should().Be(organisationValidity); - organisation.Source.LegalEntityType.Should().BeNull(); } [Fact]