Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(KL-68): update Product API #25

Merged

Conversation

ohhamma
Copy link
Contributor

@ohhamma ohhamma commented Jul 30, 2024

πŸ“Œ μ—°κ΄€λœ 이슈

πŸ“ μž‘μ—… λ‚΄μš©

  • μƒν’ˆ 정보 μˆ˜μ • API κ΅¬ν˜„
  • κ΄€λ ¨ ν…ŒμŠ€νŠΈμ½”λ“œ μž‘μ„±

🌳 μž‘μ—… 브랜치λͺ…

  • KL-68/μƒν’ˆ-정보-μˆ˜μ •-api-κ΅¬ν˜„

πŸ“Έ μŠ€ν¬λ¦°μƒ· (선택)

πŸ’¬ 리뷰 μš”κ΅¬μ‚¬ν•­ (선택)

Summary by CodeRabbit

  • New Features

    • Introduced a new endpoint for updating product information with PATCH requests, allowing partial updates to product details.
    • Enhanced product creation and update functionalities with improved validation for incoming requests.
  • Bug Fixes

    • Improved error handling for malformed requests, enhancing clarity and robustness in error reporting.
  • Tests

    • Expanded test coverage to include scenarios for product updates and validation, ensuring robustness in functionality.
  • Documentation

    • Updated validation messages and constraints for product-related data to improve data integrity.

ohhamma added 3 commits July 30, 2024 15:21
- updateDtoλ₯Ό λ°›μ•„ null이 μ•„λ‹Œ ν•„λ“œ 값을 λ³€κ²½ν•˜λŠ” μƒν’ˆ update λ©”μ†Œλ“œ μž‘μ„±
- κ΄€λ ¨ ν…ŒμŠ€νŠΈμ½”λ“œ μž‘μ„±
  - μƒν’ˆ 정보 μ—…λ°μ΄νŠΈ ν…ŒμŠ€νŠΈ
  - μƒν’ˆ 정보 λΆ€λΆ„ μ—…λ°μ΄νŠΈ ν…ŒμŠ€νŠΈ
  - μƒν’ˆ 정보 μ—…λ°μ΄νŠΈ μ‹œ null κ°’ λ¬΄μ‹œ ν…ŒμŠ€νŠΈ
- ProductService에 id, updateDtoλ₯Ό λ°›μ•„ μƒν’ˆμ˜ 정보λ₯Ό μˆ˜μ • 및 λ ˆν¬μ§€ν† λ¦¬μ— 변경사항 μ €μž₯
- κ΄€λ ¨ ν…ŒμŠ€νŠΈμ½”λ“œ μž‘μ„±
  - μƒν’ˆ μ—…λ°μ΄νŠΈ 성곡 ν…ŒμŠ€νŠΈ
  - μƒν’ˆ μ—…λ°μ΄νŠΈ μ‹€νŒ¨ ν…ŒμŠ€νŠΈ - μƒν’ˆ μ—†μŒ
- μƒν’ˆ 정보 μˆ˜μ • API κ΅¬ν˜„
- κ΄€λ ¨ ν…ŒμŠ€νŠΈμ½”λ“œ μž‘μ„±
  - μƒν’ˆ 정보 λΆ€λΆ„ μ—…λ°μ΄νŠΈ API ν…ŒμŠ€νŠΈ
@ohhamma ohhamma added βœ… Test ν…ŒμŠ€νŠΈ κ΄€λ ¨ ✨ Feature μƒˆλ‘œμš΄ κΈ°λŠ₯ 개발 및 μš”μ²­ labels Jul 30, 2024
@ohhamma ohhamma requested review from idealflower-k and min3m July 30, 2024 07:44
@ohhamma ohhamma self-assigned this Jul 30, 2024
@ohhamma ohhamma changed the title feat(KL-68): update product api feat(KL-68): update Product API Jul 30, 2024
Copy link
Contributor

@idealflower-k idealflower-k left a comment

Choose a reason for hiding this comment

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

μƒν’ˆ μ†μ„±λ“€μ˜ μœ νš¨μ„±κ²€μ‚¬κ°€ μΆ”κ°€λ˜λ©΄ 쒋을거 κ°™μŠ΅λ‹ˆλ‹€!

ohhamma added 8 commits July 30, 2024 19:01
- μƒν’ˆ 등둝 μš”μ²­ μœ νš¨μ„± 검사
- μ»¨νŠΈλ‘€λŸ¬μ— @Valid ν‚€μ›Œλ“œ μΆ”κ°€
- κ΄€λ ¨ ν…ŒμŠ€νŠΈμ½”λ“œ μΆ”κ°€
  - μƒν’ˆ 등둝 API μœ νš¨μ„± 검사 μ‹€νŒ¨ ν…ŒμŠ€νŠΈ
- μœ νš¨μ„± κ²€μ‚¬μ—μ„œ λ°œμƒν•œ 였λ₯˜ λ©”μ‹œμ§€λ₯Ό μˆ˜μ§‘ν•΄μ„œ 좜λ ₯ν•˜λ„λ‘ GlobalExceptionHandler μˆ˜μ •
- μˆ˜μ •λœ λ‚΄μš©μ— 맞게 ν…ŒμŠ€νŠΈμ½”λ“œ μˆ˜μ •
  - BindingResultλ₯Ό λͺ¨ν‚Ήν•΄μ„œ getFieldErrors()κ°€ μœ νš¨ν•œ FieldError λͺ©λ‘μ„ λ°˜ν™˜ν•˜λ„λ‘ μ„€μ •
- h2 λ°μ΄ν„°λ² μ΄μŠ€ λͺ¨λ“œ MySQL둜 μ„€μ •
- μœ νš¨ν•˜μ§€ μ•Šμ€ μš”μ²­ λ©”μ‹œμ§€μ— λŒ€ν•œ μ˜ˆμ™Έ 핸듀링
- κ΄€λ ¨ ν…ŒμŠ€νŠΈμ½”λ“œ μΆ”κ°€
- μƒν’ˆ 가격이 0 이상이어야 ν•œλ‹€λŠ” μ œμ•½ μΆ”κ°€
- κ΄€λ ¨ ν…ŒμŠ€νŠΈμ½”λ“œ μΆ”κ°€
  - 가격이 음수일 λ•Œ μœ νš¨μ„± 검사 μ‹€νŒ¨
  - 가격이 0일 λ•Œ μœ νš¨μ„± 검사 성곡
- μƒν’ˆ μš”μ²­ dtoμ—μ„œ 가격과 μ£Όμ†Œ 자리 λ°”κΏˆ
- 바뀐 μžλ¦¬μ— 맞게 κ΄€λ ¨ ν…ŒμŠ€νŠΈμ½”λ“œ μˆ˜μ •
- 각 ν…ŒμŠ€νŠΈμΌ€μ΄μŠ€μ—μ„œ λ°œμƒν•œ μ˜ˆμ™Έμ— λŒ€ν•œ μ½”λ“œμ™€ λ©”μ‹œμ§€λ₯Ό ErrorCode의 μ˜ˆμ™Έμ˜ κ°’λ“€κ³Ό λΉ„κ΅ν•˜λ„λ‘ μˆ˜μ •
- μ§€μ›ν•˜μ§€ μ•ŠλŠ” λ©”μ†Œλ“œ μ˜ˆμ™Έμ˜ 이름을 METHOD_NOT_SUPPORTED둜 λ³€κ²½
- μƒν’ˆ 등둝 μš”μ²­ dto의 μœ νš¨μ„± 검사 μΆ”κ°€
  - μƒν’ˆλͺ…, μƒν’ˆ μ„€λͺ…, μ£Όμ†Œμ˜ 길이 검사
  - ν•„μˆ˜ String ν•„λ“œμ—μ„œ 빈 λ¬Έμžμ—΄ 검사
  - κ°€κ²©μ˜ λ²”μœ„ 검사
- μΆ”κ°€λœ 검사 λ‚΄μš© ν…ŒμŠ€νŠΈμ½”λ“œμ— μΆ”κ°€
- μƒν’ˆ 등둝 μš”μ²­ dto의 ν•„λ“œ μˆœμ„œ λ³€κ²½
  - 이에 맞게 ν…ŒμŠ€νŠΈμ½”λ“œ μˆ˜μ •
- μƒν’ˆ ν•„λ“œμ˜ maxκ°’ constants둜 관리
  - 이름, μ„€λͺ…, μ£Όμ†Œμ˜ 각 μ΅œλŒ€ 길이
- μƒν’ˆ 등둝 μœ νš¨μ„± 검사 μ‹œ λ³΄μ—¬μ£ΌλŠ” λ©”μ‹œμ§€λ“€μ„ μƒμˆ˜λ‘œ 관리
- 이에 맞게 ν…ŒμŠ€νŠΈμ½”λ“œ μˆ˜μ •
- μƒμˆ˜ κ΄€λ¦¬ν•˜λŠ” ν΄λž˜μŠ€μ— final ν‚€μ›Œλ“œ μΆ”κ°€
- μƒν’ˆ 정보 μˆ˜μ • μ‹œ μœ νš¨μ„± 검사
  - μƒν’ˆλͺ…, μƒν’ˆμ„€λͺ…, μ£Όμ†Œ 길이 검사
  - 가격 λ²”μœ„ 검사
- μƒν’ˆ 정보 μˆ˜μ • dto ν•„λ“œ μˆœμ„œ λ³€κ²½
  - 이에 따라 ν…ŒμŠ€νŠΈμ½”λ“œ μˆ˜μ •
@ohhamma ohhamma requested a review from idealflower-k July 31, 2024 10:09
- ν•„μš” μ—†λŠ” TODO μ½”λ©˜νŠΈ μ‚­μ œ
idealflower-k
idealflower-k previously approved these changes Aug 1, 2024
Copy link
Contributor

@idealflower-k idealflower-k left a comment

Choose a reason for hiding this comment

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

μƒν’ˆμ΄ ν• κ²Œ λ§Žμ€λ° κ³ μƒν•˜μ…¨μŠ΅λ‹ˆλ‹€!
μ—­μ‹œ νŒ€μž₯λ‹˜ μ½”λ”© μ²œμž¬μ‹œλ„€μš” :)

- update λ‘œμ§μ— λΆˆν•„μš”ν•œ save λ©”μ†Œλ“œ 호좜 제거
- 이에 λ”°λ₯Έ ν…ŒμŠ€νŠΈμ½”λ“œ μˆ˜μ •
Copy link

coderabbitai bot commented Aug 1, 2024

Walkthrough

This update enhances the ProductController and related components to support partial updates of product information and improve validation across various data transfer objects (DTOs). New endpoints and methods have been introduced for updating product details, alongside refined validation annotations to ensure data integrity. These changes collectively improve the user experience and maintainability of the application.

Changes

Files Summary
src/main/java/taco/klkl/domain/product/controller/ProductController.java Added a new PATCH endpoint for updating products and enhanced validation for existing methods.
src/main/java/taco/klkl/domain/product/domain/Product.java Introduced a method for updating product attributes and improved column definitions.
src/main/java/taco/klkl/domain/product/dto/request/ProductCreateRequestDto.java, src/main/java/taco/klkl/domain/product/dto/request/ProductUpdateRequestDto.java Enhanced validation annotations for improved data integrity in DTOs.
src/main/java/taco/klkl/domain/product/service/ProductService.java Added methods for creating and updating products, with refined transaction management.
src/main/java/taco/klkl/global/common/constants/DefaultConstants.java, src/main/java/taco/klkl/global/common/constants/ProductConstants.java, src/main/java/taco/klkl/global/common/constants/UserConstants.java Made constants classes final to prevent subclassing.
src/main/java/taco/klkl/global/error/GlobalExceptionHandler.java, src/main/java/taco/klkl/global/error/exception/ErrorCode.java Enhanced error handling and introduced new error codes for clarity.
src/test/java/taco/klkl/domain/product/* Expanded test coverage for product creation, updates, and validation scenarios.
src/test/java/taco/klkl/global/error/GlobalExceptionHandlerTest.java Added tests for new exception handling cases.
src/main/resources/application-h2.yaml Updated database connection string for MySQL compatibility.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ProductController
    participant ProductService
    participant ProductRepository

    Client->>ProductController: PATCH /products/{id}
    ProductController->>ProductService: updateProduct(id, updateRequest)
    ProductService->>ProductRepository: findById(id)
    ProductRepository-->>ProductService: product
    ProductService->>Product: update(updateRequest)
    Product->>ProductService: return updated product
    ProductService-->>ProductController: return updated product
    ProductController-->>Client: ResponseEntity<ProductDetailResponseDto>
Loading

A rabbit’s delight in code so bright,
With patches and products, all feels just right.
Validation's in place, ensuring no error,
With constants made final, we hop with great fervor!
In tests we now leap, covering every case,
For a flawless release, we quicken our pace! πŸ‡βœ¨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@ohhamma
Copy link
Contributor Author

ohhamma commented Aug 1, 2024

@coderabbitai review

Copy link

coderabbitai bot commented Aug 1, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5e3d529 and 89a1950.

Files selected for processing (19)
  • src/main/java/taco/klkl/domain/product/controller/ProductController.java (3 hunks)
  • src/main/java/taco/klkl/domain/product/domain/Product.java (3 hunks)
  • src/main/java/taco/klkl/domain/product/dto/request/ProductCreateRequestDto.java (1 hunks)
  • src/main/java/taco/klkl/domain/product/dto/request/ProductUpdateRequestDto.java (1 hunks)
  • src/main/java/taco/klkl/domain/product/service/ProductService.java (2 hunks)
  • src/main/java/taco/klkl/global/common/constants/DefaultConstants.java (1 hunks)
  • src/main/java/taco/klkl/global/common/constants/ProductConstants.java (1 hunks)
  • src/main/java/taco/klkl/global/common/constants/ProductValidationMessages.java (1 hunks)
  • src/main/java/taco/klkl/global/common/constants/UserConstants.java (1 hunks)
  • src/main/java/taco/klkl/global/error/GlobalExceptionHandler.java (5 hunks)
  • src/main/java/taco/klkl/global/error/exception/ErrorCode.java (1 hunks)
  • src/main/resources/application-h2.yaml (1 hunks)
  • src/test/java/taco/klkl/domain/product/controller/ProductControllerTest.java (6 hunks)
  • src/test/java/taco/klkl/domain/product/domain/ProductTest.java (3 hunks)
  • src/test/java/taco/klkl/domain/product/dto/request/ProductCreateRequestDtoTest.java (2 hunks)
  • src/test/java/taco/klkl/domain/product/dto/request/ProductUpdateRequestDtoTest.java (2 hunks)
  • src/test/java/taco/klkl/domain/product/integration/ProductIntegrationTest.java (2 hunks)
  • src/test/java/taco/klkl/domain/product/service/ProductServiceTest.java (3 hunks)
  • src/test/java/taco/klkl/global/error/GlobalExceptionHandlerTest.java (7 hunks)
Files skipped from review due to trivial changes (1)
  • src/main/java/taco/klkl/global/common/constants/DefaultConstants.java
Additional comments not posted (57)
src/main/java/taco/klkl/global/common/constants/ProductConstants.java (2)

3-3: Good practice: Making the class final.

Declaring the class as final prevents it from being subclassed, which is a good practice for utility classes.


9-11: New constants added for validation.

The new constants NAME_MAX_LENGTH, DESCRIPTION_MAX_LENGTH, and ADDRESS_MAX_LENGTH provide clear guidelines for data validation.

src/main/java/taco/klkl/global/common/constants/UserConstants.java (1)

6-6: Good practice: Making the class final.

Declaring the class as final prevents it from being subclassed, which is a good practice for utility classes.

src/main/resources/application-h2.yaml (1)

10-10: Verify the impact of MODE=MySQL.

The change introduces compatibility with MySQL syntax. Ensure that all SQL queries are compatible with MySQL mode and test thoroughly.

src/main/java/taco/klkl/domain/product/dto/request/ProductUpdateRequestDto.java (2)

3-6: LGTM!

The import statements are correct and necessary for the validation annotations and constants used in the record.


9-26: LGTM!

The validation annotations ensure data integrity by enforcing size and positivity constraints. The usage of constants for validation messages and sizes promotes maintainability.

src/main/java/taco/klkl/global/error/exception/ErrorCode.java (1)

13-15: LGTM!

The renaming of METHOD_NOT_ALLOWED to METHOD_NOT_SUPPORTED improves clarity. The addition of HTTP_MESSAGE_NOT_READABLE enhances error handling for invalid request message formats.

src/main/java/taco/klkl/global/common/constants/ProductValidationMessages.java (1)

1-23: LGTM!

The validation messages are clear and provide specific feedback for each field. The class is well-structured and final, preventing inheritance.

src/main/java/taco/klkl/domain/product/dto/request/ProductCreateRequestDto.java (8)

3-8: LGTM! Imports are necessary for the new validation annotations and constants.

The added import statements are appropriate and necessary for the new validation annotations and constants.


22-25: LGTM! Validation annotations for the name field are appropriate.

The @NotNull, @NotBlank, and @Size annotations ensure that the name field is not null, not blank, and within the specified size limit.


27-30: LGTM! Validation annotations for the description field are appropriate.

The @NotNull, @NotBlank, and @Size annotations ensure that the description field is not null, not blank, and within the specified size limit.


32-33: LGTM! Validation annotation for the address field is appropriate.

The @Size annotation ensures that the address field is within the specified size limit.


35-36: LGTM! Validation annotation for the price field is appropriate.

The @PositiveOrZero annotation ensures that the price field is non-negative.


38-39: LGTM! Validation annotation for the cityId field is appropriate.

The @NotNull annotation ensures that the cityId field is not null.


41-42: LGTM! Validation annotation for the subcategoryId field is appropriate.

The @NotNull annotation ensures that the subcategoryId field is not null.


44-45: LGTM! Validation annotation for the currencyId field is appropriate.

The @NotNull annotation ensures that the currencyId field is not null.

src/main/java/taco/klkl/domain/product/service/ProductService.java (4)

10-14: LGTM! Imports are necessary for the new methods and functionality.

The added import statements are appropriate and necessary for the new methods and functionality.


25-26: LGTM! Use of final keyword enhances code clarity and immutability.

The final keyword for the parameter and the local variable ensures that these values are not modified, enhancing code clarity and immutability.


31-34: LGTM! createProduct method is appropriate for creating new products.

The @Transactional annotation ensures that the method performs write operations within a transaction.


38-43: LGTM! updateProduct method is appropriate for updating existing products.

The @Transactional annotation ensures that the method performs write operations within a transaction.

src/main/java/taco/klkl/domain/product/controller/ProductController.java (3)

Line range hint 6-18:
LGTM! Imports are necessary for the new endpoint and enhanced validation.

The added import statements are appropriate and necessary for the new endpoint and enhanced validation.


39-41: LGTM! @Valid annotation enhances validation for the createProduct method.

The @Valid annotation ensures that the incoming product creation requests are validated according to the constraints defined in the DTO.


46-54: LGTM! updateProduct method is appropriate for updating product information.

The @Valid annotation ensures that the input is validated according to the constraints defined in the DTO.

src/test/java/taco/klkl/domain/product/integration/ProductIntegrationTest.java (2)

45-49: Verify the new parameters in ProductCreateRequestDto.

Ensure that the new parameters ("address" and 1000) align with the expected input format for product creation.


78-82: Verify the new parameters in ProductCreateRequestDto.

Ensure that the new parameters ("address" and 1000) align with the expected input format for product creation.

src/main/java/taco/klkl/domain/product/domain/Product.java (2)

39-94: LGTM! Improved maintainability and readability.

The use of constants from ProductConstants and DefaultConstants enhances maintainability and readability.


142-164: LGTM! New method for selective updates.

The new method update correctly updates the product properties based on the ProductUpdateRequestDto.

src/test/java/taco/klkl/domain/product/dto/request/ProductUpdateRequestDtoTest.java (5)

30-39: LGTM! Clearer method naming.

The method validProductUpdateRequestDto provides a clearer description of its purpose and correctly validates a ProductUpdateRequestDto with all valid fields.


46-65: LGTM! Enhanced validation for product name length.

The new parameterized test productNameExceedsMaxLength correctly validates the maximum length constraint for the product name and provides meaningful error messages.


67-86: LGTM! Enhanced validation for product description length.

The new parameterized test productDescriptionExceedsMaxLength correctly validates the maximum length constraint for the product description and provides meaningful error messages.


88-107: LGTM! Enhanced validation for address length.

The new parameterized test addressExceedsMaxLength correctly validates the maximum length constraint for the address and provides meaningful error messages.


109-126: LGTM! Enhanced validation for non-negative price.

The new parameterized test negativePrice correctly validates that the price cannot be negative and provides meaningful error messages.

src/main/java/taco/klkl/global/error/GlobalExceptionHandler.java (4)

Line range hint 27-50: LGTM! Improved error reporting for method argument validation.

The changes enhance the clarity of the error responses by collecting all field errors and constructing a comprehensive error message.


Line range hint 62-66: LGTM! Corrected error code for HTTP method not supported.

The change aligns the error handling with more accurate HTTP semantics.


83-95: LGTM! Added structured error handling for unreadable HTTP messages.

The new method provides consistent and informative feedback for HttpMessageNotReadableException.


Line range hint 96-104: LGTM! Structured error handling for custom exceptions.

The method provides consistent and informative feedback for CustomException.

src/test/java/taco/klkl/domain/product/domain/ProductTest.java (4)

Line range hint 80-104: LGTM! Updated display name for price handling.

The change aligns the display name with the intended data type for price handling.


107-142: LGTM! Comprehensive test for updating product information.

The test ensures that all product attributes are correctly updated when provided with a complete ProductUpdateRequestDto.


144-179: LGTM! Test for partial update of product information.

The test ensures that the product retains its original values for any attributes that are not included in the update request, while still updating the fields that are provided.


181-215: LGTM! Test for ignoring null values during product update.

The test ensures that when all fields in the update DTO are null, the product remains unchanged.

src/test/java/taco/klkl/domain/product/service/ProductServiceTest.java (2)

157-200: LGTM! Test for successful product update.

The test sets up a mock product repository to return an existing product when queried by its ID and verifies that the update logic functions correctly.


202-227: LGTM! Test for product update failure when product not found.

The test verifies that a ProductNotFoundException is thrown when the product ID is not found in the repository.

src/test/java/taco/klkl/global/error/GlobalExceptionHandlerTest.java (1)

120-143: LGTM!

The new test method httpMessageNotReadableOccurred is correctly implemented and ensures that the HttpMessageNotReadableException is handled as expected.

src/test/java/taco/klkl/domain/product/dto/request/ProductCreateRequestDtoTest.java (10)

30-42: LGTM!

The test method validProductCreateRequestDto is correctly implemented and verifies that a valid ProductCreateRequestDto passes validation.


47-64: LGTM!

The test method nullProductName is correctly implemented and verifies that a ProductCreateRequestDto with a null product name fails validation with the appropriate message.


68-86: LGTM!

The test method emptyProductName is correctly implemented and verifies that a ProductCreateRequestDto with an empty product name fails validation with the appropriate message.


88-105: LGTM!

The parameterized test method productNameExceedsMaxLength is correctly implemented and verifies that a ProductCreateRequestDto with a product name that exceeds the maximum length fails validation with the appropriate message.


109-126: LGTM!

The test method nullProductDescription is correctly implemented and verifies that a ProductCreateRequestDto with a null product description fails validation with the appropriate message.


130-148: LGTM!

The test method emptyProductDescription is correctly implemented and verifies that a ProductCreateRequestDto with an empty product description fails validation with the appropriate message.


150-167: LGTM!

The parameterized test method productDescriptionExceedsMaxLength is correctly implemented and verifies that a ProductCreateRequestDto with a product description that exceeds the maximum length fails validation with the appropriate message.


170-188: LGTM!

The parameterized test method addressExceedsMaxLength is correctly implemented and verifies that a ProductCreateRequestDto with an address that exceeds the maximum length fails validation with the appropriate message.


190-206: LGTM!

The parameterized test method negativePrice is correctly implemented and verifies that a ProductCreateRequestDto with a negative price fails validation with the appropriate message.


210-260: LGTM!

The test methods nullCityId, nullSubcategoryId, and nullCurrencyId are correctly implemented and verify that a ProductCreateRequestDto with null values for cityId, subcategoryId, and currencyId, respectively, fail validation with the appropriate messages.

src/test/java/taco/klkl/domain/product/controller/ProductControllerTest.java (4)

Line range hint 5-29:
LGTM!

The new imports for ProductUpdateRequestDto and eq matcher are correctly added. The setup method initializes mock objects for User and Product appropriately.


98-106: LGTM!

The test method testCreateProduct is correctly implemented and verifies that the product creation endpoint works as expected with valid data.


129-154: LGTM!

The test method testCreateProductValidationFailure is correctly implemented and verifies that the product creation endpoint returns the appropriate validation errors for invalid data.


156-192: LGTM!

The test method testUpdateProduct is correctly implemented and verifies that the product update endpoint works as expected with valid data.

Copy link

@min3m min3m left a comment

Choose a reason for hiding this comment

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

ν•΄λ‹Ή λ„λ©”μΈμ—μ„œ κ³΅ν†΅μ μœΌλ‘œ μ‚¬μš©λ˜λŠ” 값듀을 μƒμˆ˜λ‘œ κ΄€λ¦¬ν•˜λŠ” 방법은 μ’‹μ•„λ³΄μž…λ‹ˆλ‹€!!! λ˜ν•œ νŠΈλžœμž­μ…˜ 관리 μ–΄λ–»κ²Œ ν•΄μ•Όν•˜λ‚˜ κ³ λ―Όμ€‘μ΄μ—ˆλŠ”λ° 덕뢄에 방법을 λ°°μ›Œκ°„ 것 κ°™μŠ΅λ‹ˆλ‹€~ κ³ μƒν•˜μ…¨μ–΄μš”!

Copy link
Contributor

@idealflower-k idealflower-k left a comment

Choose a reason for hiding this comment

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

JpaRepositoryκ°€ μ—”ν‹°ν‹° 객체의 변경을 κ°μ§€ν•˜κ³  λͺ…μ‹œμ μΈ save()호좜 없이 dbμ μš©κ°€λŠ₯ν•œ 점을 μ•Œ 수 μžˆμ—ˆμŠ΅λ‹ˆλ‹€!
κ³ μƒν•˜μ…¨μŠ΅λ‹ˆλ‹€! :)

@ohhamma ohhamma merged commit 05b6ece into develop Aug 1, 2024
2 checks passed
@ohhamma ohhamma deleted the KL-68/μƒν’ˆ-정보-μˆ˜μ •-api-κ΅¬ν˜„ branch August 1, 2024 05:25
@ohhamma ohhamma removed the βœ… Test ν…ŒμŠ€νŠΈ κ΄€λ ¨ label Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature μƒˆλ‘œμš΄ κΈ°λŠ₯ 개발 및 μš”μ²­
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants