Skip to content

Feature/ultip 5215#232

Merged
grahammcvea-defra merged 11 commits into
devfrom
feature/ultip-5215
May 19, 2026
Merged

Feature/ultip 5215#232
grahammcvea-defra merged 11 commits into
devfrom
feature/ultip-5215

Conversation

@grahammcvea-defra
Copy link
Copy Markdown
Contributor

@grahammcvea-defra grahammcvea-defra commented May 18, 2026

Add support for "Common Lands" processing
Introduced functionality to handle "Common Lands" data, including:

  • Added SamCommonLandsEnabled flag in appsettings.json.
  • Updated SamDailyScanContext and SamHoldingImportContext to include "Common Lands".
  • Enhanced SamHoldingImportAggregationStep to fetch and process "Common Lands".
  • Added mapping logic for "Common Lands" in Silver and Gold models.
  • Introduced new API routes and queries for "Common Lands".
  • Extended IDataBridgeClient to support "Common Lands" API calls.
  • Updated SiteDto, SamHoldingDocument, and SiteDocument to include "Common Lands" fields.
  • Added anonymization support for "Common Lands" in PiiAnonymizerHelper.
  • Enhanced FakeDataBridgeClient to simulate "Common Lands" data.
  • Added SamCommonLandDailyScanStep for daily scanning of "Common Lands".
  • Introduced SamCommonLandMapper for mapping "Common Lands" data.
  • Added new classes for "Common Lands" relationships and identifiers.

These changes enable the application to retrieve, process, and map "Common Lands" data while ensuring proper anonymization and testing support.

Bartonkeys added 11 commits May 16, 2026 20:44
Introduced functionality to handle "Common Lands" data, including:
- Added `SamCommonLandsEnabled` flag in `appsettings.json`.
- Updated `SamDailyScanContext` and `SamHoldingImportContext` to include "Common Lands".
- Enhanced `SamHoldingImportAggregationStep` to fetch and process "Common Lands".
- Added mapping logic for "Common Lands" in Silver and Gold models.
- Introduced new API routes and queries for "Common Lands".
- Extended `IDataBridgeClient` to support "Common Lands" API calls.
- Updated `SiteDto`, `SamHoldingDocument`, and `SiteDocument` to include "Common Lands" fields.
- Added anonymization support for "Common Lands" in `PiiAnonymizerHelper`.
- Enhanced `FakeDataBridgeClient` to simulate "Common Lands" data.
- Added `SamCommonLandDailyScanStep` for daily scanning of "Common Lands".
- Introduced `SamCommonLandMapper` for mapping "Common Lands" data.
- Added new classes for "Common Lands" relationships and identifiers.

These changes enable the application to retrieve, process, and map "Common Lands" data while ensuring proper anonymization and testing support.
Introduced nullability support in `ToAssociatedCommonLands` to handle null or empty lists. Added `PermanentLandHoldingIdentifier` to `SiteDocumentExtensions` for enhanced data mapping.

Updated `SamHoldingImportOrchestratorTests` and `SamBulkImportWithAccurateRawDataTests` to include `commonLands` in test setups, mocking, and verification. Modified `GetAllQueryUris` to support `commonLandsUri`. Added mock setup for `GetByCodeAsync` to return "Common Land" site type.

Enhanced `SamTestScenarios` with `RawCommonLandsByCommonCph` for test data. Added `SamCommonLandMapperTests` to validate mapping logic and `SamCommonLandTests` to ensure proper behavior of `SamCommonLand`.

These changes ensure robust handling, mapping, and testing of `SamCommonLand` data.
Updated test cases in `SamCommonLandMapperTests.cs` and
`SamCommonLandTests.cs` to replace `null` values for the
`MAIN_CPH` property with `string.Empty`. This aligns with
the updated behavior where `MAIN_CPH` no longer supports
`null` values.

Removed a test case in `SamCommonLandTests.cs` that
validated `null` `MAIN_CPH`, as it is no longer relevant.
Other test cases remain to validate empty and whitespace
values for `MAIN_CPH`.
Updated the `NormaliseDate` method to use `CultureInfo.InvariantCulture` for both `DateTime.TryParse` and `ToString` to ensure consistent, culture-independent behavior. Added `System.Globalization` namespace to support these changes.
Enhanced `DataBridgeClientTests` with new unit tests to validate
the behavior of `DataBridgeClient` methods for fetching "Sam
Common Lands" data. Added tests for both enabled and disabled
feature flag scenarios, covering paged responses and filtering
by `COMMON_CPH`.

