Skip to content

Commit

Permalink
feat: or-2535 clear legal entity type when clearing kbo state
Browse files Browse the repository at this point in the history
  • Loading branch information
koenmetsu committed Sep 25, 2024
1 parent cbe4f79 commit 0487762
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/OrganisationRegistry/Organisation/State/KboState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public void Clear()
KboRegisteredOffice = null;
KboFormalNameLabel = null;
KboLegalFormOrganisationClassification = null;
LegalEntityTypeCode = null;
}

public KboState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,70 @@ await _eventProcessor.Handle<OrganisationDocument>(
});
}

[Fact]
public async void LegalEntityTypeAdded()
{
var scenario = new OrganisationScenario(Guid.NewGuid());
var forcedKboTermination = false;
scenario.AddCustomization(new ParameterNameArg<bool>("forcedKboTermination", forcedKboTermination));

var organisationValidity = scenario.Create<DateTime?>() ?? scenario.Create<DateTime>();

var initialiseProjection = scenario.Create<InitialiseProjection>();
var organisationCreated = scenario.Create<OrganisationCreated>();
var coupledWithKbo = scenario.Create<OrganisationCoupledWithKbo>();
var legalEntityTypeAdded = scenario.Create<KboLegalEntityTypeAdded>();

await _eventProcessor.Handle<OrganisationDocument>(
new List<IEnvelope>
{
initialiseProjection.ToEnvelope(),
organisationCreated.ToEnvelope(),
coupledWithKbo.ToEnvelope(),
legalEntityTypeAdded.ToEnvelope(),
}
);

await _fixture.Elastic.ReadClient.Indices.RefreshAsync(Indices.Index<OrganisationDocument>());
var organisation = _fixture.Elastic.ReadClient.Get<OrganisationDocument>(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<bool>("forcedKboTermination", forcedKboTermination));

var organisationValidity = scenario.Create<DateTime?>() ?? scenario.Create<DateTime>();

var initialiseProjection = scenario.Create<InitialiseProjection>();
var organisationCreated = scenario.Create<OrganisationCreated>();
var coupledWithKbo = scenario.Create<OrganisationCoupledWithKbo>();
var legalEntityTypeAdded = scenario.Create<KboLegalEntityTypeAdded>();
var couplingCancelled = scenario.Create<OrganisationCouplingWithKboCancelled>();

await _eventProcessor.Handle<OrganisationDocument>(
new List<IEnvelope>
{
initialiseProjection.ToEnvelope(),
organisationCreated.ToEnvelope(),
coupledWithKbo.ToEnvelope(),
legalEntityTypeAdded.ToEnvelope(),
couplingCancelled.ToEnvelope(),
}
);

await _fixture.Elastic.ReadClient.Indices.RefreshAsync(Indices.Index<OrganisationDocument>());
var organisation = _fixture.Elastic.ReadClient.Get<OrganisationDocument>(organisationCreated.OrganisationId);

organisation.Source.LegalEntityType.Should().BeNull();
}

[Fact]
public async void OrganisationTerminated()
{
Expand Down Expand Up @@ -310,7 +374,6 @@ await _eventProcessor.Handle<OrganisationDocument>(
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]
Expand Down

0 comments on commit 0487762

Please sign in to comment.