NRC migration to mapster - #204
Open
ragaumon wants to merge 15 commits into
Open
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Port the request-to-domain mapping profile to a Mapster IRegister, including the first AfterMapping use (Kanaal set from source Naam) and the dictionary->list Filters conversion. AutoMapper profile stays in place; nothing wires the register into production yet. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…alen collection Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… test Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
AddZgwMapster's enable parameter defaults to false, so the one-argument call registered nothing and GetRequiredService<IMapper>() threw. Also drop a comment reference to an AC wiring test that does not exist. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… dependency The per-register mapping tests build an isolated TypeAdapterConfig and cannot see the PATCH merge path, so they stayed green while PATCH threw at runtime. Two facts for two failure modes: the merge fact proves the Mapster register still serves Abonnement -> AbonnementRequestDto, and the reflection fact proves the controller depends on the Mapster-backed merger. The latter fails at this commit, which is the defect it exists to catch. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The AutoMapper-backed IRequestMerger needs an Abonnement -> AbonnementRequestDto map, which no longer exists now that the profiles are gone, so every PATCH on an abonnement threw AutoMapperMappingException. IZgwRequestMerger resolves the same pair from the Mapster register. IRequestMerger stays in the constructor because ZGWControllerBase still requires it. The other two controllers call no merger and are unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…n values No AutoMapper profile exists any more, so *ProfileTests was misleading; other migrated services already use *RegisterTests. The second Kenmerken assertion was a verbatim duplicate of the key comparison and was dropped during the migration. Restore it as the value comparison it was meant to be. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the NRC (Notificaties) service’s runtime mapping from AutoMapper profiles to Mapster registers by enabling the Mapster seam in AddZGWApi, updating controllers to use the DI-provided Mapster mapper, and adding/adjusting unit tests to validate wiring and PATCH-merge behavior.
Changes:
- Enable Mapster for NRC via
ApiServiceSettings.EnableMapster = trueand introduce MapsterIRegistermapping configurations. - Switch NRC controllers to map request/response models using
MapsterMapper.IMapperand route PATCH merging throughIZgwRequestMerger. - Update/add unit tests to cover register-level mapping behavior, Mapster DI wiring, and the PATCH merge contract path.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/OneGround.ZGW.Notificaties.Web/Startup.cs | Enables Mapster seam for NRC via service settings. |
| src/OneGround.ZGW.Notificaties.Web/MappingProfiles/v1/RequestToDomainRegister.cs | Adds Mapster register for request DTO → domain mappings. |
| src/OneGround.ZGW.Notificaties.Web/MappingProfiles/v1/RequestToDomainProfile.cs | Removes AutoMapper profile replaced by Mapster register. |
| src/OneGround.ZGW.Notificaties.Web/MappingProfiles/v1/DomainToResponseRegister.cs | Adds Mapster register for domain → response DTO (and PATCH merge support) mappings. |
| src/OneGround.ZGW.Notificaties.Web/MappingProfiles/v1/DomainToResponseProfile.cs | Removes AutoMapper profile replaced by Mapster register. |
| src/OneGround.ZGW.Notificaties.Web/Controllers/v1/NotificatiesController.cs | Uses Mapster mapper for request DTO → domain mapping. |
| src/OneGround.ZGW.Notificaties.Web/Controllers/v1/KanaalController.cs | Uses Mapster mapper for domain ↔ DTO mappings. |
| src/OneGround.ZGW.Notificaties.Web/Controllers/v1/AbonnementController.cs | Uses Mapster mapper for mappings and IZgwRequestMerger for PATCH merge flow. |
| src/Tests/OneGround.ZGW.Notificaties.WebApi.UnitTests/MappingTests/RequestToDomainRegisterTests.cs | Updates mapping tests to Mapster and strengthens nested mapping assertions. |
| src/Tests/OneGround.ZGW.Notificaties.WebApi.UnitTests/MappingTests/DomainToResponseRegisterTests.cs | Updates mapping tests to Mapster and wires DI to support URL resolution via MapContext. |
| src/Tests/OneGround.ZGW.Notificaties.WebApi.UnitTests/MappingTests/NrcMapsterWiringTests.cs | Adds test ensuring AddZgwMapster discovers NRC registers and resolves URLs via DI. |
| src/Tests/OneGround.ZGW.Notificaties.WebApi.UnitTests/MappingTests/NrcMapperContractTests.cs | Adds contract tests guarding the Mapster-backed mapper/merger wiring for PATCH merge. |
Suppressed comments (1)
src/Tests/OneGround.ZGW.Notificaties.WebApi.UnitTests/MappingTests/RequestToDomainRegisterTests.cs:93
- The Kenmerken assertions compare dictionary enumeration order (
Select(k => k.Key/Value)), which is not guaranteed and can make the test flaky if source/destination dictionaries enumerate differently. Prefer an order-independent check that verifies every expected key/value exists in the mapped result.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
NRC migration from automapper to mapster
Type of Change
Testing
Checklist