From 9659e527a34fc45db937db4afffe3070f3207d89 Mon Sep 17 00:00:00 2001 From: Sehee-Lee-01 Date: Sun, 18 Feb 2024 19:01:25 +0900 Subject: [PATCH 01/12] =?UTF-8?q?rename:=20user=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20dto=20=EB=A6=AC=ED=8C=A8=ED=82=A4=EC=A7=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sidepeek_backend_secret | 2 +- .../sixgaezzang/sidepeek/users/controller/UserController.java | 4 ++-- .../sidepeek/users/dto/{ => request}/SignUpRequest.java | 2 +- .../sidepeek/users/dto/{ => response}/UserSearchResponse.java | 2 +- .../users/dto/{ => response}/UserSummaryResponse.java | 2 +- .../java/sixgaezzang/sidepeek/users/service/UserService.java | 4 ++-- .../sixgaezzang/sidepeek/users/service/UserServiceTest.java | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) rename src/main/java/sixgaezzang/sidepeek/users/dto/{ => request}/SignUpRequest.java (94%) rename src/main/java/sixgaezzang/sidepeek/users/dto/{ => response}/UserSearchResponse.java (89%) rename src/main/java/sixgaezzang/sidepeek/users/dto/{ => response}/UserSummaryResponse.java (90%) diff --git a/sidepeek_backend_secret b/sidepeek_backend_secret index 99b3931e..c4f4aea0 160000 --- a/sidepeek_backend_secret +++ b/sidepeek_backend_secret @@ -1 +1 @@ -Subproject commit 99b3931ea3c2986756a4414b0061973b739a9668 +Subproject commit c4f4aea01cbc97e9cf99f1d098b35bbc446c83f3 diff --git a/src/main/java/sixgaezzang/sidepeek/users/controller/UserController.java b/src/main/java/sixgaezzang/sidepeek/users/controller/UserController.java index 5d7a4313..d432d293 100644 --- a/src/main/java/sixgaezzang/sidepeek/users/controller/UserController.java +++ b/src/main/java/sixgaezzang/sidepeek/users/controller/UserController.java @@ -18,8 +18,8 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.support.ServletUriComponentsBuilder; import sixgaezzang.sidepeek.users.domain.Provider; -import sixgaezzang.sidepeek.users.dto.SignUpRequest; -import sixgaezzang.sidepeek.users.dto.UserSearchResponse; +import sixgaezzang.sidepeek.users.dto.request.SignUpRequest; +import sixgaezzang.sidepeek.users.dto.response.UserSearchResponse; import sixgaezzang.sidepeek.users.service.UserService; @RestController diff --git a/src/main/java/sixgaezzang/sidepeek/users/dto/SignUpRequest.java b/src/main/java/sixgaezzang/sidepeek/users/dto/request/SignUpRequest.java similarity index 94% rename from src/main/java/sixgaezzang/sidepeek/users/dto/SignUpRequest.java rename to src/main/java/sixgaezzang/sidepeek/users/dto/request/SignUpRequest.java index 28101570..f0cf99c8 100644 --- a/src/main/java/sixgaezzang/sidepeek/users/dto/SignUpRequest.java +++ b/src/main/java/sixgaezzang/sidepeek/users/dto/request/SignUpRequest.java @@ -1,4 +1,4 @@ -package sixgaezzang.sidepeek.users.dto; +package sixgaezzang.sidepeek.users.dto.request; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotBlank; diff --git a/src/main/java/sixgaezzang/sidepeek/users/dto/UserSearchResponse.java b/src/main/java/sixgaezzang/sidepeek/users/dto/response/UserSearchResponse.java similarity index 89% rename from src/main/java/sixgaezzang/sidepeek/users/dto/UserSearchResponse.java rename to src/main/java/sixgaezzang/sidepeek/users/dto/response/UserSearchResponse.java index 65bf278f..1a63d937 100644 --- a/src/main/java/sixgaezzang/sidepeek/users/dto/UserSearchResponse.java +++ b/src/main/java/sixgaezzang/sidepeek/users/dto/response/UserSearchResponse.java @@ -1,4 +1,4 @@ -package sixgaezzang.sidepeek.users.dto; +package sixgaezzang.sidepeek.users.dto.response; import java.util.List; import sixgaezzang.sidepeek.users.domain.User; diff --git a/src/main/java/sixgaezzang/sidepeek/users/dto/UserSummaryResponse.java b/src/main/java/sixgaezzang/sidepeek/users/dto/response/UserSummaryResponse.java similarity index 90% rename from src/main/java/sixgaezzang/sidepeek/users/dto/UserSummaryResponse.java rename to src/main/java/sixgaezzang/sidepeek/users/dto/response/UserSummaryResponse.java index 5a18df54..ff0b7d6f 100644 --- a/src/main/java/sixgaezzang/sidepeek/users/dto/UserSummaryResponse.java +++ b/src/main/java/sixgaezzang/sidepeek/users/dto/response/UserSummaryResponse.java @@ -1,4 +1,4 @@ -package sixgaezzang.sidepeek.users.dto; +package sixgaezzang.sidepeek.users.dto.response; import lombok.Builder; import sixgaezzang.sidepeek.users.domain.User; diff --git a/src/main/java/sixgaezzang/sidepeek/users/service/UserService.java b/src/main/java/sixgaezzang/sidepeek/users/service/UserService.java index bb26c444..aaa3606d 100644 --- a/src/main/java/sixgaezzang/sidepeek/users/service/UserService.java +++ b/src/main/java/sixgaezzang/sidepeek/users/service/UserService.java @@ -11,8 +11,8 @@ import sixgaezzang.sidepeek.users.domain.Password; import sixgaezzang.sidepeek.users.domain.Provider; import sixgaezzang.sidepeek.users.domain.User; -import sixgaezzang.sidepeek.users.dto.SignUpRequest; -import sixgaezzang.sidepeek.users.dto.UserSearchResponse; +import sixgaezzang.sidepeek.users.dto.request.SignUpRequest; +import sixgaezzang.sidepeek.users.dto.response.UserSearchResponse; import sixgaezzang.sidepeek.users.repository.UserRepository; @Service diff --git a/src/test/java/sixgaezzang/sidepeek/users/service/UserServiceTest.java b/src/test/java/sixgaezzang/sidepeek/users/service/UserServiceTest.java index 31f38c4b..abbc2160 100644 --- a/src/test/java/sixgaezzang/sidepeek/users/service/UserServiceTest.java +++ b/src/test/java/sixgaezzang/sidepeek/users/service/UserServiceTest.java @@ -19,7 +19,7 @@ import sixgaezzang.sidepeek.users.domain.Password; import sixgaezzang.sidepeek.users.domain.Provider; import sixgaezzang.sidepeek.users.domain.User; -import sixgaezzang.sidepeek.users.dto.SignUpRequest; +import sixgaezzang.sidepeek.users.dto.request.SignUpRequest; import sixgaezzang.sidepeek.users.repository.UserRepository; @SpringBootTest From dfb64d5a51aaa92f591965ca13752fabc943b60c Mon Sep 17 00:00:00 2001 From: Sehee-Lee-01 Date: Sun, 18 Feb 2024 19:01:48 +0900 Subject: [PATCH 02/12] =?UTF-8?q?rename:=20user=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20dto=20=EB=A6=AC=ED=8C=A8=ED=82=A4=EC=A7=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/sixgaezzang/sidepeek/users/service/UserService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/sixgaezzang/sidepeek/users/service/UserService.java b/src/main/java/sixgaezzang/sidepeek/users/service/UserService.java index aaa3606d..b8525e75 100644 --- a/src/main/java/sixgaezzang/sidepeek/users/service/UserService.java +++ b/src/main/java/sixgaezzang/sidepeek/users/service/UserService.java @@ -1,6 +1,6 @@ package sixgaezzang.sidepeek.users.service; -import static sixgaezzang.sidepeek.common.ValidationUtils.validateMaxLength; +import static sixgaezzang.sidepeek.common.util.ValidationUtils.validateMaxLength; import jakarta.persistence.EntityExistsException; import java.util.Objects; From 4eef0d8f8cefa587d96e044c7889340effe15fdb Mon Sep 17 00:00:00 2001 From: Sehee-Lee-01 Date: Sun, 18 Feb 2024 19:02:41 +0900 Subject: [PATCH 03/12] =?UTF-8?q?rename:=20skill=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20dto=20=EB=A6=AC=ED=8C=A8=ED=82=A4=EC=A7=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sidepeek/skill/controller/SkillController.java | 2 +- .../sidepeek/skill/dto/{ => response}/SkillResponse.java | 2 +- .../skill/dto/{ => response}/SkillSearchResponse.java | 2 +- .../java/sixgaezzang/sidepeek/skill/serivce/SkillService.java | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) rename src/main/java/sixgaezzang/sidepeek/skill/dto/{ => response}/SkillResponse.java (89%) rename src/main/java/sixgaezzang/sidepeek/skill/dto/{ => response}/SkillSearchResponse.java (89%) diff --git a/src/main/java/sixgaezzang/sidepeek/skill/controller/SkillController.java b/src/main/java/sixgaezzang/sidepeek/skill/controller/SkillController.java index e4f1cdb3..5024a70a 100644 --- a/src/main/java/sixgaezzang/sidepeek/skill/controller/SkillController.java +++ b/src/main/java/sixgaezzang/sidepeek/skill/controller/SkillController.java @@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import sixgaezzang.sidepeek.skill.dto.SkillSearchResponse; +import sixgaezzang.sidepeek.skill.dto.response.SkillSearchResponse; import sixgaezzang.sidepeek.skill.serivce.SkillService; @RestController diff --git a/src/main/java/sixgaezzang/sidepeek/skill/dto/SkillResponse.java b/src/main/java/sixgaezzang/sidepeek/skill/dto/response/SkillResponse.java similarity index 89% rename from src/main/java/sixgaezzang/sidepeek/skill/dto/SkillResponse.java rename to src/main/java/sixgaezzang/sidepeek/skill/dto/response/SkillResponse.java index 4f929186..44ee4bab 100644 --- a/src/main/java/sixgaezzang/sidepeek/skill/dto/SkillResponse.java +++ b/src/main/java/sixgaezzang/sidepeek/skill/dto/response/SkillResponse.java @@ -1,4 +1,4 @@ -package sixgaezzang.sidepeek.skill.dto; +package sixgaezzang.sidepeek.skill.dto.response; import lombok.Builder; import sixgaezzang.sidepeek.skill.domain.Skill; diff --git a/src/main/java/sixgaezzang/sidepeek/skill/dto/SkillSearchResponse.java b/src/main/java/sixgaezzang/sidepeek/skill/dto/response/SkillSearchResponse.java similarity index 89% rename from src/main/java/sixgaezzang/sidepeek/skill/dto/SkillSearchResponse.java rename to src/main/java/sixgaezzang/sidepeek/skill/dto/response/SkillSearchResponse.java index 9aa750f6..7ed072b0 100644 --- a/src/main/java/sixgaezzang/sidepeek/skill/dto/SkillSearchResponse.java +++ b/src/main/java/sixgaezzang/sidepeek/skill/dto/response/SkillSearchResponse.java @@ -1,4 +1,4 @@ -package sixgaezzang.sidepeek.skill.dto; +package sixgaezzang.sidepeek.skill.dto.response; import java.util.List; import sixgaezzang.sidepeek.skill.domain.Skill; diff --git a/src/main/java/sixgaezzang/sidepeek/skill/serivce/SkillService.java b/src/main/java/sixgaezzang/sidepeek/skill/serivce/SkillService.java index b8172557..32ee0689 100644 --- a/src/main/java/sixgaezzang/sidepeek/skill/serivce/SkillService.java +++ b/src/main/java/sixgaezzang/sidepeek/skill/serivce/SkillService.java @@ -1,12 +1,12 @@ package sixgaezzang.sidepeek.skill.serivce; -import static sixgaezzang.sidepeek.common.ValidationUtils.validateMaxLength; +import static sixgaezzang.sidepeek.common.util.ValidationUtils.validateMaxLength; import java.util.Objects; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import sixgaezzang.sidepeek.skill.dto.SkillSearchResponse; +import sixgaezzang.sidepeek.skill.dto.response.SkillSearchResponse; import sixgaezzang.sidepeek.skill.repository.SkillRepository; @Service From fdcbd122aa9ff2f0a85188d7dacee72f8e860d7c Mon Sep 17 00:00:00 2001 From: Sehee-Lee-01 Date: Sun, 18 Feb 2024 19:19:07 +0900 Subject: [PATCH 04/12] =?UTF-8?q?feat:=20skill=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EC=8A=A4=EC=9B=A8=EA=B1=B0=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EC=84=A4=EB=AA=85=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sidepeek/skill/controller/SkillController.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/sixgaezzang/sidepeek/skill/controller/SkillController.java b/src/main/java/sixgaezzang/sidepeek/skill/controller/SkillController.java index 5024a70a..e4947580 100644 --- a/src/main/java/sixgaezzang/sidepeek/skill/controller/SkillController.java +++ b/src/main/java/sixgaezzang/sidepeek/skill/controller/SkillController.java @@ -1,5 +1,8 @@ package sixgaezzang.sidepeek.skill.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; import jakarta.validation.constraints.Size; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; @@ -18,6 +21,9 @@ public class SkillController { private final SkillService skillService; @GetMapping + @Operation(summary = "기술 스택 검색") + @ApiResponse(responseCode = "200", description = "기술 스택 검색 성공") + @Parameter(name = "keyword", description = "검색어", example = "spring") public ResponseEntity searchByName( @RequestParam(required = false) @Size(max = 50, message = "최대 50자의 키워드로 검색할 수 있습니다.") From c5b7c494369d28a7e33d18735f0bd1459ab1bc13 Mon Sep 17 00:00:00 2001 From: Sehee-Lee-01 Date: Sun, 18 Feb 2024 19:19:20 +0900 Subject: [PATCH 05/12] =?UTF-8?q?feat:=20user=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EC=8A=A4=EC=9B=A8=EA=B1=B0=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EC=84=A4=EB=AA=85=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sixgaezzang/sidepeek/users/controller/UserController.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/sixgaezzang/sidepeek/users/controller/UserController.java b/src/main/java/sixgaezzang/sidepeek/users/controller/UserController.java index d432d293..8e49aead 100644 --- a/src/main/java/sixgaezzang/sidepeek/users/controller/UserController.java +++ b/src/main/java/sixgaezzang/sidepeek/users/controller/UserController.java @@ -49,6 +49,9 @@ public ResponseEntity signUp(@RequestBody @Valid SignUpRequest request) { } @GetMapping + @Operation(summary = "회원 검색") + @ApiResponse(responseCode = "200", description = "회원 검색 성공") + @Parameter(name = "keyword", description = "검색어", example = "sixgaezzang6") public ResponseEntity searchByNickname( @RequestParam(required = false) @Size(max = 20, message = "최대 20자의 키워드로 검색할 수 있습니다.") From 50598ff600b34d55e10acfd0e8cd928c709a58ca Mon Sep 17 00:00:00 2001 From: Sehee-Lee-01 Date: Sun, 18 Feb 2024 19:25:01 +0900 Subject: [PATCH 06/12] =?UTF-8?q?refactor:=20=EB=B6=84=EC=82=B0=EB=90=9C?= =?UTF-8?q?=20=EC=83=81=EC=88=98=20=ED=86=B5=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sidepeek/skill/controller/SkillController.java | 4 +++- src/main/java/sixgaezzang/sidepeek/skill/domain/Skill.java | 4 +++- .../sixgaezzang/sidepeek/skill/serivce/SkillService.java | 7 +++---- .../sidepeek/users/controller/UserController.java | 4 +++- src/main/java/sixgaezzang/sidepeek/users/domain/User.java | 2 +- .../sixgaezzang/sidepeek/users/service/UserService.java | 7 +++---- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/sixgaezzang/sidepeek/skill/controller/SkillController.java b/src/main/java/sixgaezzang/sidepeek/skill/controller/SkillController.java index e4947580..2e1619ca 100644 --- a/src/main/java/sixgaezzang/sidepeek/skill/controller/SkillController.java +++ b/src/main/java/sixgaezzang/sidepeek/skill/controller/SkillController.java @@ -1,5 +1,7 @@ package sixgaezzang.sidepeek.skill.controller; +import static sixgaezzang.sidepeek.skill.domain.Skill.MAX_SKILL_NAME_LENGTH; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -26,7 +28,7 @@ public class SkillController { @Parameter(name = "keyword", description = "검색어", example = "spring") public ResponseEntity searchByName( @RequestParam(required = false) - @Size(max = 50, message = "최대 50자의 키워드로 검색할 수 있습니다.") + @Size(max = MAX_SKILL_NAME_LENGTH, message = "최대 " + MAX_SKILL_NAME_LENGTH + "자의 키워드로 검색할 수 있습니다.") String keyword ) { return ResponseEntity.ok() diff --git a/src/main/java/sixgaezzang/sidepeek/skill/domain/Skill.java b/src/main/java/sixgaezzang/sidepeek/skill/domain/Skill.java index 3d8ee9ca..a7bf0988 100644 --- a/src/main/java/sixgaezzang/sidepeek/skill/domain/Skill.java +++ b/src/main/java/sixgaezzang/sidepeek/skill/domain/Skill.java @@ -16,11 +16,13 @@ @Getter public class Skill { + public static final int MAX_SKILL_NAME_LENGTH = 50; + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Column(name = "name", nullable = false, length = 50) + @Column(name = "name", nullable = false, length = MAX_SKILL_NAME_LENGTH) private String name; @Column(name = "icon_image_url", nullable = false, columnDefinition = "TEXT") diff --git a/src/main/java/sixgaezzang/sidepeek/skill/serivce/SkillService.java b/src/main/java/sixgaezzang/sidepeek/skill/serivce/SkillService.java index 32ee0689..8e9e3090 100644 --- a/src/main/java/sixgaezzang/sidepeek/skill/serivce/SkillService.java +++ b/src/main/java/sixgaezzang/sidepeek/skill/serivce/SkillService.java @@ -1,6 +1,7 @@ package sixgaezzang.sidepeek.skill.serivce; import static sixgaezzang.sidepeek.common.util.ValidationUtils.validateMaxLength; +import static sixgaezzang.sidepeek.skill.domain.Skill.MAX_SKILL_NAME_LENGTH; import java.util.Objects; import lombok.RequiredArgsConstructor; @@ -14,8 +15,6 @@ @RequiredArgsConstructor public class SkillService { - public static final int KEYWORD_MAX_LENGTH = 50; - private final SkillRepository skillRepository; public SkillSearchResponse searchByName(String keyword) { @@ -23,8 +22,8 @@ public SkillSearchResponse searchByName(String keyword) { return SkillSearchResponse.from(skillRepository.findAll()); } - validateMaxLength(keyword, KEYWORD_MAX_LENGTH, - "최대 " + KEYWORD_MAX_LENGTH + "자의 키워드로 검색할 수 있습니다."); + validateMaxLength(keyword, MAX_SKILL_NAME_LENGTH, + "최대 " + MAX_SKILL_NAME_LENGTH + "자의 키워드로 검색할 수 있습니다."); return SkillSearchResponse.from(skillRepository.findAllByNameContaining(keyword)); } diff --git a/src/main/java/sixgaezzang/sidepeek/users/controller/UserController.java b/src/main/java/sixgaezzang/sidepeek/users/controller/UserController.java index 8e49aead..313a7a79 100644 --- a/src/main/java/sixgaezzang/sidepeek/users/controller/UserController.java +++ b/src/main/java/sixgaezzang/sidepeek/users/controller/UserController.java @@ -1,5 +1,7 @@ package sixgaezzang.sidepeek.users.controller; +import static sixgaezzang.sidepeek.users.domain.User.MAX_NICKNAME_LENGTH; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; @@ -54,7 +56,7 @@ public ResponseEntity signUp(@RequestBody @Valid SignUpRequest request) { @Parameter(name = "keyword", description = "검색어", example = "sixgaezzang6") public ResponseEntity searchByNickname( @RequestParam(required = false) - @Size(max = 20, message = "최대 20자의 키워드로 검색할 수 있습니다.") + @Size(max = MAX_NICKNAME_LENGTH, message = "최대 20자의 키워드로 검색할 수 있습니다.") String keyword ) { return ResponseEntity.ok() diff --git a/src/main/java/sixgaezzang/sidepeek/users/domain/User.java b/src/main/java/sixgaezzang/sidepeek/users/domain/User.java index 01ca24d3..db2bceb0 100644 --- a/src/main/java/sixgaezzang/sidepeek/users/domain/User.java +++ b/src/main/java/sixgaezzang/sidepeek/users/domain/User.java @@ -28,7 +28,7 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class User extends BaseTimeEntity { - private static final int MAX_NICKNAME_LENGTH = 20; + public static final int MAX_NICKNAME_LENGTH = 20; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/sixgaezzang/sidepeek/users/service/UserService.java b/src/main/java/sixgaezzang/sidepeek/users/service/UserService.java index b8525e75..3bb41950 100644 --- a/src/main/java/sixgaezzang/sidepeek/users/service/UserService.java +++ b/src/main/java/sixgaezzang/sidepeek/users/service/UserService.java @@ -1,6 +1,7 @@ package sixgaezzang.sidepeek.users.service; import static sixgaezzang.sidepeek.common.util.ValidationUtils.validateMaxLength; +import static sixgaezzang.sidepeek.users.domain.User.MAX_NICKNAME_LENGTH; import jakarta.persistence.EntityExistsException; import java.util.Objects; @@ -20,8 +21,6 @@ @RequiredArgsConstructor public class UserService { - private static final int KEYWORD_MAX_LENGTH = 20; - private final UserRepository userRepository; private final PasswordEncoder passwordEncoder; @@ -51,8 +50,8 @@ public UserSearchResponse searchByNickname(String keyword) { return UserSearchResponse.from(userRepository.findAll()); } - validateMaxLength(keyword, KEYWORD_MAX_LENGTH, - "최대 " + KEYWORD_MAX_LENGTH + "자의 키워드로 검색할 수 있습니다."); + validateMaxLength(keyword, MAX_NICKNAME_LENGTH, + "최대 " + MAX_NICKNAME_LENGTH + "자의 키워드로 검색할 수 있습니다."); return UserSearchResponse.from(userRepository.findAllByNicknameContaining(keyword)); } From 0197ad200e80d57565a50caf21f21ea16aee26b1 Mon Sep 17 00:00:00 2001 From: Sehee-Lee-01 Date: Sun, 18 Feb 2024 20:01:51 +0900 Subject: [PATCH 07/12] =?UTF-8?q?test:=20=ED=9A=8C=EC=9B=90=20=EB=8B=89?= =?UTF-8?q?=EB=84=A4=EC=9E=84=20=EA=B2=80=EC=83=89=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../users/service/UserServiceTest.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/test/java/sixgaezzang/sidepeek/users/service/UserServiceTest.java b/src/test/java/sixgaezzang/sidepeek/users/service/UserServiceTest.java index abbc2160..6f25637b 100644 --- a/src/test/java/sixgaezzang/sidepeek/users/service/UserServiceTest.java +++ b/src/test/java/sixgaezzang/sidepeek/users/service/UserServiceTest.java @@ -3,8 +3,10 @@ import static io.micrometer.common.util.StringUtils.isBlank; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; +import static sixgaezzang.sidepeek.users.domain.User.MAX_NICKNAME_LENGTH; import jakarta.persistence.EntityExistsException; +import java.util.List; import net.datafaker.Faker; import org.assertj.core.api.ThrowableAssert.ThrowingCallable; import org.junit.jupiter.api.BeforeEach; @@ -12,6 +14,9 @@ import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.NullAndEmptySource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.security.crypto.password.PasswordEncoder; @@ -20,6 +25,7 @@ import sixgaezzang.sidepeek.users.domain.Provider; import sixgaezzang.sidepeek.users.domain.User; import sixgaezzang.sidepeek.users.dto.request.SignUpRequest; +import sixgaezzang.sidepeek.users.dto.response.UserSummaryResponse; import sixgaezzang.sidepeek.users.repository.UserRepository; @SpringBootTest @@ -131,6 +137,59 @@ class 회원가입_테스트 { assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(signup) .withMessage("비밀번호는 8자 이상, 영문, 숫자, 특수문자를 포함해야 합니다."); } + + } + + @Nested + class 회원_닉네임_검색_테스트 { + + static final int USER_COUNT = 5; + static final String[] users = {"zzang1", "zzang2", "zzang3", "coco1", "coco2"}; + + @BeforeEach + void setUp() { + for (int i = 0; i < USER_COUNT; i++) { + User user = createUser(users[i] + "@google.com", password, users[i]); + userRepository.save(user); + } + } + + @ParameterizedTest(name = "[{index}] {0}으로 검색할 때 " + USER_COUNT + "명의 회원이 나온다.") + @NullAndEmptySource + void 검색어_없이_전체_회원_닉네임_검색에_성공한다(String keyword) { + // given, when + List users = userService.searchByNickname(keyword) + .users(); + + // then + assertThat(users.size()).isEqualTo(USER_COUNT); + } + + @ParameterizedTest(name = "[{index}] {0}으로 검색할 때 {1}명의 회원이 나온다.") + @CsvSource(value = {"zzang:3", "coco:2"}, delimiter = ':') + void 검색어로_회원_닉네임_검색에_성공한다(String keyword, int count) { + // given, when + List users = userService.searchByNickname(keyword) + .users(); + + // then + assertThat(users.size()).isEqualTo(count); + } + + @Test + void 닉네임_최대_글자_수가_넘어_회원_닉네임_검색에_실패한다() { + // given + int keywordLength = MAX_NICKNAME_LENGTH + 1; + String keyword = "a".repeat(keywordLength); + + // when + ThrowingCallable search = () -> userService.searchByNickname(keyword); + + // then + assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(search) + .withMessage("최대 " + MAX_NICKNAME_LENGTH + "자의 키워드로 검색할 수 있습니다."); + } + } private User createUser(String email, String password, String nickname) { From 8390d39ef1be24c893ea9a5215461c23b70d97f8 Mon Sep 17 00:00:00 2001 From: Sehee-Lee-01 Date: Sun, 18 Feb 2024 20:20:57 +0900 Subject: [PATCH 08/12] =?UTF-8?q?test:=20=ED=9A=8C=EC=9B=90=20=EB=8B=89?= =?UTF-8?q?=EB=84=A4=EC=9E=84=20=EA=B2=80=EC=83=89=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sixgaezzang/sidepeek/users/service/UserServiceTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/sixgaezzang/sidepeek/users/service/UserServiceTest.java b/src/test/java/sixgaezzang/sidepeek/users/service/UserServiceTest.java index 6f25637b..456129ff 100644 --- a/src/test/java/sixgaezzang/sidepeek/users/service/UserServiceTest.java +++ b/src/test/java/sixgaezzang/sidepeek/users/service/UserServiceTest.java @@ -154,7 +154,7 @@ void setUp() { } } - @ParameterizedTest(name = "[{index}] {0}으로 검색할 때 " + USER_COUNT + "명의 회원이 나온다.") + @ParameterizedTest(name = "[{index}] {0}으로 검색할 때 " + USER_COUNT + "명의 모든 회원이 나온다.") @NullAndEmptySource void 검색어_없이_전체_회원_닉네임_검색에_성공한다(String keyword) { // given, when @@ -177,7 +177,7 @@ void setUp() { } @Test - void 닉네임_최대_글자_수가_넘어_회원_닉네임_검색에_실패한다() { + void 검색어_최대_글자_수가_넘어_회원_닉네임_검색에_실패한다() { // given int keywordLength = MAX_NICKNAME_LENGTH + 1; String keyword = "a".repeat(keywordLength); From f12931da6976a473f00dcd664c5ad405cf3d41ae Mon Sep 17 00:00:00 2001 From: Sehee-Lee-01 Date: Sun, 18 Feb 2024 20:22:09 +0900 Subject: [PATCH 09/12] =?UTF-8?q?test:=20=EA=B8=B0=EC=88=A0=20=EC=8A=A4?= =?UTF-8?q?=ED=83=9D=20=EA=B2=80=EC=83=89=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sidepeek/skill/domain/Skill.java | 12 +++ .../skill/serivce/SkillServiceTest.java | 93 +++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 src/test/java/sixgaezzang/sidepeek/skill/serivce/SkillServiceTest.java diff --git a/src/main/java/sixgaezzang/sidepeek/skill/domain/Skill.java b/src/main/java/sixgaezzang/sidepeek/skill/domain/Skill.java index a7bf0988..640d9425 100644 --- a/src/main/java/sixgaezzang/sidepeek/skill/domain/Skill.java +++ b/src/main/java/sixgaezzang/sidepeek/skill/domain/Skill.java @@ -1,5 +1,7 @@ package sixgaezzang.sidepeek.skill.domain; +import static sixgaezzang.sidepeek.common.util.ValidationUtils.validateMaxLength; + import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; @@ -7,6 +9,7 @@ import jakarta.persistence.Id; import jakarta.persistence.Table; import lombok.AccessLevel; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @@ -28,4 +31,13 @@ public class Skill { @Column(name = "icon_image_url", nullable = false, columnDefinition = "TEXT") private String iconImageUrl; + @Builder + public Skill(String name, String iconImageUrl) { + validateMaxLength(name, MAX_SKILL_NAME_LENGTH, + "최대 " + MAX_SKILL_NAME_LENGTH + "자의 이름으로 생성할 수 있습니다."); + + this.name = name; + this.iconImageUrl = iconImageUrl; + } + } diff --git a/src/test/java/sixgaezzang/sidepeek/skill/serivce/SkillServiceTest.java b/src/test/java/sixgaezzang/sidepeek/skill/serivce/SkillServiceTest.java new file mode 100644 index 00000000..ee7a71ed --- /dev/null +++ b/src/test/java/sixgaezzang/sidepeek/skill/serivce/SkillServiceTest.java @@ -0,0 +1,93 @@ +package sixgaezzang.sidepeek.skill.serivce; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; +import static sixgaezzang.sidepeek.skill.domain.Skill.MAX_SKILL_NAME_LENGTH; + +import java.util.List; +import org.assertj.core.api.ThrowableAssert; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.NullAndEmptySource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.transaction.annotation.Transactional; +import sixgaezzang.sidepeek.skill.domain.Skill; +import sixgaezzang.sidepeek.skill.dto.response.SkillResponse; +import sixgaezzang.sidepeek.skill.repository.SkillRepository; + +@SpringBootTest +@Transactional +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +class SkillServiceTest { + + @Autowired + SkillService skillService; + @Autowired + SkillRepository skillRepository; + + @Nested + class 기술_스택_검색_테스트 { + + static final int SKILL_COUNT = 5; + static final String[] skills = {"spring", "spring boot", "spring web", "react", "react query"}; + + @BeforeEach + void setUp() { + for (int i = 0; i < SKILL_COUNT; i++) { + Skill skill = createSkill(skills[i], "url"); + skillRepository.save(skill); + } + } + + @ParameterizedTest(name = "[{index}] {0}으로 검색할 때 " + SKILL_COUNT + "개의 모든 기술 스택이 나온다.") + @NullAndEmptySource + void 검색어_없이_전체_기술_스택_검색에_성공한다(String keyword) { + // given, when + List skills = skillService.searchByName(keyword) + .skills(); + + // then + assertThat(skills.size()).isEqualTo(SKILL_COUNT); + } + + @ParameterizedTest(name = "[{index}] {0}으로 검색할 때 {1}개의 기술 스택이 나온다.") + @CsvSource(value = {"spring:3", "react:2"}, delimiter = ':') + void 검색어로_기술_스택_검색에_성공한다(String keyword, int count) { + // given, when + List skills = skillService.searchByName(keyword) + .skills(); + + // then + assertThat(skills.size()).isEqualTo(count); + } + + @Test + void 검색어_최대_글자_수가_넘어_기술_스택_검색에_실패한다() { + // given + int keywordLength = MAX_SKILL_NAME_LENGTH + 1; + String keyword = "a".repeat(keywordLength); + + // when + ThrowableAssert.ThrowingCallable search = () -> skillService.searchByName(keyword); + + // then + assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(search) + .withMessage("최대 " + MAX_SKILL_NAME_LENGTH + "자의 키워드로 검색할 수 있습니다."); + } + + } + + private Skill createSkill(String name, String iconImageUrl) { + return Skill.builder() + .name(name) + .iconImageUrl(iconImageUrl) + .build(); + } + +} From 4e50508ff62ed5fe1d2279899480dec2cfb1e578 Mon Sep 17 00:00:00 2001 From: Sehee-Lee-01 Date: Mon, 19 Feb 2024 08:49:28 +0900 Subject: [PATCH 10/12] =?UTF-8?q?refactor:=20=EC=83=81=EC=88=98=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sixgaezzang/sidepeek/users/controller/UserController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/sixgaezzang/sidepeek/users/controller/UserController.java b/src/main/java/sixgaezzang/sidepeek/users/controller/UserController.java index 313a7a79..9ca3d7d3 100644 --- a/src/main/java/sixgaezzang/sidepeek/users/controller/UserController.java +++ b/src/main/java/sixgaezzang/sidepeek/users/controller/UserController.java @@ -56,7 +56,7 @@ public ResponseEntity signUp(@RequestBody @Valid SignUpRequest request) { @Parameter(name = "keyword", description = "검색어", example = "sixgaezzang6") public ResponseEntity searchByNickname( @RequestParam(required = false) - @Size(max = MAX_NICKNAME_LENGTH, message = "최대 20자의 키워드로 검색할 수 있습니다.") + @Size(max = MAX_NICKNAME_LENGTH, message = "최대 " + MAX_NICKNAME_LENGTH + "자의 키워드로 검색할 수 있습니다.") String keyword ) { return ResponseEntity.ok() From 1ef272995dafc4fd98f4899ea594f47d6101ce97 Mon Sep 17 00:00:00 2001 From: Sehee-Lee-01 Date: Mon, 19 Feb 2024 08:53:47 +0900 Subject: [PATCH 11/12] =?UTF-8?q?refactor:=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sidepeek/skill/serivce/SkillServiceTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/sixgaezzang/sidepeek/skill/serivce/SkillServiceTest.java b/src/test/java/sixgaezzang/sidepeek/skill/serivce/SkillServiceTest.java index ee7a71ed..f3c1babd 100644 --- a/src/test/java/sixgaezzang/sidepeek/skill/serivce/SkillServiceTest.java +++ b/src/test/java/sixgaezzang/sidepeek/skill/serivce/SkillServiceTest.java @@ -40,8 +40,7 @@ class 기술_스택_검색_테스트 { @BeforeEach void setUp() { for (int i = 0; i < SKILL_COUNT; i++) { - Skill skill = createSkill(skills[i], "url"); - skillRepository.save(skill); + createSkill(skills[i], "url"); } } @@ -84,10 +83,11 @@ void setUp() { } private Skill createSkill(String name, String iconImageUrl) { - return Skill.builder() + Skill skill = Skill.builder() .name(name) .iconImageUrl(iconImageUrl) .build(); + return skillRepository.save(skill); } } From 2e3bd8b9815428803064e133882d5618eac3df15 Mon Sep 17 00:00:00 2001 From: Sehee-Lee-01 Date: Mon, 19 Feb 2024 09:02:32 +0900 Subject: [PATCH 12/12] =?UTF-8?q?refactor:=20url=20validate=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/sixgaezzang/sidepeek/skill/domain/Skill.java | 2 ++ .../sixgaezzang/sidepeek/skill/serivce/SkillServiceTest.java | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/sixgaezzang/sidepeek/skill/domain/Skill.java b/src/main/java/sixgaezzang/sidepeek/skill/domain/Skill.java index 640d9425..2b07d65e 100644 --- a/src/main/java/sixgaezzang/sidepeek/skill/domain/Skill.java +++ b/src/main/java/sixgaezzang/sidepeek/skill/domain/Skill.java @@ -1,6 +1,7 @@ package sixgaezzang.sidepeek.skill.domain; import static sixgaezzang.sidepeek.common.util.ValidationUtils.validateMaxLength; +import static sixgaezzang.sidepeek.common.util.ValidationUtils.validateURI; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -35,6 +36,7 @@ public class Skill { public Skill(String name, String iconImageUrl) { validateMaxLength(name, MAX_SKILL_NAME_LENGTH, "최대 " + MAX_SKILL_NAME_LENGTH + "자의 이름으로 생성할 수 있습니다."); + validateURI(iconImageUrl, "이미지 url 형식이 올바르지 않습니다."); this.name = name; this.iconImageUrl = iconImageUrl; diff --git a/src/test/java/sixgaezzang/sidepeek/skill/serivce/SkillServiceTest.java b/src/test/java/sixgaezzang/sidepeek/skill/serivce/SkillServiceTest.java index f3c1babd..74562d4b 100644 --- a/src/test/java/sixgaezzang/sidepeek/skill/serivce/SkillServiceTest.java +++ b/src/test/java/sixgaezzang/sidepeek/skill/serivce/SkillServiceTest.java @@ -39,8 +39,9 @@ class 기술_스택_검색_테스트 { @BeforeEach void setUp() { + String tempImageUrl = "https://google.com/image.png"; for (int i = 0; i < SKILL_COUNT; i++) { - createSkill(skills[i], "url"); + createSkill(skills[i], tempImageUrl); } }