Introduced helper methods in `MockSamData` to generate mock
responses for "Sam Common Lands" data, ensuring realistic and
consistent test data. These changes improve test coverage and
verify functionality under various configurations.
Added a new test class `PiiAnonymizerHelperTests` to validate
the `PiiAnonymizerHelper` class. Introduced tests to ensure
PII fields in `SamCommonLand` are anonymized correctly,
including `ADDRESS_LINE_1`, `POSTCODE`, `PREMISES_NAME`,
`EASTING`, and `NORTHING`. Verified deterministic behavior
based on `COMMON_CPH` and ensured non-PII fields remain
unchanged.

Added tests for edge cases such as null or empty fields,
placeholder values, and empty `DataBridgeResponse` objects.
Included a comprehensive test to validate anonymization of
all PII fields in a single call.
Updated `VerifySilverDataTypesAsync` in both `SamImportHoldingAnonMessageTests` and `SamImportHoldingMessageTests` to add a filter excluding `SiteTypeCode` equal to "CL".

Replaced `_localStackFixture` with `localStackFixture` in `SamImportHoldingMessageTests` for `CreateMessage` and `SendMessageAsync` calls to ensure consistent object usage.

Updated `DisposeAsync` in `SamImportHoldingMessageTests` to use `mongoDbFixture` instead of `_mongoDbFixture` for purging data tables.

These changes improve query precision, naming consistency, and maintainability.
Refactored `SamImportHoldingAnonMessageTests` and
`SamImportHoldingMessageTests` to use private readonly fields for
dependencies, improving encapsulation and maintainability. Updated
method calls to align with the new structure.

Added `SamCommonLandDailyScanStepTests` to test the functionality of
`SamCommonLandDailyScanStep`. This includes mocking dependencies,
configuring in-memory feature flags, and writing unit tests for
various scenarios such as handling feature flags, API responses,
pagination, and error handling.

Introduced `FluentAssertions` for expressive assertions and improved
test readability. Enhanced code consistency and maintainability
through better naming conventions and encapsulation.
Added multiple test methods to validate anonymization logic:
- `GetSamCommonLandsAsync_Generic_ShouldAnonymizeAddressAndLocationFields`: Ensures PII fields are anonymized while non-PII fields remain unchanged.
- `GetSamCommonLandsByCommonCphAsync_ShouldAnonymizeAllCommonLands`: Verifies anonymization of all common lands for a given `COMMON_CPH`.
- `GetSamCommonLandsByCommonCphAsync_ShouldHandleNullFields`: Confirms proper handling of null values in PII fields.
- `GetSamCommonLandsByCommonCphAsync_ShouldNotAnonymizePlaceholderPremisesName`: Ensures placeholder values like `"-"` are not anonymized.
- `GetSamCommonLandsAsync_ShouldProduceDeterministicResults`: Validates deterministic anonymization for the same `COMMON_CPH`.
- `GetSamCommonLandsAsync_ShouldPreserveNonPiiFields`: Confirms non-PII fields are preserved while PII fields are anonymized.
- `GetSamCommonLandsAsync_ShouldReturnNull_WhenInnerReturnsNull`: Ensures `null` is returned when the inner client returns `null`.
- `GetSamCommonLandsByCommonCphAsync_ShouldHandleEmptyList`: Verifies proper handling of empty list responses.
@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% 87%
KeeperData.Core 88% 78%
KeeperData.Infrastructure 93% 84%
KeeperData.Tests.Common 96% 87%
Summary 94% (15781 / 16851) 84% (2468 / 2954)

@sonarqubecloud
Copy link
Copy Markdown

@grahammcvea-defra grahammcvea-defra merged commit 9b95df7 into dev May 19, 2026
8 checks passed
@grahammcvea-defra grahammcvea-defra deleted the feature/ultip-5215 branch May 19, 2026 14:43
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