Skip to content

Commit

Permalink
hotfix: 템플릿 삭제 요청 포맷 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyubin989 committed Feb 22, 2024
1 parent 0e0b41f commit f8945d2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.baro.memofolder.application.dto.RenameMemoFolderCommand;
import com.baro.memofolder.application.dto.SaveMemoFolderCommand;
import com.baro.memofolder.application.dto.SaveMemoFolderResult;
import com.baro.memofolder.presentation.dto.DeleteMemoFolderRequest;
import com.baro.memofolder.presentation.dto.RenameMemoFolderRequest;
import com.baro.memofolder.presentation.dto.SaveMemoFolderRequest;
import java.net.URI;
Expand All @@ -17,9 +16,11 @@
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;

Expand Down Expand Up @@ -56,10 +57,10 @@ public ResponseEntity<Void> renameMemoFolder(AuthMember authMember, @RequestBody
return ResponseEntity.noContent().build();
}

@DeleteMapping
public ResponseEntity<Void> deleteMemoFolder(AuthMember authMember, @RequestBody DeleteMemoFolderRequest request) {
DeleteMemoFolderCommand command = new DeleteMemoFolderCommand(authMember.id(), request.memoFolderId(),
request.deleteAllMemo());
@DeleteMapping("/{memoFolderId}")
public ResponseEntity<Void> deleteMemoFolder(AuthMember authMember, @PathVariable("memoFolderId") Long memoFolderId,
@RequestParam("deleteAllMemo") boolean deleteAllMemo) {
DeleteMemoFolderCommand command = new DeleteMemoFolderCommand(authMember.id(), memoFolderId, deleteAllMemo);
memoFolderService.deleteMemoFolder(command);
return ResponseEntity.noContent().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
import static org.springframework.restdocs.request.RequestDocumentation.queryParameters;

import com.baro.auth.domain.Token;
import com.baro.memofolder.presentation.dto.DeleteMemoFolderRequest;
import com.baro.memofolder.presentation.dto.RenameMemoFolderRequest;
import com.baro.memofolder.presentation.dto.SaveMemoFolderRequest;
import io.restassured.response.ExtractableResponse;
Expand Down Expand Up @@ -143,42 +145,50 @@ public class MemoFolderAcceptanceSteps {
.extract();
}

public static ExtractableResponse<Response> 폴더_삭제_요청_성공(Token 토큰, DeleteMemoFolderRequest 바디) {
var url = "/memo-folders";
public static ExtractableResponse<Response> 폴더_삭제_요청_성공(Token 토큰, Long 메모폴더Id, boolean 모두삭제여부) {
var url = "/memo-folders/{memoFolderId}";

return given(requestSpec).log().all()
.filter(document(DEFAULT_REST_DOCS_PATH,
requestHeaders(
headerWithName(HttpHeaders.AUTHORIZATION).description("인증 토큰")
),
requestFields(
fieldWithPath("memoFolderId").description("폴더 id"),
fieldWithPath("deleteAllMemo").description("폴더에 있는 메모를 모두 삭제할지 여부")
pathParameters(
parameterWithName("memoFolderId").description("폴더 id")
),
queryParameters(
parameterWithName("deleteAllMemo").description("폴더에 있는 메모를 모두 삭제할지 여부")
)
))
.contentType(MediaType.APPLICATION_JSON_VALUE)
.header(HttpHeaders.AUTHORIZATION, "Bearer " + 토큰.accessToken()).body(바디)
.header(HttpHeaders.AUTHORIZATION, "Bearer " + 토큰.accessToken())
.pathParam("memoFolderId", 메모폴더Id)
.queryParam("deleteAllMemo", 모두삭제여부)
.when().delete(url)
.then().log().all()
.extract();
}

public static ExtractableResponse<Response> 폴더_삭제_요청_실패(Token 토큰, DeleteMemoFolderRequest 바디) {
var url = "/memo-folders";
public static ExtractableResponse<Response> 폴더_삭제_요청_실패(Token 토큰, Long 메모폴더Id, boolean 모두삭제여부) {
var url = "/memo-folders/{memoFolderId}";

return given(requestSpec).log().all()
.filter(document(DEFAULT_REST_DOCS_PATH,
requestHeaders(
headerWithName(HttpHeaders.AUTHORIZATION).description("인증 토큰")
),
requestFields(
fieldWithPath("memoFolderId").description("폴더 id"),
fieldWithPath("deleteAllMemo").description("폴더에 있는 메모를 모두 삭제할지 여부")
pathParameters(
parameterWithName("memoFolderId").description("폴더 id")
),
queryParameters(
parameterWithName("deleteAllMemo").description("폴더에 있는 메모를 모두 삭제할지 여부")
),
responseFields(예외_응답())
))
.contentType(MediaType.APPLICATION_JSON_VALUE)
.header(HttpHeaders.AUTHORIZATION, "Bearer " + 토큰.accessToken()).body(바디)
.header(HttpHeaders.AUTHORIZATION, "Bearer " + 토큰.accessToken())
.pathParam("memoFolderId", 메모폴더Id)
.queryParam("deleteAllMemo", 모두삭제여부)
.when().delete(url)
.then().log().all()
.extract();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.baro.member.exception.MemberException;
import com.baro.member.exception.MemberExceptionType;
import com.baro.memofolder.domain.MemoFolderRepository;
import com.baro.memofolder.presentation.dto.DeleteMemoFolderRequest;
import com.baro.memofolder.presentation.dto.RenameMemoFolderRequest;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
Expand Down Expand Up @@ -194,10 +193,9 @@ class MemoFolderApiTest extends RestApiTest {
// given
var 토큰 = 로그인(원진());
var 메모폴더ID = 메모_폴더를_생성_하고_ID를_반환한다(토큰, 폴더_이름_바디);
var 바디 = new DeleteMemoFolderRequest(메모폴더ID, true);

// when
var 응답 = 폴더_삭제_요청_성공(토큰, 바디);
var 응답 = 폴더_삭제_요청_성공(토큰, 메모폴더ID, true);

// then
응답값을_검증한다(응답, 응답값_없음);
Expand All @@ -208,10 +206,9 @@ class MemoFolderApiTest extends RestApiTest {
// given
var 토큰 = 로그인(원진());
var 메모폴더ID = 메모_폴더를_생성_하고_ID를_반환한다(토큰, 폴더_이름_바디);
var 바디 = new DeleteMemoFolderRequest(메모폴더ID, false);

// when
var 응답 = 폴더_삭제_요청_성공(토큰, 바디);
var 응답 = 폴더_삭제_요청_성공(토큰, 메모폴더ID, false);

// then
응답값을_검증한다(응답, 응답값_없음);
Expand All @@ -222,10 +219,9 @@ class MemoFolderApiTest extends RestApiTest {
// given
var 토큰 = 로그인(원진());
var 존재하지않는_메모폴더ID = 999L;
var 바디 = new DeleteMemoFolderRequest(존재하지않는_메모폴더ID, false);

// when
var 응답 = 폴더_삭제_요청_실패(토큰, 바디);
var 응답 = 폴더_삭제_요청_실패(토큰, 존재하지않는_메모폴더ID, false);

// then
응답값을_검증한다(응답, 존재하지_않음);
Expand All @@ -237,10 +233,9 @@ class MemoFolderApiTest extends RestApiTest {
var 원진토큰 = 로그인(원진());
var 준희토큰 = 로그인(준희());
var 메모폴더ID = 메모_폴더를_생성_하고_ID를_반환한다(원진토큰, 폴더_이름_바디);
var 바디 = new DeleteMemoFolderRequest(메모폴더ID, false);

// when
var 응답 = 폴더_삭제_요청_실패(준희토큰, 바디);
var 응답 = 폴더_삭제_요청_실패(준희토큰, 메모폴더ID, false);

// then
응답값을_검증한다(응답, 권한_없음);
Expand All @@ -251,11 +246,9 @@ class MemoFolderApiTest extends RestApiTest {
// given
var 토큰 = 로그인(원진());
var 기본폴더ID = 기본폴더의_ID();
var 메모폴더ID = 메모_폴더를_생성_하고_ID를_반환한다(토큰, 폴더_이름_바디);
var 바디 = new DeleteMemoFolderRequest(기본폴더ID, false);

// when
var 응답 = 폴더_삭제_요청_실패(토큰, 바디);
var 응답 = 폴더_삭제_요청_실패(토큰, 기본폴더ID, false);

// then
응답값을_검증한다(응답, 권한_없음);
Expand Down

0 comments on commit f8945d2

Please sign in to comment.