Commit 9b95df7
Feature/ultip 5215 (#232)
* 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.
* Add support for SamCommonLand data handling
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.
* Replace null with string.Empty for MAIN_CPH in tests
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`.
* Clean up redundant braces and improve test coverage
* Ensure culture-invariant date parsing and formatting
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.
* Add tests for Sam Common Lands functionality
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.
* Add unit tests for PII anonymization in SamCommonLand
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.
* Refine filters and update object references
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.
* Refactor tests and add SamCommonLandDailyScan tests
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.
* Replace null with empty string in COMMON_CPH property
* Add tests for anonymization and edge case handling
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.
---------
Co-authored-by: Graham McVea <graham.mcvea@bartonkeys.com>1 parent c4fa165 commit 9b95df7
37 files changed
Lines changed: 2698 additions & 33 deletions
File tree
- src
- KeeperData.Api
- KeeperData.Application/Orchestration
- ChangeScanning/Sam/Daily
- Steps
- Imports/Sam
- Holdings
- Steps
- Mappings
- KeeperData.Core
- ApiClients/DataBridgeApi
- Contracts
- DTOs
- Documents
- Silver
- KeeperData.Infrastructure
- Anonymization
- ApiClients
- Decorators
- Fakes
- Data/Seed
- tests
- KeeperData.Api.Tests.Component/Orchestration/Imports/Sam
- Holdings
- KeeperData.Api.Tests.Integration/Orchestration/Imports/Sam
- KeeperData.Application.Tests.Unit/Orchestration
- ChangeScanning/Sam
- Imports/Sam/Mappings
- KeeperData.Core.Tests.Unit/ApiClients/DataBridgeApi/Contracts
- KeeperData.Infrastructure.Tests.Unit
- Anonymization
- ApiClients
- KeeperData.Tests.Common
- Factories/UseCases
- TestData/Sam
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
Lines changed: 63 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| 35 | + | |
| 36 | + | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| |||
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| 72 | + | |
| 73 | + | |
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
| |||
79 | 82 | | |
80 | 83 | | |
81 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
82 | 112 | | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
| |||
Lines changed: 125 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
Lines changed: 61 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
0 commit comments