Skip to content

Bug/ulitp 5394 Refactor common land mapping and address selection#238

Merged
grahammcvea-defra merged 10 commits into
devfrom
bug/ulitp-5394
Jun 16, 2026
Merged

Bug/ulitp 5394 Refactor common land mapping and address selection#238
grahammcvea-defra merged 10 commits into
devfrom
bug/ulitp-5394

Conversation

@grahammcvea-defra

Copy link
Copy Markdown
Contributor

Refactor common land mapping and address selection

SamCommonLandMapper.ToSilver is now async and supports country resolution for enriched address data. Address mapping uses resolved country identifiers and codes. SamHoldingMapper gains SelectAddressSource to prioritize common land addresses when mapping to gold. Site creation and update logic now use the prioritized address source. Unit tests updated and expanded for new async and address selection logic.

Bartonkeys added 10 commits June 9, 2026 07:42
Refactored representative holding selection to prioritize SAM Holdings over Common Land using a new SelectRepresentativeHolding method. Updated EnrichWithCommonLandDataAsync to merge LocalAuthorityName and deduplicate AssociatedMainHoldings across all silver holdings. Adjusted FindAndUpdateMainSiteIfExists to use CPH string. Updated SamHoldingMapper to use new selection logic. Added unit tests for merging and selection behavior. Enhanced FakeDataBridgeClient test data for completeness.
Refactored site data assignment into ApplySiteData to reduce duplication in SamHoldingMapper. Updated site creation and update methods to use this helper. Added a unit test to ensure active Common Land holdings are correctly selected as representative.
Removed the unused SiteDocument? capturedFilter variable from SamHoldingImportGoldMappingStepTests to clean up the test code. No functional changes were made.
Applied .Distinct() to ProductionUsageCodeList to remove duplicate production usage codes after trimming, ensuring only unique codes are included in the mapped result.
Refactored SAM holding mapping by introducing ResolveLocationPartsAsync to handle address and communication extraction as a tuple. Replaced duplicate logic in creation and update flows, and cached IsPermanentLandHolding() result for clarity and efficiency.
Refactored SelectRepresentativeHolding from SamHoldingImportGoldMappingStep to SamHoldingMapper as an internal method. Updated references to use the new location. No changes to method logic.
SamCommonLandMapper.ToSilver is now async and supports country resolution for enriched address data. Address mapping uses resolved country identifiers and codes. SamHoldingMapper gains SelectAddressSource to prioritize common land addresses when mapping to gold. Site creation and update logic now use the prioritized address source. Unit tests updated and expanded for new async and address selection logic.
@github-actions

Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Health
KeeperData.Api 97% 82%
KeeperData.Api.Worker 97% 96%
KeeperData.Application 98% 86%
KeeperData.Core 88% 78%
KeeperData.Infrastructure 93% 85%
KeeperData.Tests.Common 95% 82%
Summary 94% (16150 / 17228) 83% (2552 / 3068)

@sonarqubecloud

Copy link
Copy Markdown

@grahammcvea-defra grahammcvea-defra merged commit 76cdd94 into dev Jun 16, 2026
13 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants