From 9b4ee4508669e3f08e7305eadcf64b9e0bd52066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A7=84=EC=A3=BC=EC=9B=90?= <84346055+jinjoo-lab@users.noreply.github.com> Date: Fri, 6 Oct 2023 10:18:07 +0900 Subject: [PATCH 1/3] [ADD] Member Controller Api - Docs --- backend/src/docs/member.adoc | 4 ++ .../controller/MemberControllerTest.java | 41 +++++++++++++++++++ .../path/controller/PathControllerTest.java | 12 +++--- 3 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java diff --git a/backend/src/docs/member.adoc b/backend/src/docs/member.adoc index bad4a425..7908e689 100644 --- a/backend/src/docs/member.adoc +++ b/backend/src/docs/member.adoc @@ -4,3 +4,7 @@ :toc: left :toclevels: 4 +== Member +=== 닉네임 중복 검색 +operation::get duplicate nickname[snippets='http-request,http-response'] + diff --git a/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java new file mode 100644 index 00000000..d1351b22 --- /dev/null +++ b/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java @@ -0,0 +1,41 @@ +package com.twtw.backend.domain.member.controller; + +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{ + final ResultActions perform = + mockMvc.perform( + get("/member/duplicate/{name}","진주원") + .contentType(MediaType.APPLICATION_JSON) + ); + + // then + perform.andExpect(status().isOk()); + // docs + + perform.andDo(print()) + .andDo(document("get duplicate nickname", getDocumentRequest(), getDocumentResponse())); + } +} diff --git a/backend/src/test/java/com/twtw/backend/domain/path/controller/PathControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/path/controller/PathControllerTest.java index adab02c6..d324f4a6 100644 --- a/backend/src/test/java/com/twtw/backend/domain/path/controller/PathControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/path/controller/PathControllerTest.java @@ -58,12 +58,12 @@ void searchCarPath() throws Exception { .content( toRequestBody( new SearchCarPathRequest( - "", - "", + "37.636040,126.827507", + "37.644998,126.832659", "", SearchPathOption.TRAFAST, SearchPathFuel.DIESEL, - 0))) + 1))) .contentType(MediaType.APPLICATION_JSON)); // then @@ -93,12 +93,12 @@ void searchPedPath() throws Exception { .content( toRequestBody( new SearchCarPathRequest( - "", - "", + "37.636040,126.827507", + "37.644998,126.832659", "", SearchPathOption.TRAFAST, SearchPathFuel.DIESEL, - 0))) + 1))) .contentType(MediaType.APPLICATION_JSON)); // then From 572e47520d4ce9fab0d1fd488ba0d9287c5381c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A7=84=EC=A3=BC=EC=9B=90?= <84346055+jinjoo-lab@users.noreply.github.com> Date: Fri, 6 Oct 2023 10:23:09 +0900 Subject: [PATCH 2/3] [ADD] Member Controller Api - Docs --- backend/src/docs/index.adoc | 1 + .../backend/domain/member/controller/MemberControllerTest.java | 3 +++ 2 files changed, 4 insertions(+) diff --git a/backend/src/docs/index.adoc b/backend/src/docs/index.adoc index 5d1ee08f..bd176ec9 100644 --- a/backend/src/docs/index.adoc +++ b/backend/src/docs/index.adoc @@ -12,3 +12,4 @@ include::auth.adoc[] include::path.adoc[] include::plan.adoc[] include::place.adoc[] +include::member.adoc[] diff --git a/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java index d1351b22..69d2f0ef 100644 --- a/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java @@ -29,6 +29,9 @@ void duplicate() throws Exception{ mockMvc.perform( get("/member/duplicate/{name}","진주원") .contentType(MediaType.APPLICATION_JSON) + .header( + "Authorization", + "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh") ); // then From ca0ecb72320a7dab1a6a0024defd0468c8b34f6c Mon Sep 17 00:00:00 2001 From: github-actions <> Date: Fri, 6 Oct 2023 01:23:55 +0000 Subject: [PATCH 3/3] Google Java Format --- .../controller/MemberControllerTest.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java index 69d2f0ef..34bc56c5 100644 --- a/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java @@ -1,7 +1,16 @@ 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; @@ -9,14 +18,6 @@ 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 { @@ -24,21 +25,24 @@ public class MemberControllerTest extends RestDocsTest { @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())); } }