feat(core): add guardrails to update template endpoint#51
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds domain-level validation guardrails around entity-template creation/update to enforce uniqueness and referential integrity, and introduces API-layer exception mappings and test coverage for the new rules.
Changes:
- Enforce case-insensitive uniqueness for property/relation names and validate relation target templates exist.
- Block property type changes on template updates and map new domain exceptions to HTTP 400.
- Add/adjust integration + unit tests and supporting test fixtures/config.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/resources/integration_test/json/entity-template/v1/putTemplate_400_unsafe_type_conversion.json | Adds PUT payload fixture to exercise blocked property type changes |
| src/test/resources/integration_test/json/entity-template/v1/putEntityTemplate_400_identifier_in_body.json | Adds PUT payload fixture containing forbidden/unknown identifier field |
| src/test/resources/integration_test/json/entity-template/v1/postEntityTemplate_400_target_template_not_found.json | Adds POST payload fixture for invalid relation target template |
| src/test/resources/integration_test/json/entity-template/v1/postEntityTemplate_400_duplicate_relation_names.json | Adds POST payload fixture for duplicate relation names (case-insensitive) |
| src/test/resources/integration_test/json/entity-template/v1/postEntityTemplate_400_duplicate_property_names.json | Adds POST payload fixture for duplicate property names (case-insensitive) |
| src/test/resources/application-test.yml | Tightens Jackson test deserialization settings (fail on unknown properties) |
| src/test/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/EntityTemplateControllerTest.java | Adds integration tests for new 400 cases; refactors some endpoint path usages |
| src/test/java/com/decathlon/idp_core/domain/service/entity_template/RelationDefinitionValidationServiceTest.java | Introduces unit tests for relation name uniqueness validation |
| src/test/java/com/decathlon/idp_core/domain/service/entity_template/PropertyDefinitionValidationServiceTest.java | Extends unit tests for property uniqueness and blocked type changes |
| src/main/java/com/decathlon/idp_core/infrastructure/adapters/persistence/repository/JpaEntityRepository.java | Adds existsByTemplateIdentifier query method |
| src/main/java/com/decathlon/idp_core/infrastructure/adapters/persistence/PostgresEntityAdapter.java | Implements existsByTemplateIdentifier in persistence adapter |
| src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/handler/ApiExceptionHandler.java | Maps new domain exceptions to HTTP 400 responses |
| src/main/java/com/decathlon/idp_core/domain/service/entity_template/RelationDefinitionValidationService.java | Adds domain service validations for relation uniqueness + target existence |
| src/main/java/com/decathlon/idp_core/domain/service/entity_template/PropertyDefinitionValidationService.java | Adds property name uniqueness + property type immutability validation |
| src/main/java/com/decathlon/idp_core/domain/service/entity_template/EntityTemplateValidationService.java | Orchestrates new property/relation validations on create/update |
| src/main/java/com/decathlon/idp_core/domain/service/entity_template/EntityTemplateService.java | Updates update-flow to pass existing template into validation |
| src/main/java/com/decathlon/idp_core/domain/port/EntityRepositoryPort.java | Extends entity persistence port with existsByTemplateIdentifier |
| src/main/java/com/decathlon/idp_core/domain/exception/entity_template/UnsafeTypeConversionException.java | Introduces domain exception for blocked property type changes |
| src/main/java/com/decathlon/idp_core/domain/exception/entity_template/TargetTemplateNotFoundException.java | Introduces domain exception for missing relation targets |
| src/main/java/com/decathlon/idp_core/domain/exception/entity_template/RelationNameAlreadyExistsException.java | Introduces domain exception for duplicate relation names |
| src/main/java/com/decathlon/idp_core/domain/exception/entity_template/PropertyNameAlreadyExistsException.java | Introduces domain exception for duplicate property names |
| src/main/java/com/decathlon/idp_core/domain/constant/ValidationMessages.java | Adds new validation message constants for the new rule violations |
brandPittCode
requested changes
May 12, 2026
brandPittCode
requested changes
May 12, 2026
Collaborator
brandPittCode
left a comment
There was a problem hiding this comment.
add flywway sctipt for indexes
-- Optimize property deletion by template identifier and property name
CREATE INDEX idx_entity_template_identifier
ON entity (template_identifier);
CREATE INDEX idx_property_name
ON property (name);
|
brandPittCode
approved these changes
May 12, 2026
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.



PR Description
What this PR Provides
Enforce the following business rules:
Review
The reviewer must double-check these points:
How to test
Happy Path
Error Path
Breaking changes
N/A