-
Notifications
You must be signed in to change notification settings - Fork 3
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
github-actions
committed
Oct 6, 2023
1 parent
572e475
commit ca0ecb7
Showing
1 changed file
with
17 additions
and
13 deletions.
There are no files selected for viewing
30 changes: 17 additions & 13 deletions
30
backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.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 |
---|---|---|
@@ -1,44 +1,48 @@ | ||
package com.twtw.backend.domain.member.controller; | ||
|
||
import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; | ||
import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; | ||
|
||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; | ||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
import com.twtw.backend.domain.member.service.MemberService; | ||
import com.twtw.backend.support.docs.RestDocsTest; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.test.web.servlet.ResultActions; | ||
|
||
import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; | ||
import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; | ||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; | ||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
@DisplayName("MemberController의") | ||
@WebMvcTest(MemberController.class) | ||
public class MemberControllerTest extends RestDocsTest { | ||
@MockBean private MemberService memberService; | ||
|
||
@Test | ||
@DisplayName("닉네임이 중복되었는가") | ||
void duplicate() throws Exception{ | ||
void duplicate() throws Exception { | ||
final ResultActions perform = | ||
mockMvc.perform( | ||
get("/member/duplicate/{name}","진주원") | ||
get("/member/duplicate/{name}", "진주원") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.header( | ||
"Authorization", | ||
"Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh") | ||
); | ||
"Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); | ||
|
||
// then | ||
perform.andExpect(status().isOk()); | ||
// docs | ||
|
||
perform.andDo(print()) | ||
.andDo(document("get duplicate nickname", getDocumentRequest(), getDocumentResponse())); | ||
.andDo( | ||
document( | ||
"get duplicate nickname", | ||
getDocumentRequest(), | ||
getDocumentResponse())); | ||
} | ||
} |