-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,8 @@ include::highlight-answers.adoc[] | |
|
||
== 인증 | ||
|
||
include::auth.adoc[] | ||
include::auth.adoc[] | ||
|
||
== 사용자 | ||
|
||
include::member.adoc[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
==== 내 프로필 정보 | ||
|
||
operation::my-profile[snippets="curl-request,request-cookies,http-response,response-fields"] |
21 changes: 21 additions & 0 deletions
21
backend/src/main/java/reviewme/member/controller/MemberController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package reviewme.member.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import reviewme.member.service.MemberService; | ||
import reviewme.member.service.dto.ProfileResponse; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class MemberController { | ||
|
||
private final MemberService memberService; | ||
|
||
@GetMapping("/v2/members/profile/mine") | ||
public ResponseEntity<ProfileResponse> getProfile() { | ||
ProfileResponse response = memberService.getProfile(); | ||
return ResponseEntity.ok(response); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
backend/src/main/java/reviewme/member/service/MemberService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package reviewme.member.service; | ||
|
||
import org.springframework.stereotype.Service; | ||
import reviewme.member.service.dto.ProfileResponse; | ||
|
||
@Service | ||
public class MemberService { | ||
|
||
public ProfileResponse getProfile() { | ||
return null; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
backend/src/main/java/reviewme/member/service/dto/ProfileResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package reviewme.member.service.dto; | ||
|
||
public record ProfileResponse( | ||
String nickname, | ||
String profileImageUrl | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package reviewme.api; | ||
|
||
import static org.springframework.restdocs.cookies.CookieDocumentation.cookieWithName; | ||
import static org.springframework.restdocs.cookies.CookieDocumentation.requestCookies; | ||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; | ||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; | ||
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.mockito.BDDMockito; | ||
import org.springframework.restdocs.cookies.CookieDescriptor; | ||
import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; | ||
import org.springframework.restdocs.payload.FieldDescriptor; | ||
import reviewme.member.service.dto.ProfileResponse; | ||
|
||
public class MemberApiTest extends ApiTest { | ||
|
||
@Test | ||
void 내_프로필을_불러온다() { | ||
BDDMockito.given(memberService.getProfile()) | ||
.willReturn(new ProfileResponse("donghoony", "https://aru.image")); | ||
|
||
CookieDescriptor[] cookieDescriptors = { | ||
cookieWithName("JSESSIONID").description("세션 ID") | ||
}; | ||
|
||
FieldDescriptor[] responseFieldDescriptors = { | ||
fieldWithPath("nickname").description("닉네임"), | ||
fieldWithPath("profileImageUrl").description("프로필 이미지 URL") | ||
}; | ||
|
||
RestDocumentationResultHandler handler = document( | ||
"my-profile", | ||
requestCookies(cookieDescriptors), | ||
responseFields(responseFieldDescriptors) | ||
); | ||
|
||
givenWithSpec().log().all() | ||
.cookie("JSESSIONID", "SESSION12345678") | ||
.when().get("/v2/members/profile/mine") | ||
.then().log().all() | ||
.apply(handler) | ||
.statusCode(200); | ||
} | ||
} |