Skip to content

#27 validate entities before persisting v2#38

Open
smirnova-yulia wants to merge 34 commits intomainfrom
task/#27-validate-entities-before-persisting-v2
Open

#27 validate entities before persisting v2#38
smirnova-yulia wants to merge 34 commits intomainfrom
task/#27-validate-entities-before-persisting-v2

Conversation

@smirnova-yulia
Copy link
Copy Markdown

Task description:

  • Introduce constraints for the 'productId,' 'name,' and 'weight' fields
  • Update 'ProductServiceImpl' to validate Product entity during save
  • Add test cases to verify validation logic in 'ProductValidationTests'
  • Enhance API tests to cover invalid Product save scenarios

Additional

  • task description: nothing was changed
  • code
    Test Method Naming: testReviewEntityValidationNegative -> testProductEntityValidationNegative
    Test Code Organization: added parameterized tests to reduce code duplication
    Error Message Consistency: in ProductServiceImpl to provide a complete feedback
  • ProductServiceApiTests failes with "ApplicationContext failure threshold (1) exceeded: skipping repeated attempt to load context for", most probably messageProcessor is not initiated correctly. Not related to this issue, but to Use event-drive approach to communicate between microservices #19

dtsaryov and others added 30 commits July 22, 2025 12:44
…er is a non-negative integer

Declare a RestControllerAdvice class to handle API exceptions and return proper responses.
Write tests to check the validation
- Create ServiceUtil for service discovery
- Implement ProductCompositeIntegration and update ProductCompositeService with aggregated responses
- Update tests to check updated behavior
- Configure JPA with MySQL for persistence
- Add `ReviewEntity` and `ReviewRepository` for database operations
- Declare and implement CRUD operations for the 'ReviewService' API endpoint
- Configure MySQL in 'docker-compose.yml'
- Update application properties for local and Docker profiles
- Add integration tests with Testcontainers for API and persistence layer
- Add `spring-boot-starter-validation` dependency to enable bean validation
- Annotate fields in `ReviewEntity` with validation constraints
- Introduce `ReviewValidationTests` to validate `ReviewEntity` constraints
- Add Flyway dependencies to manage DB schema migrations
- Add 'V1__' migration script to create 'reviews' table with constraints
- Add `ReviewDbMigrationTest` to validate Flyway migrations
- Extend `ReviewEntity` with a non-null `date` field
- Update database schema with Flyway migration 'V2__'
- Modify API contract and record `Review` to include `date`
- Adjust validation rules and tests for new field
- Add `LocalDateConverter` for proper `LocalDate` serialization/deserialization
…ayer

- Configure MongoDB Docker container
- Update `docker-compose.yml` to include a MongoDB service with health checks
- Add CRUD operations for recommendation
- Write integration tests with Testcontainers
- Add 'spring-boot-starter-validation' dependency to enable bean validation
- Introduce 'MongoDbValidationConfig' to integrate validation with MongoDB
- Update 'RecommendationEntity' with validation annotations for fields
- Modify tests to include validation scenarios
- Add 'RecommendationValidationTests' to validate entity constraints
… layer

- Configure PostgreSQL in 'docker-compose.yml' and application configurations
- Add 'ProductEntity' and 'ProductRepository' for database operations
- Implement CRUD operations in 'ProductServiceImpl'
- Add API endpoints for product CRUD operations
- Write test cases using Testcontainers for persistence and API integration
…ize schema

- Add Liquibase dependency and initial changelog with 'products' table creation
- Update application configuration to use Liquibase for schema management
- Replace SQL-based initialization with Liquibase
- Add 'ProductMigrationTest' to verify Liquibase migrations with Testcontainers
…delete composite products

- Implement CRUD operations for composite products in `ProductCompositeService`
- Add new endpoints with OpenAPI documentation: POST, DELETE for composite products
- Enhance service layer with integration methods and logging
- Refactor product, recommendations, and reviews retrieval logic
- Update tests with comprehensive cases for new operations
- Remove `MappingUtils` and its usages
- Introduce `ReviewMapper` interface using MapStruct for mapping logic
- Add MapStruct dependency and configuration in `build.gradle`
- Update `ReviewServiceImpl` to use `ReviewMapper` for mapping operations
- Add `ReviewMapperTest` to verify mapping functionality
- Remove `MappingUtils` and its usages
- Introduce `RecommendationMapper` interface using MapStruct for mapping logic
- Add MapStruct dependency and configuration in `build.gradle`
- Update `RecommendationServiceImpl` to use `RecommendationMapper` for mapping operations
- Add `RecommendationMapperTest` to verify mapping functionality
- Remove `MapperUtils` and its usages
- Introduce `ProductMapper` interface using MapStruct for mapping logic
- Add MapStruct dependency and configuration in `build.gradle`
- Update `ProductServiceImpl` to use `ProductMapper` for mapping operations
- Add `ProductMapperTest` to verify mapping functionality
- Replace synchronous RestTemplate with WebClient across microservices
- Refactor repositories to use reactive CRUD operations
- Update service implementations and test cases accordingly
- Transition from traditional MVC to WebFlux stack for all APIs and testing frameworks
- Remove unused synchronous methods, libraries, and dependencies
- Add messaging support across microservices using Spring Cloud Stream with RabbitMQ
- Replace HTTP-based communication with event-driven messaging for create and delete operations
- Add event models and processing logic in `api` module
- Update `ProductCompositeIntegration` to publish and consume events
- Refactor tests and add message-driven test cases for all event-processing scenarios
- Integrate Health Checks for underlying services using Actuator
…tion

- Add Eureka Server module with Spring Cloud Netflix Eureka
- Integrate Eureka client in all microservices for service discovery
- Replace hardcoded service URLs with dynamic resolution through Eureka
- Update WebClient configuration to support load balancing with Eureka
- Refactor configuration files to include Eureka settings
- Modify Docker Compose to include Eureka Server
- Enhance logging and error handling in `ProductCompositeIntegration` for service calls
- Add tests for Eureka Server and client integration
- Introduce 'NotFoundException'
- Update 'ProductServiceImpl' to throw 'NotFoundException' when no product is found
- Modify 'ProductCompositeIntegration' logic to handle `NotFoundException` from downstream services
- Add 'GlobalControllerExceptionHandler' to process `NotFoundException` responses with proper HTTP status
…management-20250726184713

Add workflow: pr-label-management.yml
- Adjust the DTO and the entity to handle the new field
- Add validation for the new field and update tests
- Generate Flyway update scripts
- Update test cases across all services to include and validate the new field
dtsaryov added 3 commits July 28, 2025 15:06
- Update API contracts to define the new '/product-composite/reviews/{productId}' endpoint
- Update OpenAPI documentation to describe the new endpoint
- Include test cases to validate reviews retrieval logic
… associated recommendations and reviews

- Update API contracts to define the new '/product-composite' endpoint
- Implement service method in 'ProductCompositeService' to aggregate product details
- Update 'ProductCompositeIntegration' to call downstream 'ProductService' for all products
- Extend 'ProductService' with a new method and corresponding implementation in 'ProductServiceImpl'
- Add test cases to verify 'getAllProducts' functionality end-to-end
- Introduce constraints for the 'productId,' 'name,' and 'weight' fields
- Update 'ProductServiceImpl' to validate Product entity during save
- Add test cases to verify validation logic in 'ProductValidationTests'
- Enhance API tests to cover invalid Product save scenarios
@DmitriyChernyakSetronica DmitriyChernyakSetronica force-pushed the task/#27-validate-entities-before-persisting-v2 branch from 8beb929 to de96af1 Compare October 30, 2025 08:42
Task description:

Introduce constraints for the 'productId,' 'name,' and 'weight' fields
Update 'ProductServiceImpl' to validate Product entity during save
Add test cases to verify validation logic in 'ProductValidationTests'
Enhance API tests to cover invalid Product save scenarios

FAIL_TO_PASS: shop.microservices.core.product.ProductServiceApiTests, shop.microservices.core.product.ProductValidationTests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants