Conversation
There was a problem hiding this comment.
Pull request overview
Adds domain-level validation to ensure EntityTemplate property rules are compatible with their declared property types during create/update, and tightens JSON deserialization to reject unknown request fields.
Changes:
- Introduce
PropertyRulesService+PropertyRulesConflictExceptionand enforce validation fromEntityTemplateServiceon create/update. - Map
PropertyRulesConflictExceptionto HTTP 400 and enable Jacksonfail-on-unknown-properties. - Refactor API DTO out / mapper packages from
entitytemplate→entity_templateand update tests/fixtures accordingly.
Reviewed changes
Copilot reviewed 19 out of 23 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/com/decathlon/idp_core/domain/service/entity_template/PropertyRulesService.java | New domain validation logic for rule/type compatibility (STRING/NUMBER/BOOLEAN). |
| src/main/java/com/decathlon/idp_core/domain/service/entity_template/EntityTemplateService.java | Calls property-rules validation during template create/update; renames update method. |
| src/main/java/com/decathlon/idp_core/domain/exception/PropertyRulesConflictException.java | New domain exception used to surface rule/type conflicts. |
| src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/handler/ApiExceptionHandler.java | Maps PropertyRulesConflictException to HTTP 400 responses. |
| src/main/resources/application.yml | Enables global Jackson fail-on-unknown-properties. |
| src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/EntityTemplateController.java | Updates service method call and DTO out / mapper package imports. |
| src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/mapper/entity_template/EntityTemplateMapper.java | Moves mapper package and updates DTO out package imports. |
| src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/mapper/entity/EntityDtoOutMapper.java | Updates import to moved EntityTemplateService. |
| src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/configuration/SwaggerConfiguration.java | Updates import to moved EntityTemplateDtoOut package. |
| src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/dto/out/entity_template/EntityTemplateDtoOut.java | Package rename to entity_template. |
| src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/dto/out/entity_template/PropertyDefinitionDtoOut.java | Package rename to entity_template. |
| src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/dto/out/entity_template/PropertyRulesDtoOut.java | Package rename to entity_template. |
| src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/dto/out/entity_template/RelationDefinitionDtoOut.java | Package rename to entity_template. |
| src/main/java/com/decathlon/idp_core/domain/constant/ValidationMessages.java | Adds property-rules validation message templates/helpers; adjusts relation message text. |
| src/main/java/com/decathlon/idp_core/domain/exception/EntityTemplateAlreadyExistsException.java | Updates import to moved EntityTemplateService. |
| src/main/java/com/decathlon/idp_core/domain/exception/EntityTemplateNameAlreadyExistsException.java | Updates import to moved EntityTemplateService. |
| src/test/java/com/decathlon/idp_core/domain/service/entity_template/PropertyRulesServiceTest.java | New unit tests covering rule/type compatibility scenarios. |
| src/test/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/EntityTemplateControllerTest.java | Adds integration test for invalid STRING rules → 400. |
| src/test/java/com/decathlon/idp_core/infrastructure/adapters/api/mapper/EntityTemplateMapperTest.java | Updates imports for renamed DTO out / mapper packages. |
| src/test/resources/integration_test/json/entity-template/v1/postEntityTemplate_400_invalid_rules.json | New fixture for invalid rule/type combinations. |
| src/test/resources/integration_test/json/entity-template/v1/postEntityTemplate_201.json | Adjusts fixture rules to avoid disallowed numeric rules for STRING. |
| src/test/resources/integration_test/json/entity-template/v1/postEntityTemplateWithoutRelationsDefinitions_201.json | Adjusts fixture rules to avoid disallowed numeric rules for STRING. |
| src/test/resources/integration_test/json/entity-template/v1/putEntityTemplate_200.json | Adjusts fixture rules to avoid disallowed numeric rules for STRING. |
brandPittCode
left a comment
There was a problem hiding this comment.
Drop the rules.id field from the PropertyRulesDtoOut.
We should make our enum caseInsensitive for the inputDto. For example for type in the propertyDefinition object.
We can explore the spring configuration way:
jackson:
deserialization:
read_enum_values_using_index: false
accept_case_insensitive_enums: true
or the annotation in class option.
|
Coucou |
https://github.com/Decathlon/internal-developer-platform into feat/add-property-rules-validation-of-entity-template
|



PR Description
What this PR Provides
Review
The reviewer must double-check these points:
How to test
POST /entity-templates
(a+)+$(400 Bad Request)PUT /entity-templates
Breaking changes
N/A