feat: Rating inter service communication#6
Merged
janosevicsm merged 5 commits intodevelopfrom Feb 22, 2026
Merged
Conversation
Introduce role-based authorization and request-scoped user context. Adds @RequireRole annotation and RoleAuthorizationInterceptor to enforce roles from the X-User-Role header (throws Unauthorized/Forbidden as needed). Adds UserContext record and UserContextResolver to inject a validated UserContext (from X-User-Id and X-User-Role) into controller methods. Registers the resolver and interceptor in WebConfig. Protects RatingController endpoints with @RequireRole("GUEST"). Adds UnauthorizedException and ForbiddenException and corresponding handlers in GlobalExceptionHandler to return 401/403 responses.
Introduce gRPC integration with the user service and refactor rating service to use it. Adds protobuf/grpc plugin and dependencies to build.gradle.kts and a user_internal.proto definition, plus UserGrpcClient and UserSummaryResult to call the user service. RatingService was refactored into a @service class (old RatingServiceImpl removed) to fetch user summaries, populate guest metadata, and perform CRUD with soft-delete; controller updated to accept UserContext and pass it through; CreateRatingRequest DTO trimmed of guest fields and mapper updated to ignore guest-related entity fields. Also add gRPC client configuration to application.properties and environment variables for USER_GRPC_HOST/PORT.
Add support for rating target types and reservation-based eligibility checks. Introduces RatingTargetType enum, adds targetType to CreateRatingRequest and Rating entity, and maps it in RatingMapper. Integrates a ReservationGrpcClient and proto (reservation_internal.proto) to verify if a guest can rate a target; service now checks eligibility and prevents duplicate ratings (throws ConflictException) and unauthorized updates/deletes (throws ForbiddenException). Adds RatingsSummaryResponse and updates controller endpoints to return summaries and pass UserContext. Adds repository lookup for existing guest-target ratings, a ConflictException class and handler, a ReservationEligibilityResult record, and gRPC client config in application.properties. Also includes minor controller path change and related method signature updates.
Introduce RabbitMQ-based notification publishing and an accommodation gRPC client. Added RabbitMQConfig (exchange + JSON converter), message DTOs (HostRatedMessage, AccommodationRatedMessage), and RatingEventPublisherService to publish host/accommodation rated events via RabbitTemplate. Added accommodation gRPC proto and client (AccommodationGrpcClient + AccommodationSummaryResult) and wired accommodation client into service flow. Update RatingService to inject and invoke the event publisher after saving ratings and add targetType to RatingResponse. Also add RabbitMQ and accommodation gRPC settings to application.properties and local env, and include jackson-datatype-jsr310 and spring-boot-starter-amqp dependencies in build.gradle.kts. These changes enable sending notifications to hosts when ratings are created.
Add comprehensive test coverage and test build config: - New tests: RatingControllerTest, RatingServiceTest, RatingEventPublisherServiceTest (unit tests) and RatingIntegrationTest (integration tests using Testcontainers + MongoDB). - Update RatingApplicationTests: activate "test" profile and mock RatingEventPublisherService to avoid real publishing during tests. - Add src/test/resources/application-test.properties to configure test profile (disable tracing, exclude RabbitAutoConfiguration, and provide static gRPC addresses for mocked clients). - Update build.gradle.kts: add jacoco plugin and jacocoTestReport task, add test dependencies (spring-boot-starter-test, webmvc-test, Testcontainers for JUnit/MongoDB), and add Lombok test compile/annotation-processor entries; ensure tests use JUnit Platform. - Minor update to logback-test.xml. These changes enable isolated unit testing, ordered integration tests backed by a transient MongoDB container, and generation of JaCoCo XML coverage reports for CI.
rozicd
approved these changes
Feb 22, 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.
No description provided.