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

Feature/product testcode #57

Merged
merged 19 commits into from
Jan 17, 2024

Conversation

HyunJunSon
Copy link
Collaborator

๐Ÿ’ก Motivation and Context

  • product testCode ์ž‘์„ฑ
  • fixture Monkey library ์ ์šฉ
  • Id ๊ฐ’ Integer -> Long ํƒ€์ž… ๋ณ€๊ฒฝ
  • ๋ฐฐ์น˜์ฝ”๋“œ ์ถ”๊ฐ€์— ๋”ฐ๋ฅธ ๋„์ปค์ปดํฌ์ฆˆ ์ด๋ฏธ์ง€ ์ถ”๊ฐ€

๐Ÿ”จ Modified

์—ฌ๊ธฐ์— ๋ฌด์—‡์ด ํฌ๊ฒŒ ๋ฐ”๋€Œ์—ˆ๋Š”์ง€ ์„ค๋ช…ํ•ด ์ฃผ์„ธ์š”

  • ์—ฌ๊ธฐ์— ์„ธ๋ถ€ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”

๐ŸŒŸ More

  • ์—ฌ๊ธฐ์— PR ์ดํ›„ ์ถ”๊ฐ€๋กœ ํ•ด์•ผ ํ•  ์ผ์— ๋Œ€ํ•ด์„œ ์„ค๋ช…ํ•ด ์ฃผ์„ธ์š”

  • ๋งˆ์ดํŽ˜์ด์ง€, ๋ฉ”์ธํŽ˜์ด์ง€ ๋„๋ฉ”์ธ ์ฝ”๋“œ, ํ…Œ์ŠคํŠธ์ฝ”๋“œ ์ž‘์„ฑ



๐Ÿ“‹ ์ปค๋ฐ‹ ์ „ ์ฒดํฌ๋ฆฌ์ŠคํŠธ

  • [ใ…‡] ์ถ”๊ฐ€/๋ณ€๊ฒฝ์— ๋Œ€ํ•œ ๋‹จ์œ„ ํ…Œ์ŠคํŠธ๋ฅผ ์™„๋ฃŒํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • [ใ…‡] ์ปจ๋ฒค์…˜์— ๋งž๊ฒŒ ์ž‘์„ฑํ•˜์˜€์Šต๋‹ˆ๋‹ค.

๐ŸคŸ๐Ÿป PR๋กœ ์™„๋ฃŒ๋œ ์ด์Šˆ

closes #

HyunJunSon and others added 17 commits January 5, 2024 18:04
- flyway์— ์žˆ๋Š” create sequence๋ณด๋‹ค entity ์ฝ”๋“œ์— ์ž‘์„ฑํ•œ ์–ด๋…ธํ…Œ์ด์…˜์œผ๋กœ ์‹œํ€€์Šค๊ฐ€ ์ƒ์„ฑ๋˜๊ณ  ์žˆ๋Š” ํ˜„์ƒ ํ™•์ธํ•˜์—ฌ sql๋ฌธ ๋ณ€๊ฒฝ
  - ํ…Œ์ด๋ธ” ์ƒ์„ฑ ํ›„, ์‹œํ€€์Šค ๋ณ€๊ฒฝ sql ์ž‘์„ฑ ๋ฐฉ์‹
- sql์„ ๊ตฌ๋ถ„ํ•˜๋Š” ๊ฒŒ ์ข‹์„ ๊ฒƒ ๊ฐ™์•„ init ํŒŒ์ผ์—๋Š” ํ…Œ์ด๋ธ” ์ƒ์„ฑ ddl๋งŒ ๋‘๊ณ  ์‹œํ€€์Šค ๋ณ€๊ฒฝ ๋ฐ ์ดˆ๊ธฐ ๊ณตํ†ต์ฝ”๋“œ insert sql์€ ํŒŒ์ผ ๋ถ„๋ฆฌ
์ด์ œ ์—ฌ๊ธฐ์„œ ๋ฌธ์ž์—ด์„ ์•”ํ˜ธํ™” ํ•ด์„œ ๋ถ™์—ฌ๋„ฃ์œผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์ปค๋ฐ‹ํ•  ๋•Œ ์›๋ฌธ์ด ๋…ธ์ถœ๋˜์ง€ ์•Š์•˜๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”.
@HyunJunSon HyunJunSon added the ๐Ÿ’ก Feature ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ ์ถ”๊ฐ€, ํ˜น์€ ๊ตฌํ˜„ label Jan 15, 2024
@HyunJunSon HyunJunSon self-assigned this Jan 15, 2024
@@ -36,7 +37,7 @@ services:
# db-read:
# image: younglong/pg-washpedia:latest
# volumes:
# - postgreEditDB:/var/lib/postgresql/data
# - ./postgreEditDB:/var/lib/postgresql/data
# environment:
# POSTGRES_DB: read_db
# POSTGRES_USER: ${{ secrets.PROJECT_USER }}
Copy link

Choose a reason for hiding this comment

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

Based on the code patch you provided, here are some of the improvements and bug risks I can identify:

  1. The commented batch service image line (line 12) should be uncommented if you want to use a specific image. If you are using a custom image, make sure it is properly defined in the docker-compose.yml or specify it using the ${IMAGE} variable.

  2. Port mapping for the batch service (lines 14-15) seems to be incorrect. Port 8080 should be mapped to 8082 instead of mapping 8082 to 8080. Adjust it like this: - "8080:8082".

  3. Make sure the necessary dependencies (db-edit, db-read) are available when running the batch service. Verify that they are correctly specified in the depends_on section.

  4. For the db-read service (lines 35-37), check if the volume mapping is correct. It currently points to ./postgreEditDB, which may cause issues if the directory doesn't exist. Make sure the path is accurate, and the PostgreSQL data will be properly persisted.

Additionally, it would be helpful to review other parts of the codebase, including Dockerfile, environment variables, and any additional services or functionality not included in the given patch.

@@ -36,7 +36,7 @@ ResponseEntity<ProductDto> findProductById(@PathVariable("id") Long productId) {
.orElse(ResponseEntity.status(HttpStatus.NOT_FOUND).build());
}

@GetMapping("/products/")
@GetMapping("/products")
ResponseEntity<List<ProductDto>> findProductByKeyword(@RequestParam("keyword") String keyword){
final List<ProductDto> list = productService.getProductListByKeyword(keyword);

Copy link

Choose a reason for hiding this comment

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

The code patch you provided is quite small, but here are a few observations:

  1. In the "findProductById" method, it's generally good practice to return a more specific error response when a product is not found instead of a generic 404 status. You could consider returning a custom error message or using a more specific HTTP status code.

  2. In the "findProductByKeyword" method, consider adding validation for the keyword parameter. For example, you can check if the keyword is empty or null and handle such cases appropriately.

  3. It's generally recommended to use plural nouns for resource endpoints. So instead of "/products", you might consider using "/product".

  4. Make sure that the "getProductListByKeyword" method in the "productService" does proper error handling for exceptions or edge cases. For example, what happens if the keyword is not found or if an error occurs during the search.

Overall, without seeing the complete context or implementation details, it's difficult to identify any other potential issues or suggest further improvements. However, these points should give you some initial areas to consider for your code review.

@@ -22,7 +22,7 @@ public record ProductDto(Integer productNo,
) {

public static ProductDto of(
Integer productNo,
Long productNo,
String productName,
String barcode,
String description,
Copy link

Choose a reason for hiding this comment

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

Here are some observations and suggestions for your code patch:

  1. You changed the type of productNo from Integer to Long in the ProductDto record. Make sure this change aligns with the requirements and data types used throughout your application.

  2. Consider adding input validation checks in the of method parameters to ensure they are not null or empty if necessary. This can help prevent potential issues when creating instances of ProductDto.

  3. Verify that the new parameters added to the of method are correctly assigned to the corresponding fields of the ProductDto record. Ensure the order and variable names match appropriately.

  4. Double-check that the import statements at the top of your file are correct and necessary for the code you provided.

  5. Additionally, it would be helpful to review the rest of the code-base where the ProductDto record is being used, along with any methods that accept or return this DTO. Ensure consistency in handling the changes made to the ProductDto record.

Remember to also test your code changes thoroughly to catch any potential bugs or issues that may arise as a result of these modifications.

Copy link
Collaborator

@linglong67 linglong67 left a comment

Choose a reason for hiding this comment

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

์š”์•ฝ ๋ฐ ๋ง๋ถ™์ด์ž๋ฉด,

  1. PR์€ ์ œ๋ชฉ๊ณผ ๋‚ด์šฉ์ด ๋งค์น˜๊ฐ€ ์ž˜ ๋˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Œ
  2. fixture monkey ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋Š” LGTM!
  3. entity, dto ๋‚ด Integer โ†’ Long ์œผ๋กœ ๋ณ€๊ฒฝ๋œ ๋ถ€๋ถ„๋“ค์€ flyway๋กœ ์ปฌ๋Ÿผ ์ •๋ณด ์—…๋ฐ์ดํŠธ ํ•„์š”

์ž…๋‹ˆ๋‹ค..!
(๊ทผ๋ฐ์š”.. ์ปค๋ฐ‹ ์ด๋ ฅ์€ ์‚ด์ง ๊ผฌ์ธ๊ฑด๊ฐ€์š”..? ใ…‹ใ…‹ใ…‹)

Copy link
Collaborator

Choose a reason for hiding this comment

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

์ดํ›„์—๋Š” PR์„ ๊ตฌ๋ถ„ํ•ด์„œ ์˜ฌ๋ ค์ฃผ์‹œ๋Š” ๊ฒŒ ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”!
PR ๋ช…๊ณผ ๋‚ด๋ถ€ ์ž‘์—… ์‚ฌํ•ญ์ด ๋‹ค๋ฅธ ๋ถ€๋ถ„๋“ค์ด ์žˆ์–ด์„œ ๋‚˜์ค‘์— ์ด๋ ฅ ๊ด€๋ฆฌ๊ฐ€ ์–ด๋ ค์šธ ์ˆ˜๋„ ์žˆ์ง€ ์•Š์„๊นŒ์š”!?

Copy link
Collaborator

Choose a reason for hiding this comment

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

๋‚ด์šฉ์— ๋Œ€ํ•ด ๊ฐ„๋žตํ•˜๊ฒŒ ์„ค๋ช…ํ•ด์ฃผ์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”~
(์ด ์„ค์ •์ด ํ•„์š”ํ•˜๊ฒŒ ๋œ ์ด์œ ๋ž„๊นŒ์š”??)

Comment on lines 67 to 75
public Member toEntity(MemberDto memberDto) {
return Member.of(
this.memberNo,
this.id,
this.email,
this.password,
this.gender,
this.birthdate
memberDto.memberNo(),
memberDto.id(),
memberDto.email(),
memberDto.password(),
memberDto.gender(),
memberDto.birthdate()
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

์ด๊ฑฐ ์ด๋Œ€๋กœ๋ฉด memberDto.toEntity(memberDto) ๊ฐ™์€ ํ˜•ํƒœ๋กœ ํ˜ธ์ถœ๋˜๊ฒŒ ๋  ๊ฒƒ ๊ฐ™์€๋ฐ์š”
memberDto.toEntity() ํ˜•ํƒœ๊ฐ€ ๋” ๋‚˜์•„๋ณด์—ฌ์š”! (๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ ์˜๋ฏธ๊ฐ€ ์žˆ์„๊นŒ ์‹ถ์–ด์„œ์š”)

Copy link
Collaborator

Choose a reason for hiding this comment

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

ํ™•์ธํ•ด๋ดค๋Š”๋ฐ this๋กœ ๋ณด๋‚ด๋‚˜ memberDto๋กœ ๋ณด๋‚ด๋‚˜ ๋‘˜๋‹ค toEntity(memberDto)๋กœ ํ•ด์ค˜์•ผ๋ฉ๋‹ˆ๋‹ค.
ํšŒ์› ๊ฐ€์ž…, ๋กœ๊ทธ์ธ ๊ตฌํ˜„ํ•˜๋Š” ๋™์•ˆ์€ member์ •๋ณด๋ฅผ ํ†ต์œผ๋กœ ๋ฐ”์ธ๋”ฉ ํ•  ์ผ์ด ์—†์–ด์„œ toEntity๋ฅผ ์“ฐ์ง€ ์•Š์•˜๋Š”๋ฐ
์ด๋Ÿฐ ๊ณ ๋ฏผ์ด ์žˆ๊ฒ ๊ตฌ๋‚˜ ํ•˜๋Š”๊ฑธ ์ด์ œ์•ผ ์•Œ์•˜๋„ค์š”

Copy link
Collaborator

Choose a reason for hiding this comment

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

fixture monkey ์‚ฌ์šฉ ์˜ˆ์‹œ๊ฐ€ ์ƒ๊ฒจ์„œ ์ข‹๋„ค์š” ๐Ÿ‘
๋‹ค์Œ์— ํ•œ๋ฒˆ ๊ฐ„๋žตํ•˜๊ฒŒ ์„ค๋ช… ๋“ฃ๊ณ  ์‹ถ์–ด์š”!

Copy link
Collaborator

@chan99k chan99k left a comment

Choose a reason for hiding this comment

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

์ž˜ ์ฝ์—ˆ์Šต๋‹ˆ๋‹ค.
์—”ํ‹ฐํ‹ฐ์˜ Id ํƒ€์ž…์„ Long์œผ๋กœ ๋ณ€๊ฒฝํ•œ ๊ฒƒ ํ™•์ธํ–ˆ์–ด์š”. SERIAL ํƒ€์ž…์ด Integer์™€ Long์„ ๋ชจ๋‘ ์“ธ ์ˆ˜ ์žˆ๋Š” ๊ฑฐ๊ตฐ์š”. ๊ทธ๋Ÿฐ๋ฐ ๊ฒฐ๊ตญ ์ •์ˆ˜๋ฒ”์œ„ ๋•Œ๋ฌธ์— BIGSERIAL ๋กœ ๋ฐ”๊ฟ”์•ผ ํ•˜๋Š” ๊ฑฐ ์•„๋‹Œ๊ฐ€ ์‹ถ์Šต๋‹ˆ๋‹ค. flyway ์Šคํฌ๋ฆฝํŠธ๋กœ ํƒ€์ž… ๋ณ€๊ฒฝ์„ ํ•ด์•ผ ํ•  ๊ฑฐ ๊ฐ™์•„์š”.

image

# ports:
# - "8082:8080"
# - "8082:8082"
Copy link
Collaborator

Choose a reason for hiding this comment

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

๐Ÿ‘๐Ÿป

this.email(),
this.password(),
this.gender(),
this.birthdate()
);
}

Copy link

Choose a reason for hiding this comment

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

Overall, the code patch looks fine with a few suggestions for improvement:

  1. Data Type: The memberNo field in MemberDto has been changed from Integer to Long. Make sure this change is intentional and aligns with the data type in the Member entity.

  2. Redundant Parameters: In the of method of MemberDto, you can remove the parameters memberNo and memberDto, as they are not used within the method.

  3. Method Naming: Instead of having toEntity() accept a MemberDto parameter, it can directly access the fields of the current object. You can omit the parameter and modify the method to public Member toEntity(). This aligns with how other methods are written.

  4. Code Formatting: Ensure consistent indentation and formatting throughout the code. It helps with readability.

Besides these suggestions, ensure that the changes made match the requirements of your application, as I can only provide general code review suggestions based on the given information.

@@ -36,7 +36,7 @@ ResponseEntity<ProductDto> findProductById(@PathVariable("id") Long productId) {
.orElse(ResponseEntity.status(HttpStatus.NOT_FOUND).build());
}

@GetMapping("/products/")
@GetMapping("/products/search")
ResponseEntity<List<ProductDto>> findProductByKeyword(@RequestParam("keyword") String keyword){
final List<ProductDto> list = productService.getProductListByKeyword(keyword);

Copy link

Choose a reason for hiding this comment

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

Based on the provided code patch, here's a brief code review:

  1. In the findProductById method, the response is handled well by returning ResponseEntity.status(HttpStatus.NOT_FOUND).build() when the product is not found. This ensures that a proper HTTP 404 Not Found response is returned.

  2. In the findProductByKeyword method, the endpoint URL has been changed from /products/ to /products/search. This change is appropriate if the intention is to have a separate endpoint for searching products instead of retrieving all products.

  3. It would be helpful to add validation checks for the keyword parameter in the findProductByKeyword method. Depending on the requirements, you might want to consider handling scenarios where the keyword is empty or null.

  4. Consider using a pagination mechanism (if applicable) for fetching the list of products. Retrieving all products at once can lead to performance issues if there are a large number of products in the database.

  5. Ensure that the underlying productService.getProductListByKeyword(keyword) method is implemented correctly and efficiently. Verify if any additional error handling or data validation is required within that method.

  6. Overall, it's difficult to spot bugs or provide specific improvement suggestions without seeing the complete codebase. A more thorough review may be necessary to identify any potential risks or areas for improvement.

Remember to also consider best practices related to security, exception handling, logging, and testing based on your project requirements.

Copy link
Collaborator

@chan99k chan99k left a comment

Choose a reason for hiding this comment

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

LGTM. ์งˆ๋ฌธ ๋‚จ๊ฒผ์Šต๋‹ˆ๋‹ค

@BeforeEach
void ์ค€๋น„(WebApplicationContext webApplicationContext) {
fixtureMonkey = FixtureMonkey.builder()
.objectIntrospector(new FailoverIntrospector(
Copy link
Collaborator

Choose a reason for hiding this comment

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

objectIntrospector ์™€ FailoverIntrospector ๊ฐ€ ์–ด๋–ค ์—ญํ• ์„ ํ•˜๋‚˜์š”?

Copy link
Collaborator

Choose a reason for hiding this comment

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

๋„ค์ด๋ฐ ์ถ”์ธก๋งŒ ๋ณด๋ฉด ์ „์ž๋Š” ๊ฐ์ฒด์ƒ์„ฑ์ค€๋น„์ž๊ฐ™๊ณ  ํ›„์ž๋Š” ์‹คํŒจ๊ฐ’์ด ๋–จ์–ด์งˆ๋•Œ๊นŒ์ง€ ๋งŒ๋“ค์–ด์ฃผ๋Š” ์ƒ์„ฑ์ž? ๊ฐ™์€๊ฑฐ ๊ฐ™๋„ค์š”

Comment on lines +49 to +52
FieldReflectionArbitraryIntrospector.INSTANCE,
ConstructorPropertiesArbitraryIntrospector.INSTANCE,
BeanArbitraryIntrospector.INSTANCE,
BuilderArbitraryIntrospector.INSTANCE
Copy link
Collaborator

Choose a reason for hiding this comment

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

๊ฐ๊ฐ์˜ Introspector ๊ฐ€ ์–ด๋–ค ์—ญํ• ์„ ํ•˜๋Š”์ง€ ์•Œ๋ ค์ฃผ์‹ค ์ˆ˜ ์žˆ๋‚˜์š”

Copy link
Collaborator

@gunsight1 gunsight1 left a comment

Choose a reason for hiding this comment

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

๊ณ ์ƒํ•˜์…จ์Šต๋‹ˆ๋‹ค ์ถ”ํ›„ PR์— flyway ํŒŒ์ผ ํ•˜๋‚˜ ์ถ”๊ฐ€ํ•˜์—ฌ์„œ ํ…Œ์ด๋ธ” ์ปฌ๋Ÿผ๋“ค์˜ ๋Œ€ํ•œ serial4 -> serial8๊นŒ์ง€ ์ถ”๊ฐ€ํ•ด์ฃผ์‹œ๋ฉด ๊ฐ์‚ฌํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค

@gunsight1 gunsight1 merged commit 3db1964 into Kernel360:develop Jan 17, 2024
1 check passed
@HyunJunSon HyunJunSon deleted the feature/product_testcode branch January 17, 2024 05:48
This pull request was closed.
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.

4 participants