Skip to content

Conversation

@Shyam-Vishwakarma
Copy link
Contributor

@Shyam-Vishwakarma Shyam-Vishwakarma commented May 22, 2025

Date: 23 May 2025

Developer Name: @Shyam-Vishwakarma

Issue Ticket Number

Description

  • Added integration tests for PATCH v1/endorsements/{endorsementId} endpoint

  • Added centralized exception messages by adding constants in Constants.java and updated usage of the hardcoded error messages with these constants.

  • Changed the cookieName property in application-test.properties from rds-session-v2-development to rds-session-v2 to align with the production-like configuration and make consistent with RESTApiHelper class.

  • Note: Four tests are being skipped because the bugs related to these tests will be fixed once the issue [BUG] Fix bugs in PATCH /v1/endorsements/{id} endpoint #206 is resolved.

Documentation Updated?

  • Yes
  • No

Under Feature Flag

  • Yes
  • No

Database Changes

  • Yes
  • No

Breaking Changes

  • Yes
  • No

Development Tested?

  • Yes
  • No

Screenshots

Screenshot 1 Build success:

image

Test Coverage

Screenshot 1

Screenshot 2025-05-23 013029

  • Test coverage is low because unit tests are not available for dtos, view-models and utils classes.

Additional Notes

  • Execute mvn verify --file skill-tree/pom.xml -Dskip-ut=true command to run integration tests, and mvn test --file skill-tree/pom.xml to run unit tests
  • Make sure, Docker engine is running while executing integration tests.

@coderabbitai
Copy link

coderabbitai bot commented May 22, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Summary by CodeRabbit

  • New Features
    • Added comprehensive integration tests for updating endorsement messages, covering scenarios like successful updates, validation errors, authorization issues, and error handling.
  • Bug Fixes
    • Improved error message consistency by centralizing validation and exception messages.
  • Chores
    • Updated test configuration for session cookie naming.

Walkthrough

The changes centralize various error message strings as constants in the Constants class, update references to these constants across the codebase, and introduce a comprehensive integration test class for the PATCH /v1/endorsements/{id} endpoint. The test class covers scenarios including validation, authorization, and error handling.

Changes

File(s) Change Summary
skill-tree/src/main/java/com/RDS/skilltree/utils/Constants.java Added three new exception message constants: ENDORSEMENT_MESSAGE_EMPTY, USER_NOT_FOUND, and UNAUTHORIZED_ENDORSEMENT_UPDATE.
skill-tree/src/main/java/com/RDS/skilltree/services/external/RdsServiceImplementation.java Replaced a hardcoded exception message with the new USER_NOT_FOUND constant.
skill-tree/src/main/java/com/RDS/skilltree/viewmodels/UpdateEndorsementViewModel.java Updated validation annotation to use the ENDORSEMENT_MESSAGE_EMPTY constant instead of a hardcoded string.
skill-tree/src/main/resources/application-test.properties Changed cookieName property value from rds-session-v2-development to rds-session-v2.
skill-tree/src/test/java/com/RDS/skilltree/integration/skills/UpdateEndorsementsIntegrationTest.java Added a new integration test class covering various PATCH /v1/endorsements/{id} scenarios.

Sequence Diagram(s)

sequenceDiagram
    participant Test as UpdateEndorsementsIntegrationTest
    participant API as EndorsementsController
    participant Service as EndorsementService
    participant Repo as EndorsementRepository
    participant RDS as RdsServiceImplementation

    Test->>API: PATCH /v1/endorsements/{id} (with message)
    API->>Service: updateEndorsement(id, message, user)
    Service->>Repo: findById(id)
    Repo-->>Service: Endorsement or null
    Service->>RDS: getUserDetails(userId)
    RDS-->>Service: UserDetails or Exception
    Service->>Repo: save(updated Endorsement)
    Repo-->>Service: Updated Endorsement
    Service-->>API: Updated Endorsement
    API-->>Test: HTTP Response (200/400/401/403/404)
Loading

Assessment against linked issues

Objective Addressed Explanation
Integration tests for PATCH /v1/endorsements/{id} (#181)

Suggested reviewers

  • mbramani
  • iamitprakash

Poem

A rabbit hops with glee today,
For constants guide what errors say!
With tests that check each patch and post,
The code is solid—raise a toast!
Endorsements patched, the bugs all flee,
Hooray for teamwork—hip, hip, yippee! 🐇✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 29a45b5 and 66be30e.

📒 Files selected for processing (5)
  • skill-tree/src/main/java/com/RDS/skilltree/services/external/RdsServiceImplementation.java (2 hunks)
  • skill-tree/src/main/java/com/RDS/skilltree/utils/Constants.java (1 hunks)
  • skill-tree/src/main/java/com/RDS/skilltree/viewmodels/UpdateEndorsementViewModel.java (1 hunks)
  • skill-tree/src/main/resources/application-test.properties (1 hunks)
  • skill-tree/src/test/java/com/RDS/skilltree/integration/skills/UpdateEndorsementsIntegrationTest.java (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
skill-tree/src/main/java/com/RDS/skilltree/viewmodels/UpdateEndorsementViewModel.java (1)
skill-tree/src/main/java/com/RDS/skilltree/utils/Constants.java (2)
  • Constants (3-16)
  • ExceptionMessages (6-15)
skill-tree/src/main/java/com/RDS/skilltree/services/external/RdsServiceImplementation.java (1)
skill-tree/src/main/java/com/RDS/skilltree/utils/Constants.java (2)
  • Constants (3-16)
  • ExceptionMessages (6-15)
🔇 Additional comments (1)
skill-tree/src/main/resources/application-test.properties (1)

1-1: Verify that every helper relying on cookieName was updated

Changing the cookie name in the test profile to match production (rds-session-v2) is sensible, but double-check:

  1. Any code that reads the cookieName property programmatically.
  2. Utility helpers (e.g., RestAPIHelper#getGuestUserCookie) that may still send the old value.
  3. CI pipelines caching cookies between test steps.

A quick grep over the codebase (or running the existing integration test suite) will catch lingering references.

@iamitprakash iamitprakash merged commit 526e35a into RealDevSquad:develop Jun 2, 2025
5 checks passed
@AnujChhikara AnujChhikara mentioned this pull request Jun 10, 2025
10 tasks
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.

[TEST] Write integration tests for PATCH /v1/endorsements/{id}

4 participants