Skip to content

Commit

Permalink
refactor: 기존 카테고리 api 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
yechop committed Feb 12, 2025
1 parent a818470 commit 799bbfc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ public ResponseEntity<CategoryCreateResponse> createCategory(
.body(response);
}

@PatchMapping("/{accessCode}/category")
@PatchMapping("/{accessCode}/category/{categoryId}")
public ResponseEntity<CategoryUpdateResponse> updateCategory(
@PathVariable("accessCode") String accessCode,
@PathVariable("categoryId") Long categoryId,
@Valid @RequestBody CategoryUpdateRequest categoryUpdateRequest
) {
final CategoryUpdateResponse response = categoryService.updateCategoryName(accessCode,
categoryId,
categoryUpdateRequest);

return ResponseEntity.ok(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public interface CategoryDocs {
@ApiResponse(responseCode = "200", description = "카테고리 생성 성공", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = CategoryUpdateRequest.class)))
@ApiResponse(responseCode = "4xx", description = "카테고리 생성 실패", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ApiErrorResponse.class)))
ResponseEntity<CategoryUpdateResponse> updateCategory(@PathVariable("accessCode") String accessCode,
@PathVariable("categoryId") Long categoryId,
@RequestBody CategoryUpdateRequest categoryUpdateRequest
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ void update_category() {
new CategoryCreateRequest("이전 카테고리"));

final String updateName = "변경된 카테고리";
final CategoryUpdateRequest request = new CategoryUpdateRequest(Long.parseLong(previousCategory.id()),
updateName);
final CategoryUpdateRequest request = new CategoryUpdateRequest(updateName);

//when & then
final CategoryUpdateResponse categoryUpdateResponse = RestAssured
Expand All @@ -81,7 +80,7 @@ void update_category() {

.when()
.body(request)
.patch("/api/{accessCode}/category", pairRoomUrl.accessCode())
.patch("/api/{accessCode}/category/{categoryId}", pairRoomUrl.accessCode(), previousCategory.id())

.then()
.log()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void save_category() {
ACCESS_CODE.getValue());
assertThat(categories.stream().anyMatch(
category -> category.id().equals(createdCategory.id()) &&
category.categoryName().equals(createdCategory.value())))
category.value().equals(createdCategory.value())))
.isTrue();
}

Expand All @@ -87,14 +87,14 @@ void update_category() {

//when
final CategoryUpdateResponse updatedCategory = categoryService.updateCategoryName(ACCESS_CODE.getValue(),
new CategoryUpdateRequest(Long.parseLong(createdCategory.id()), "파이썬"));
Long.parseLong(createdCategory.id()), new CategoryUpdateRequest("파이썬"));

//then
final List<CategoryReadResponse> categories = categoryService.findAllByPairRoomAccessCode(
ACCESS_CODE.getValue());
assertThat(categories.stream().anyMatch(
category -> category.id().equals(createdCategory.id()) &&
category.categoryName().equals(updatedCategory.updatedCategoryName())))
category.value().equals(updatedCategory.updatedCategoryName())))
.isTrue();
}

Expand Down

0 comments on commit 799bbfc

Please sign in to comment.