Skip to content

feat: Rating inter service communication#6

Merged
janosevicsm merged 5 commits intodevelopfrom
feature/inter-service-communication
Feb 22, 2026
Merged

feat: Rating inter service communication#6
janosevicsm merged 5 commits intodevelopfrom
feature/inter-service-communication

Conversation

@janosevicsm
Copy link
Copy Markdown
Contributor

No description provided.

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.
@janosevicsm janosevicsm self-assigned this Feb 22, 2026
@janosevicsm janosevicsm merged commit e74c9d6 into develop Feb 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants