Skip to content

Refactor/181 university and my api#4

Open
nayonsoso wants to merge 5 commits into
developfrom
refactor/181-university-and-my-api
Open

Refactor/181 university and my api#4
nayonsoso wants to merge 5 commits into
developfrom
refactor/181-university-and-my-api

Conversation

@nayonsoso
Copy link
Copy Markdown
Owner

@nayonsoso nayonsoso commented Feb 11, 2025

User description

관련 이슈

  • resolves: #이슈 번호

작업 내용

특이 사항

리뷰 요구사항 (선택)


PR Type

Enhancement, Bug fix, Tests


Description

  • Refactored and streamlined API endpoints for user and university operations.

    • Changed my-page endpoint to my and consolidated update operations.
    • Updated university endpoint to universities and separated like/unlike operations.
  • Enhanced error handling for user and university-related actions.

    • Added specific error codes for university like/unlike operations.
    • Improved validation for nickname changes and profile image updates.
  • Improved test coverage and refactored test cases.

    • Updated tests to reflect new API endpoints and logic.
    • Removed redundant tests and added new ones for enhanced scenarios.
  • Added development environment test data for easier testing.


Changes walkthrough 📝

Relevant files
Bug fix
1 files
EmailSignInService.java
Removed unnecessary `throws` declaration in password validation
+1/-1     
Enhancement
5 files
ErrorCode.java
Added error codes for university like/unlike operations   
+2/-0     
SiteUserController.java
Refactored user API endpoints and consolidated update operations
+9/-29   
SiteUserService.java
Consolidated user profile and nickname update logic           
+32/-55 
UniversityController.java
Refactored university API endpoints and separated like/unlike
operations
+13/-3   
UniversityLikeService.java
Added separate methods for liking and unliking universities
+23/-5   
Tests
8 files
MyPageTest.java
Updated tests for refactored user API endpoints                   
+1/-1     
MyPageUpdateTest.java
Removed redundant tests for user profile updates                 
+0/-133 
UniversityDetailTest.java
Updated tests for refactored university detail endpoint   
+1/-1     
UniversityLikeTest.java
Updated tests for university like/unlike operations           
+3/-26   
UniversityRecommendTest.java
Updated tests for university recommendation endpoint         
+5/-5     
UniversitySearchTest.java
Updated tests for university search endpoint                         
+7/-7     
SiteUserServiceTest.java
Refactored tests for user profile and nickname updates     
+22/-39 
UniversityLikeServiceTest.java
Added tests for university like/unlike error handling       
+66/-25 
Configuration changes
1 files
data.sql
Added test data for development environment                           
+5/-0     

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Summary by CodeRabbit

    • New Features

      • Introduced the ability to cancel a liked university directly through a new removal option.
    • API Changes

      • Updated endpoints for profile and university operations (e.g., profile management now uses a unified endpoint, and university routes are standardized).
    • Improvements

      • Consolidated profile updates to handle both image and nickname changes together.
      • Enhanced error feedback on duplicate like actions and invalid cancellation attempts.

    @deepsource-io
    Copy link
    Copy Markdown

    deepsource-io Bot commented Feb 11, 2025

    Here's the code health analysis summary for commits faec50b..26727ed. View details on DeepSource ↗.

    Analysis Summary

    AnalyzerStatusSummaryLink
    DeepSource Java LogoJava❌ Failure
    ❗ 1 occurence introduced
    🎯 2 occurences resolved
    View Check ↗
    DeepSource Shell LogoShell✅ SuccessView Check ↗

    💡 If you’re a repository administrator, you can configure the quality gates from the settings.

    @coderabbitai
    Copy link
    Copy Markdown

    coderabbitai Bot commented Feb 11, 2025

    Walkthrough

    This pull request introduces several modifications across the codebase. In the authentication module, the exception declaration in the password validation method has been removed while preserving internal logic. New error codes are added to the error-handling enum. The user profile update functions are consolidated into a single endpoint with updated request mappings and dependency injections. University endpoints are pluralized and refined with a new cancellation operation for wish-listed universities, while related exception handling is revised. Several test files have been updated or removed, and a new SQL record for a user is inserted.

    Changes

    File(s) Change Summary
    src/main/java/.../auth/service/EmailSignInService.java Removed explicit throws CustomException in validatePassword method signature; internal exception logic remains unchanged.
    src/main/java/.../custom/exception/ErrorCode.java Added two new error codes: ALREADY_LIKED_UNIVERSITY and NOT_LIKED_UNIVERSITY.
    src/main/java/.../siteuser/controller/SiteUserController.java,
    src/main/java/.../siteuser/service/SiteUserService.java,
    src/test/java/.../e2e/MyPageTest.java,
    src/test/java/.../e2e/MyPageUpdateTest.java,
    src/test/java/.../siteuser/service/SiteUserServiceTest.java
    Consolidated multiple update endpoints into a single updateMyPageInfo method; updated request mappings from /my-page to /my; removed outdated methods and tests; introduced a new S3Service dependency.
    src/main/java/.../university/controller/UniversityController.java,
    src/main/java/.../university/service/UniversityLikeService.java
    Updated base endpoints from singular to plural; modified recommend (/recommends/recommend) and detail (/detail/{id}/{id}) paths; added cancelWishUniversity and cancelLikeUniversity methods; adjusted exception flow for like actions.
    src/test/java/.../e2e/UniversityDetailTest.java,
    src/test/java/.../e2e/UniversityRecommendTest.java,
    src/test/java/.../e2e/UniversitySearchTest.java,
    src/test/java/.../e2e/UniversityLikeTest.java,
    src/test/java/.../university/service/UniversityLikeServiceTest.java
    Updated endpoint paths for university operations; restructured like-related tests with nested classes; removed a duplicate like test case for enhanced coverage.
    src/main/resources/data.sql Added an SQL record to insert a new user into the site_user table.

    Sequence Diagram(s)

    sequenceDiagram
        participant U as User
        participant C as SiteUserController
        participant S as SiteUserService
        participant S3 as S3Service
        U->>C: PATCH /my with image & nickname
        C->>S: updateMyPageInfo(user, imageFile, nickname)
        S->>S3: (Optional) Validate/Upload image file
        S-->>C: Update performed (no response body)
        C-->>U: HTTP 200 OK
    
    Loading
    sequenceDiagram
        participant U as User
        participant UC as UniversityController
        participant ULS as UniversityLikeService
        U->>UC: DELETE /universities/{id}/like
        UC->>ULS: cancelLikeUniversity(user, id)
        alt University not liked
            ULS-->>UC: Throw CustomException (NOT_LIKED_UNIVERSITY)
            UC-->>U: HTTP error response
        else Like exists
            ULS-->>UC: LikeResultResponse (cancellation confirmed)
            UC-->>U: HTTP 200 OK with response
        end
    
    Loading

    Poem

    I'm a hopping rabbit in a code-filled glen,
    Skipping through changes like dew on the fen.
    Endpoints now plural, methods streamlined with care,
    New error codes and tests—coding magic in the air!
    With carrots of logic and hops of delight,
    I celebrate these changes deep into the night. 🐰

    ✨ Finishing Touches
    • 📝 Generate Docstrings (Beta)

    🪧 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.
      • Generate unit testing code for this file.
      • 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 generate unit testing code for this file.
      • @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 generate unit testing code.
      • @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.

    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. (Beta)
    • @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.

    @qodo-code-review
    Copy link
    Copy Markdown

    Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Input Validation

    The combined update endpoint for profile image and nickname lacks proper input validation for the nickname parameter. Consider adding validation annotations like @Valid and size/pattern constraints.

    @PatchMapping
    public ResponseEntity<Void> updateMyPageInfo(
            @AuthorizedUser SiteUser siteUser,
            @RequestParam("file") MultipartFile imageFile,
            @RequestParam("nickname") String nickname
    ) {
        siteUserService.updateMyPageInfo(siteUser, imageFile, nickname);
        return ResponseEntity.ok().build();
    }
    Race Condition

    The like/unlike operations could have race conditions when multiple requests happen simultaneously. Consider adding proper transaction isolation or optimistic locking.

    @Transactional
    public LikeResultResponse likeUniversity(SiteUser siteUser, Long universityInfoForApplyId) {
        UniversityInfoForApply universityInfoForApply = universityInfoForApplyRepository.getUniversityInfoForApplyById(universityInfoForApplyId);
    
        Optional<LikedUniversity> optionalLikedUniversity = likedUniversityRepository.findBySiteUserAndUniversityInfoForApply(siteUser, universityInfoForApply);
        if (optionalLikedUniversity.isPresent()) {
            throw new CustomException(ALREADY_LIKED_UNIVERSITY);
        }

    @qodo-code-review
    Copy link
    Copy Markdown

    Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Add ID parameter validation

    Add parameter validation to ensure universityInfoForApplyId is positive, since
    it's used as a database ID.

    src/main/java/com/example/solidconnection/university/service/UniversityLikeService.java [58]

    -public LikeResultResponse cancelLikeUniversity(SiteUser siteUser, long universityInfoForApplyId) throws CustomException {
    +public LikeResultResponse cancelLikeUniversity(SiteUser siteUser, long universityInfoForApplyId) {
    +    if (universityInfoForApplyId <= 0) {
    +        throw new CustomException(UNIVERSITY_INFO_FOR_APPLY_NOT_FOUND);
    +    }
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    __

    Why: Adding validation for the universityInfoForApplyId parameter is a good defensive programming practice that can prevent potential issues with invalid IDs before database access.

    Medium
    General
    Remove redundant exception declaration

    Remove unnecessary throws declaration since CustomException is a
    RuntimeException and doesn't need to be declared.

    src/main/java/com/example/solidconnection/auth/service/EmailSignInService.java [38]

    -private void validatePassword(String rawPassword, String encodedPassword) throws CustomException {
    +private void validatePassword(String rawPassword, String encodedPassword) {

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 5

    __

    Why: The suggestion correctly identifies that declaring 'throws CustomException' is redundant since CustomException is a RuntimeException. Removing it improves code clarity.

    Low

    Copy link
    Copy Markdown

    @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: 0

    🔭 Outside diff range comments (1)
    src/test/java/com/example/solidconnection/e2e/UniversityLikeTest.java (1)

    31-123: ⚠️ Potential issue

    Add test coverage for already liked universities.

    A test case for handling the scenario where a user attempts to like an already liked university has been removed. Based on the AI summary, the service now throws a CustomException with ALREADY_LIKED_UNIVERSITY error code in this case. This scenario should be tested to ensure proper error handling.

    Add the following test case:

    @Test
    void 이미_좋아요한_대학교에_좋아요를_누른다() {
        // setUp - Save initial like
        likedUniversityRepository.save(createLikedUniversity(siteUser, 괌대학_A_지원_정보));
    
        // request - Attempt to like again
        RestAssured.given()
                .header("Authorization", "Bearer " + accessToken)
                .log().all()
                .post("/universities/" + 괌대학_A_지원_정보.getId() + "/like")
                .then().log().all()
                .statusCode(HttpStatus.BAD_REQUEST.value())
                .body("code", equalTo("ALREADY_LIKED_UNIVERSITY"));
    }
    🧹 Nitpick comments (12)
    src/main/java/com/example/solidconnection/auth/service/EmailSignInService.java (1)

    38-42: Consider keeping the throws CustomException declaration.

    While the method still throws CustomException, removing the declaration from the method signature makes the error handling less explicit. This could make it harder for other developers to understand and handle potential exceptions.

    -    private void validatePassword(String rawPassword, String encodedPassword) {
    +    private void validatePassword(String rawPassword, String encodedPassword) throws CustomException {
    src/main/java/com/example/solidconnection/university/service/UniversityLikeService.java (1)

    54-68: Consider adding more descriptive error messages.

    While the error handling is good, consider adding more descriptive error messages to help users understand what went wrong.

    -            throw new CustomException(NOT_LIKED_UNIVERSITY);
    +            throw new CustomException(NOT_LIKED_UNIVERSITY, 
    +                "University with ID " + universityInfoForApplyId + " is not in your wish list");
    src/main/java/com/example/solidconnection/university/controller/UniversityController.java (1)

    91-91: Address the TODO comment regarding return type.

    The comment indicates a needed change in the return type to UniversityInfoForApplyPreviewResponses.

    Would you like me to help implement this change or create an issue to track this task?

    src/test/java/com/example/solidconnection/university/service/UniversityLikeServiceTest.java (1)

    156-167: Consider using a test data builder pattern.

    While the current test data creation is functional, consider implementing a builder pattern for SiteUser to make test data creation more flexible and maintainable.

    Example implementation:

    -    private SiteUser createSiteUser() {
    -        SiteUser siteUser = new SiteUser(
    -                "test@example.com",
    -                "nickname",
    -                "profileImageUrl",
    -                "1999-01-01",
    -                PreparationStatus.CONSIDERING,
    -                Role.MENTEE,
    -                Gender.MALE
    -        );
    -        return siteUserRepository.save(siteUser);
    -    }
    +    @Builder
    +    private static class TestSiteUserBuilder {
    +        private String email = "test@example.com";
    +        private String nickname = "nickname";
    +        private String profileImageUrl = "profileImageUrl";
    +        private String birthDate = "1999-01-01";
    +        private PreparationStatus status = PreparationStatus.CONSIDERING;
    +        private Role role = Role.MENTEE;
    +        private Gender gender = Gender.MALE;
    +        
    +        public SiteUser build() {
    +            return new SiteUser(email, nickname, profileImageUrl, 
    +                              birthDate, status, role, gender);
    +        }
    +    }
    +
    +    private SiteUser createSiteUser() {
    +        return siteUserRepository.save(
    +            TestSiteUserBuilder.builder().build()
    +        );
    +    }
    src/main/java/com/example/solidconnection/siteuser/controller/SiteUserController.java (1)

    33-40: Consider returning updated info in the response.
    Consolidating the nickname and profile image updates in one method is clean, but returning an empty response makes it harder for clients to confirm new values. Consider returning a response with updated fields for convenience.

    src/main/java/com/example/solidconnection/siteuser/service/SiteUserService.java (5)

    50-53: Ensure partial updates are supported if desired.
    All validations (nickname uniqueness, recency, and non-empty image) occur simultaneously. If the user intends to only update one item (e.g., just the nickname), it will still require a new image file. Clarify if every update must include a new image or if partial updates should be allowed.


    61-62: User entity updates are straightforward.
    Assigning the new URL and nickname here is fine. Optionally, you could unify these updates in a single setter or a domain method if you want stricter consistency checks or event triggers.


    67-67: Consider normalization for nickname uniqueness checks.
    By default, existsByNickname is likely case-sensitive. Ensure you want "Nick" and "nick" as distinct entries. If not, convert the nickname to a canonical form before checking.


    84-87: Allowing empty image might be desired?
    Currently, the code enforces strictly that files not be empty. If the user only wants to change the nickname, they still must upload an image. Confirm this is intentional.


    90-93: Fragile default-image check.
    Relying on the 'profile/' prefix to distinguish default images may break if future default URLs differ. A more explicit field or default-flag might be more robust.

    src/main/resources/data.sql (2)

    44-47: Avoid dependency on external profile images in test data.

    The profile image URL points to a specific GitHub user's profile picture. This creates an external dependency that could break tests if the image becomes unavailable.

    Consider using a local test image or a reliable placeholder image service:

    -VALUES ('1999-01-01', 'test@test.email', 'yonso','https://github.com/nayonsoso.png',
    +VALUES ('1999-01-01', 'test@test.email', 'yonso','https://via.placeholder.com/150',
             'FEMALE', 'CONSIDERING', 'MENTEE',
             '$2a$10$psmwlxPfqWnIlq9JrlQJkuXr1XtjRNsyVOgcTWYZub5jFfn0TML76', 'EMAIL'); -- 12341234

    47-47: Use a stronger password for test data.

    The comment indicates the password is "12341234", which is a weak password. Even for test data, it's good practice to use strong passwords to prevent accidental use in production.

    Consider using a stronger password that meets common security requirements (e.g., minimum length, mixed case, numbers, special characters).

    -        '$2a$10$psmwlxPfqWnIlq9JrlQJkuXr1XtjRNsyVOgcTWYZub5jFfn0TML76', 'EMAIL'); -- 12341234
    +        '$2a$10$psmwlxPfqWnIlq9JrlQJkuXr1XtjRNsyVOgcTWYZub5jFfn0TML76', 'EMAIL'); -- TestUser123!@#
    📜 Review details

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

    📥 Commits

    Reviewing files that changed from the base of the PR and between faec50b and 26727ed.

    📒 Files selected for processing (15)
    • src/main/java/com/example/solidconnection/auth/service/EmailSignInService.java (1 hunks)
    • src/main/java/com/example/solidconnection/custom/exception/ErrorCode.java (1 hunks)
    • src/main/java/com/example/solidconnection/siteuser/controller/SiteUserController.java (2 hunks)
    • src/main/java/com/example/solidconnection/siteuser/service/SiteUserService.java (2 hunks)
    • src/main/java/com/example/solidconnection/university/controller/UniversityController.java (4 hunks)
    • src/main/java/com/example/solidconnection/university/service/UniversityLikeService.java (4 hunks)
    • src/main/resources/data.sql (1 hunks)
    • src/test/java/com/example/solidconnection/e2e/MyPageTest.java (1 hunks)
    • src/test/java/com/example/solidconnection/e2e/MyPageUpdateTest.java (0 hunks)
    • src/test/java/com/example/solidconnection/e2e/UniversityDetailTest.java (1 hunks)
    • src/test/java/com/example/solidconnection/e2e/UniversityLikeTest.java (3 hunks)
    • src/test/java/com/example/solidconnection/e2e/UniversityRecommendTest.java (5 hunks)
    • src/test/java/com/example/solidconnection/e2e/UniversitySearchTest.java (7 hunks)
    • src/test/java/com/example/solidconnection/siteuser/service/SiteUserServiceTest.java (8 hunks)
    • src/test/java/com/example/solidconnection/university/service/UniversityLikeServiceTest.java (2 hunks)
    💤 Files with no reviewable changes (1)
    • src/test/java/com/example/solidconnection/e2e/MyPageUpdateTest.java
    🔇 Additional comments (32)
    src/test/java/com/example/solidconnection/e2e/UniversityRecommendTest.java (2)

    69-69: LGTM! Endpoint changes follow REST API best practices.

    The endpoint updates from /university/recommends to /universities/recommend across all test methods are consistent and align with REST API conventions by using plural nouns for resource collections.

    Also applies to: 97-97, 124-124, 151-151, 174-174


    60-190: LGTM! Test implementation is robust and comprehensive.

    The test class demonstrates excellent test practices:

    • Clear test scenarios covering all important use cases
    • Well-structured test methods with setup, execution, and verification phases
    • Comprehensive assertions using assertAll
    • Descriptive test names
    src/test/java/com/example/solidconnection/e2e/UniversityLikeTest.java (1)

    75-75: LGTM! Endpoint paths updated to follow REST conventions.

    The endpoint paths have been updated from /university/* to /universities/* to better align with REST conventions for resource collections.

    Also applies to: 94-94, 116-116

    src/main/java/com/example/solidconnection/university/service/UniversityLikeService.java (1)

    41-44: LGTM! Improved error handling for duplicate likes.

    The change properly handles the case when a user tries to like an already liked university by throwing a specific exception.

    src/main/java/com/example/solidconnection/university/controller/UniversityController.java (1)

    28-28: LGTM! Improved RESTful API design.

    The change from /university to /universities better follows REST conventions by using plural nouns for resource collections.

    src/test/java/com/example/solidconnection/e2e/UniversityDetailTest.java (1)

    48-48: LGTM! Test updated to match new endpoint structure.

    The test has been properly updated to use the new pluralized endpoint path /universities/, maintaining consistency with the controller changes.

    src/main/java/com/example/solidconnection/custom/exception/ErrorCode.java (1)

    86-87: LGTM! Well-structured error codes.

    The new error codes follow the established pattern and maintain consistency with existing error codes in terms of HTTP status codes and message formatting.

    src/test/java/com/example/solidconnection/university/service/UniversityLikeServiceTest.java (2)

    41-72: LGTM! Well-organized test structure using nested classes.

    The use of @Nested classes improves test organization and readability by grouping related test cases together.


    44-71: LGTM! Comprehensive test coverage with proper assertions.

    The test methods effectively cover both success and failure scenarios:

    • Uses assertAll for multiple assertions
    • Properly tests exception cases with assertThatCode
    src/test/java/com/example/solidconnection/e2e/MyPageTest.java (2)

    47-47: LGTM! Endpoint URL update aligns with controller changes.

    The endpoint URL change from /my-page to /my correctly reflects the updated @RequestMapping in SiteUserController.


    41-57: Verify test coverage after MyPageUpdateTest.java deletion.

    Since MyPageUpdateTest.java was deleted, please ensure that all update operations previously tested there are now covered by other test files.

    ❌ Verification inconclusive

    🏁 Script executed:

    #!/bin/bash
    # Search for tests covering the new consolidated update endpoint
    rg -t java "test.*my.*update" "src/test"
    
    # Search for any remaining references to the old endpoint
    rg -t java "my-page" "src/test"

    Length of output: 70


    Test Coverage for Update Operations Not Evident

    The searches did not return any test cases specifically referencing update operations (e.g., tests using “update”, “put”, or “patch” with the “/my” endpoint). This could mean that either update operations were integrated into other tests with different naming, or that these cases are currently not being tested. Please manually verify that update scenarios previously covered in MyPageUpdateTest.java are now appropriately tested.

    src/test/java/com/example/solidconnection/e2e/UniversitySearchTest.java (1)

    46-46: LGTM! Consistent endpoint updates across all test methods.

    The changes to pluralize the university endpoints from /university/search to /universities/search are consistent across all test methods and align with REST API best practices of using plural nouns for resources.

    Let's verify that these endpoint changes are coordinated with the controller updates:

    Also applies to: 70-70, 88-88, 105-105, 123-123, 142-142, 158-158

    ✅ Verification successful

    🏁 Script executed:

    #!/bin/bash
    # Description: Verify that the UniversityController's base request mapping has been updated to match the test endpoints
    
    # Search for the UniversityController class and its request mapping
    ast-grep --pattern $'@RequestMapping($path)
    class UniversityController {
      $$$
    }'

    Length of output: 82


    I'll generate an additional shell script to further verify that the base request mapping in the UniversityController has been updated to use the /universities endpoint.

    Please run this script to check for the appropriate updated mapping in UniversityController. If these commands show that the controller now uses /universities, then the changes are coordinated. Otherwise, manual verification may be required.


    🏁 Script executed:

    #!/bin/bash
    echo "Searching for UniversityController file(s):"
    # List Java files mentioning 'UniversityController'
    fd -e java -x grep -H "class UniversityController" {}
    
    echo "------------------------------------------"
    echo "Searching for updated @RequestMapping endpoints (should include '/universities'):"
    # Search for @RequestMapping annotations that include '/universities'
    rg -n '@RequestMapping\(".*universities' .

    Length of output: 727


    Endpoint updates are coordinated and consistent.

    The UniversityController in src/main/java/com/example/solidconnection/university/controller/UniversityController.java now maps to "/universities" (line 28), which perfectly aligns with the test endpoints in UniversitySearchTest.java.

    src/main/java/com/example/solidconnection/siteuser/controller/SiteUserController.java (3)

    4-4: No concerns with new import usage.
    Importing S3Service here appears correct and consistent with the changes below.


    18-18: Heads-up on potential breaking change.
    Changing the endpoint path from "/my-page" to "/my" could break existing client integrations if they are not updated accordingly.


    23-23: Validate necessity of direct usage in controller.
    S3Service is declared here but is not directly referenced in this controller code. Confirm if it’s needed or should remain only in the service layer to keep the controller lean.

    src/main/java/com/example/solidconnection/siteuser/service/SiteUserService.java (3)

    47-47: Documentation alignment is fine.
    This line properly explains the method’s purpose in Korean. No issues spotted.


    58-59: Watch for upload failures.
    While the integration with S3Service looks correct, consider handling potential exceptions from the upload call to provide more robust error responses.


    95-104: Wish-list retrieval logic looks good.
    Method implementation is straightforward, returns the correct list of universities. No issues found here.

    src/test/java/com/example/solidconnection/siteuser/service/SiteUserServiceTest.java (14)

    19-19: Import of @beforeeach is correct.
    Introducing @BeforeEach usage below is typical for shared setup logic.


    39-41: Mockito imports look fine.
    Using BDDMockito for readability in test setup is consistent with your existing pattern.


    112-112: Method call coverage is appropriate.
    Ensures the newly introduced updateMyPageInfo logic is under test.


    115-115: Verification of updated profile image is accurate.
    Asserts that the service call updates profileImageUrl correctly.


    127-127: Repeated service call for coverage.
    Testing another scenario or repeated usage is good practice. No concerns here.


    155-155: Exception handling test is valid.
    Confirms that empty image files trigger the expected exception, covering a crucial edge case.


    164-168: Setup method removal of duplication.
    Centralizing repeated stubbing logic for S3 in @BeforeEach is good practice.


    174-174: Test-scope valid image creation is standard.
    Creation of a valid MockMultipartFile for testing is clear and reusable.


    178-178: Ensures nickname path is covered.
    Updating both nickname and image in the same test verifies combined logic.


    183-183: Checks final nickname state properly.
    Asserting the final entity state ensures correctness of nickname updates.


    191-191: Reusing valid file creation approach.
    Shows consistency in test code. No concerns here.


    194-196: Duplicate nickname exception is handled.
    Verifies that the custom exception triggers as expected for collisions.


    203-203: No concerns with file creation usage.
    Continues consistent test scaffolding.


    211-213: Testing insufficient time gap edge case.
    Confirms the custom exception is thrown for nickname changes too soon.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    1 participant