From fc8d695d4d3e576a2059687ee779531d27fb5b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=8A=B9=EC=A7=84?= Date: Thu, 9 Nov 2023 10:54:15 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[FEAT]=20group=20=EB=B0=8F=20plan=20?= =?UTF-8?q?=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EC=99=80=20api=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/docs/group.adoc | 24 +++ backend/src/docs/index.adoc | 1 + backend/src/docs/plan.adoc | 15 ++ .../group/controller/GroupController.java | 8 +- .../plan/dto/response/PlanInfoResponse.java | 2 +- .../group/controller/GroupControllerTest.java | 111 ++++++++++++- .../plan/controller/PlanControllerTest.java | 155 +++++++++++++++++- 7 files changed, 302 insertions(+), 14 deletions(-) create mode 100644 backend/src/docs/group.adoc diff --git a/backend/src/docs/group.adoc b/backend/src/docs/group.adoc new file mode 100644 index 00000000..9fb9027d --- /dev/null +++ b/backend/src/docs/group.adoc @@ -0,0 +1,24 @@ +:doctype: book +:icons: font +:source-highlighter: highlightjs +:toc: left +:toclevels: 4 + +== Group +=== 그룹 단건 조회 +operation::get group by id[snippets='http-request,http-response'] + +=== 그룹 생성 +operation::post save group[snippets='http-request,http-response'] + +=== 그룹 가입 +operation::post join group[snippets='http-request,http-response'] + +=== 그룹 초대 +operation::post invite group[snippets='http-request,http-response'] + +=== 위치 공유 여부 수정 +operation::post change share[snippets='http-request,http-response'] + +=== 위치 공유 여부 조회 +operation::get share[snippets='http-request,http-response'] diff --git a/backend/src/docs/index.adoc b/backend/src/docs/index.adoc index 725e814f..57b5b5fb 100644 --- a/backend/src/docs/index.adoc +++ b/backend/src/docs/index.adoc @@ -14,3 +14,4 @@ include::plan.adoc[] include::place.adoc[] include::member.adoc[] include::friend.adoc[] +include::group.adoc[] diff --git a/backend/src/docs/plan.adoc b/backend/src/docs/plan.adoc index 73992020..e620e734 100644 --- a/backend/src/docs/plan.adoc +++ b/backend/src/docs/plan.adoc @@ -7,3 +7,18 @@ == Plan === 검색어와 카테고리를 통한 장소 검색 operation::get search plan destination[snippets='http-request,http-response'] + +=== 계획 저장 +operation::post save plan[snippets='http-request,http-response'] + +=== 계획 단건 조회 +operation::get plan[snippets='http-request,http-response'] + +=== 계획 삭제 +operation::delete plan[snippets='http-request,http-response'] + +=== 계획 참여 +operation::post join plan[snippets='http-request,http-response'] + +=== 계획 탈퇴 +operation::post out plan[snippets='http-request,http-response'] diff --git a/backend/src/main/java/com/twtw/backend/domain/group/controller/GroupController.java b/backend/src/main/java/com/twtw/backend/domain/group/controller/GroupController.java index e6179a1a..fc222077 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/controller/GroupController.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/controller/GroupController.java @@ -27,7 +27,7 @@ public ResponseEntity getGroupById(@PathVariable UUID id) { return ResponseEntity.ok(groupService.getGroupById(id)); } - @PostMapping() + @PostMapping public ResponseEntity makeGroup( @RequestBody MakeGroupRequest makeGroupRequest) { return ResponseEntity.ok(groupService.makeGroup(makeGroupRequest)); @@ -45,14 +45,14 @@ public ResponseEntity inviteGroup( return ResponseEntity.ok(groupService.inviteGroup(inviteGroupRequest)); } - @PutMapping("/share/{id}") + @PostMapping("/share/{id}") public ResponseEntity changeShare(@PathVariable UUID id) { groupService.changeShare(id); - return ResponseEntity.ok().build(); + return ResponseEntity.noContent().build(); } @GetMapping("/share/{id}") - public ResponseEntity getshare(@PathVariable UUID id) { + public ResponseEntity getShare(@PathVariable UUID id) { return ResponseEntity.ok(groupService.getShare(id)); } } diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/dto/response/PlanInfoResponse.java b/backend/src/main/java/com/twtw/backend/domain/plan/dto/response/PlanInfoResponse.java index 2be1d6ba..d16ede79 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/dto/response/PlanInfoResponse.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/dto/response/PlanInfoResponse.java @@ -19,5 +19,5 @@ public class PlanInfoResponse { private UUID placeId; private PlaceDetails placeDetail; private GroupInfoResponse groupInfoResponse; - private List memberList; + private List members; } diff --git a/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java index 2ec6a2c0..39a135d4 100644 --- a/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java @@ -2,7 +2,6 @@ import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; - import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; @@ -12,11 +11,15 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.twtw.backend.domain.group.dto.request.InviteGroupRequest; +import com.twtw.backend.domain.group.dto.request.JoinGroupRequest; import com.twtw.backend.domain.group.dto.request.MakeGroupRequest; import com.twtw.backend.domain.group.dto.response.GroupInfoResponse; +import com.twtw.backend.domain.group.dto.response.ShareInfoResponse; +import com.twtw.backend.domain.group.dto.response.SimpleGroupInfoResponse; import com.twtw.backend.domain.group.service.GroupService; import com.twtw.backend.support.docs.RestDocsTest; - +import java.util.UUID; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -24,11 +27,9 @@ import org.springframework.http.MediaType; import org.springframework.test.web.servlet.ResultActions; -import java.util.UUID; - @DisplayName("GroupController의") @WebMvcTest(GroupController.class) -public class GroupControllerTest extends RestDocsTest { +class GroupControllerTest extends RestDocsTest { @MockBean private GroupService groupService; @Test @@ -93,4 +94,104 @@ void makeGroup() throws Exception { perform.andDo(print()) .andDo(document("post save group", getDocumentRequest(), getDocumentResponse())); } + + @Test + @DisplayName("그룹 가입 API가 수행되는가") + void joinGroup() throws Exception { + // given + final SimpleGroupInfoResponse expected = new SimpleGroupInfoResponse(UUID.randomUUID()); + given(groupService.joinGroup(any())).willReturn(expected); + + // when + final ResultActions perform = + mockMvc.perform( + post("/group/join") + .contentType(MediaType.APPLICATION_JSON) + .content(toRequestBody(new JoinGroupRequest(UUID.randomUUID()))) + .header( + "Authorization", + "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); + + // then + perform.andExpect(status().isOk()) + .andExpect(jsonPath("$.groupId").isString()); + + // docs + perform.andDo(print()) + .andDo(document("post join group", getDocumentRequest(), getDocumentResponse())); + } + + @Test + @DisplayName("그룹 초대 API가 수행되는가") + void inviteGroup() throws Exception { + // given + final GroupInfoResponse expected = new GroupInfoResponse(UUID.randomUUID(), UUID.randomUUID(), "홍담진", "http://someUrlToS3"); + given(groupService.inviteGroup(any())).willReturn(expected); + + // when + final ResultActions perform = + mockMvc.perform( + post("/group/invite") + .contentType(MediaType.APPLICATION_JSON) + .content(toRequestBody(new InviteGroupRequest(UUID.randomUUID(), UUID.randomUUID()))) + .header( + "Authorization", + "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); + + // then + perform.andExpect(status().isOk()) + .andExpect(jsonPath("$.groupId").isString()) + .andExpect(jsonPath("$.name").isString()); + + // docs + perform.andDo(print()) + .andDo(document("post invite group", getDocumentRequest(), getDocumentResponse())); + } + + @Test + @DisplayName("위치 공유 수정 API가 수행되는가") + void changeShare() throws Exception { + // when + final ResultActions perform = + mockMvc.perform( + post("/group/share/" + UUID.randomUUID()) + .contentType(MediaType.APPLICATION_JSON) + .content(toRequestBody(new InviteGroupRequest(UUID.randomUUID(), UUID.randomUUID()))) + .header( + "Authorization", + "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); + + // then + perform.andExpect(status().isNoContent()); + + // docs + perform.andDo(print()) + .andDo(document("post change share", getDocumentRequest(), getDocumentResponse())); + } + + @Test + @DisplayName("위치 공유 조회 API가 수행되는가") + void getShare() throws Exception { + // given + final ShareInfoResponse expected = new ShareInfoResponse(UUID.randomUUID(), UUID.randomUUID(), true); + given(groupService.getShare(any())).willReturn(expected); + + // when + final ResultActions perform = + mockMvc.perform( + get("/group/share/" + UUID.randomUUID()) + .contentType(MediaType.APPLICATION_JSON) + .content(toRequestBody(new InviteGroupRequest(UUID.randomUUID(), UUID.randomUUID()))) + .header( + "Authorization", + "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); + + // then + perform.andExpect(status().isOk()) + .andExpect(jsonPath("$.share").isBoolean()); + + // docs + perform.andDo(print()) + .andDo(document("get share", getDocumentRequest(), getDocumentResponse())); + } } diff --git a/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java index db37f274..2bea85f0 100644 --- a/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java @@ -2,21 +2,29 @@ import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; - import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; 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; +import com.twtw.backend.domain.group.dto.response.GroupInfoResponse; +import com.twtw.backend.domain.member.dto.response.MemberResponse; import com.twtw.backend.domain.place.entity.CategoryGroupCode; import com.twtw.backend.domain.plan.dto.client.PlaceDetails; +import com.twtw.backend.domain.plan.dto.request.PlanMemberRequest; +import com.twtw.backend.domain.plan.dto.request.SavePlanRequest; import com.twtw.backend.domain.plan.dto.response.PlanDestinationResponse; +import com.twtw.backend.domain.plan.dto.response.PlanInfoResponse; +import com.twtw.backend.domain.plan.dto.response.PlanResponse; import com.twtw.backend.domain.plan.service.PlanService; import com.twtw.backend.support.docs.RestDocsTest; - +import java.util.List; +import java.util.UUID; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -24,8 +32,6 @@ import org.springframework.http.MediaType; import org.springframework.test.web.servlet.ResultActions; -import java.util.List; - @DisplayName("PlanController의") @WebMvcTest(PlanController.class) class PlanControllerTest extends RestDocsTest { @@ -88,4 +94,145 @@ void searchPlanDestination() throws Exception { getDocumentRequest(), getDocumentResponse())); } + + @Test + @DisplayName("계획 저장 API가 수행되는가") + void savePlan() throws Exception { + // given + final PlanResponse expected = new PlanResponse(UUID.randomUUID(), UUID.randomUUID()); + given(planService.savePlan(any())).willReturn(expected); + + // when + final ResultActions perform = + mockMvc.perform( + post("/plans") + .contentType(MediaType.APPLICATION_JSON) + .content(toRequestBody(new SavePlanRequest(UUID.randomUUID(), new PlaceDetails("카페 온마이마인드", + "345", + "https://place.map.kakao.com/1625295668", + "음식점 > 카페", + "경기 안성시 죽산면 죽산리 414", + "경기 안성시 죽산면 죽산초교길 36-4", + CategoryGroupCode.CE7, + "127.420430538256", + "37.0766874564297")))) + .header( + "Authorization", + "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); + // then + perform.andExpect(status().isOk()) + .andExpect(jsonPath("$.planId").isString()) + .andExpect(jsonPath("$.groupId").isString()); + + // docs + perform.andDo(print()) + .andDo(document("post save plan", getDocumentRequest(), getDocumentResponse())); + } + + @Test + @DisplayName("단건 조회 API가 수행되는가") + void getPlanById() throws Exception { + // given + final PlanInfoResponse expected = new PlanInfoResponse(UUID.randomUUID(), UUID.randomUUID(), new PlaceDetails("카페 온마이마인드", + "345", + "https://place.map.kakao.com/1625295668", + "음식점 > 카페", + "경기 안성시 죽산면 죽산리 414", + "경기 안성시 죽산면 죽산초교길 36-4", + CategoryGroupCode.CE7, + "127.420430538256", + "37.0766874564297"), new GroupInfoResponse(UUID.randomUUID(), UUID.randomUUID(), "홍담진", "http://someUrlToS3"), List.of(new MemberResponse(UUID.randomUUID(), "진호정"))); + given(planService.getPlanById(any())).willReturn(expected); + + // when + final ResultActions perform = + mockMvc.perform( + get("/plans/" + UUID.randomUUID()) + .contentType(MediaType.APPLICATION_JSON) + .header( + "Authorization", + "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); + // then + perform.andExpect(status().isOk()) + .andExpect(jsonPath("$.planId").isString()) + .andExpect(jsonPath("$.members").isArray()); + + // docs + perform.andDo(print()) + .andDo(document("get plan", getDocumentRequest(), getDocumentResponse())); + } + + @Test + @DisplayName("단건 삭제 API가 수행되는가") + void deletePlanById() throws Exception { + // when + final ResultActions perform = + mockMvc.perform( + delete("/plans/" + UUID.randomUUID()) + .contentType(MediaType.APPLICATION_JSON) + .header( + "Authorization", + "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); + // then + perform.andExpect(status().isNoContent()); + + // docs + perform.andDo(print()) + .andDo(document("delete plan", getDocumentRequest(), getDocumentResponse())); + } + + @Test + @DisplayName("계획 참여 API가 수행되는가") + void joinPlan() throws Exception { + // given + final PlanResponse expected = new PlanResponse(UUID.randomUUID(), UUID.randomUUID()); + given(planService.joinPlan(any())).willReturn(expected); + + // when + final ResultActions perform = + mockMvc.perform( + post("/plans/join") + .contentType(MediaType.APPLICATION_JSON) + .content(toRequestBody(new SavePlanRequest(UUID.randomUUID(), new PlaceDetails( + "이디야커피 안성죽산점", + "435", + "http://place.map.kakao.com/1562566188", + "음식점 > 카페 > 커피전문점 > 이디야커피", + "경기 안성시 죽산면 죽산리 118-3", + "경기 안성시 죽산면 죽주로 287-1", + CategoryGroupCode.CE7, + "127.426865189637", + "37.0764635355795")))) + .header( + "Authorization", + "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); + // then + perform.andExpect(status().isOk()) + .andExpect(jsonPath("$.planId").isString()) + .andExpect(jsonPath("$.groupId").isString()); + + // docs + perform.andDo(print()) + .andDo(document("post join plan", getDocumentRequest(), getDocumentResponse())); + } + + @Test + @DisplayName("계획 탈퇴 API가 수행되는가") + void outPlan() throws Exception { + // when + final ResultActions perform = + mockMvc.perform( + post("/plans/out") + .contentType(MediaType.APPLICATION_JSON) + .content(toRequestBody(new PlanMemberRequest(UUID.randomUUID()))) + .header( + "Authorization", + "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); + // then + perform.andExpect(status().isNoContent()); + + // docs + perform.andDo(print()) + .andDo(document("post out plan", getDocumentRequest(), getDocumentResponse())); + } } From ae27bdba9b0fde48fd3feea8c901d74de47c2f2d Mon Sep 17 00:00:00 2001 From: github-actions <> Date: Thu, 9 Nov 2023 01:54:45 +0000 Subject: [PATCH 2/2] Google Java Format --- .../group/controller/GroupControllerTest.java | 33 +++++--- .../plan/controller/PlanControllerTest.java | 80 ++++++++++++------- 2 files changed, 73 insertions(+), 40 deletions(-) diff --git a/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java index 39a135d4..32a6333e 100644 --- a/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java @@ -2,6 +2,7 @@ import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; + import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; @@ -19,7 +20,7 @@ import com.twtw.backend.domain.group.dto.response.SimpleGroupInfoResponse; import com.twtw.backend.domain.group.service.GroupService; import com.twtw.backend.support.docs.RestDocsTest; -import java.util.UUID; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -27,6 +28,8 @@ import org.springframework.http.MediaType; import org.springframework.test.web.servlet.ResultActions; +import java.util.UUID; + @DisplayName("GroupController의") @WebMvcTest(GroupController.class) class GroupControllerTest extends RestDocsTest { @@ -113,8 +116,7 @@ void joinGroup() throws Exception { "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); // then - perform.andExpect(status().isOk()) - .andExpect(jsonPath("$.groupId").isString()); + perform.andExpect(status().isOk()).andExpect(jsonPath("$.groupId").isString()); // docs perform.andDo(print()) @@ -125,7 +127,9 @@ void joinGroup() throws Exception { @DisplayName("그룹 초대 API가 수행되는가") void inviteGroup() throws Exception { // given - final GroupInfoResponse expected = new GroupInfoResponse(UUID.randomUUID(), UUID.randomUUID(), "홍담진", "http://someUrlToS3"); + final GroupInfoResponse expected = + new GroupInfoResponse( + UUID.randomUUID(), UUID.randomUUID(), "홍담진", "http://someUrlToS3"); given(groupService.inviteGroup(any())).willReturn(expected); // when @@ -133,7 +137,10 @@ void inviteGroup() throws Exception { mockMvc.perform( post("/group/invite") .contentType(MediaType.APPLICATION_JSON) - .content(toRequestBody(new InviteGroupRequest(UUID.randomUUID(), UUID.randomUUID()))) + .content( + toRequestBody( + new InviteGroupRequest( + UUID.randomUUID(), UUID.randomUUID()))) .header( "Authorization", "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); @@ -156,7 +163,10 @@ void changeShare() throws Exception { mockMvc.perform( post("/group/share/" + UUID.randomUUID()) .contentType(MediaType.APPLICATION_JSON) - .content(toRequestBody(new InviteGroupRequest(UUID.randomUUID(), UUID.randomUUID()))) + .content( + toRequestBody( + new InviteGroupRequest( + UUID.randomUUID(), UUID.randomUUID()))) .header( "Authorization", "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); @@ -173,7 +183,8 @@ void changeShare() throws Exception { @DisplayName("위치 공유 조회 API가 수행되는가") void getShare() throws Exception { // given - final ShareInfoResponse expected = new ShareInfoResponse(UUID.randomUUID(), UUID.randomUUID(), true); + final ShareInfoResponse expected = + new ShareInfoResponse(UUID.randomUUID(), UUID.randomUUID(), true); given(groupService.getShare(any())).willReturn(expected); // when @@ -181,14 +192,16 @@ void getShare() throws Exception { mockMvc.perform( get("/group/share/" + UUID.randomUUID()) .contentType(MediaType.APPLICATION_JSON) - .content(toRequestBody(new InviteGroupRequest(UUID.randomUUID(), UUID.randomUUID()))) + .content( + toRequestBody( + new InviteGroupRequest( + UUID.randomUUID(), UUID.randomUUID()))) .header( "Authorization", "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); // then - perform.andExpect(status().isOk()) - .andExpect(jsonPath("$.share").isBoolean()); + perform.andExpect(status().isOk()).andExpect(jsonPath("$.share").isBoolean()); // docs perform.andDo(print()) diff --git a/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java index 2bea85f0..db1b98e7 100644 --- a/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java @@ -2,6 +2,7 @@ import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; + import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; @@ -23,8 +24,7 @@ import com.twtw.backend.domain.plan.dto.response.PlanResponse; import com.twtw.backend.domain.plan.service.PlanService; import com.twtw.backend.support.docs.RestDocsTest; -import java.util.List; -import java.util.UUID; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -32,6 +32,9 @@ import org.springframework.http.MediaType; import org.springframework.test.web.servlet.ResultActions; +import java.util.List; +import java.util.UUID; + @DisplayName("PlanController의") @WebMvcTest(PlanController.class) class PlanControllerTest extends RestDocsTest { @@ -107,15 +110,20 @@ void savePlan() throws Exception { mockMvc.perform( post("/plans") .contentType(MediaType.APPLICATION_JSON) - .content(toRequestBody(new SavePlanRequest(UUID.randomUUID(), new PlaceDetails("카페 온마이마인드", - "345", - "https://place.map.kakao.com/1625295668", - "음식점 > 카페", - "경기 안성시 죽산면 죽산리 414", - "경기 안성시 죽산면 죽산초교길 36-4", - CategoryGroupCode.CE7, - "127.420430538256", - "37.0766874564297")))) + .content( + toRequestBody( + new SavePlanRequest( + UUID.randomUUID(), + new PlaceDetails( + "카페 온마이마인드", + "345", + "https://place.map.kakao.com/1625295668", + "음식점 > 카페", + "경기 안성시 죽산면 죽산리 414", + "경기 안성시 죽산면 죽산초교길 36-4", + CategoryGroupCode.CE7, + "127.420430538256", + "37.0766874564297")))) .header( "Authorization", "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); @@ -133,15 +141,23 @@ void savePlan() throws Exception { @DisplayName("단건 조회 API가 수행되는가") void getPlanById() throws Exception { // given - final PlanInfoResponse expected = new PlanInfoResponse(UUID.randomUUID(), UUID.randomUUID(), new PlaceDetails("카페 온마이마인드", - "345", - "https://place.map.kakao.com/1625295668", - "음식점 > 카페", - "경기 안성시 죽산면 죽산리 414", - "경기 안성시 죽산면 죽산초교길 36-4", - CategoryGroupCode.CE7, - "127.420430538256", - "37.0766874564297"), new GroupInfoResponse(UUID.randomUUID(), UUID.randomUUID(), "홍담진", "http://someUrlToS3"), List.of(new MemberResponse(UUID.randomUUID(), "진호정"))); + final PlanInfoResponse expected = + new PlanInfoResponse( + UUID.randomUUID(), + UUID.randomUUID(), + new PlaceDetails( + "카페 온마이마인드", + "345", + "https://place.map.kakao.com/1625295668", + "음식점 > 카페", + "경기 안성시 죽산면 죽산리 414", + "경기 안성시 죽산면 죽산초교길 36-4", + CategoryGroupCode.CE7, + "127.420430538256", + "37.0766874564297"), + new GroupInfoResponse( + UUID.randomUUID(), UUID.randomUUID(), "홍담진", "http://someUrlToS3"), + List.of(new MemberResponse(UUID.randomUUID(), "진호정"))); given(planService.getPlanById(any())).willReturn(expected); // when @@ -193,16 +209,20 @@ void joinPlan() throws Exception { mockMvc.perform( post("/plans/join") .contentType(MediaType.APPLICATION_JSON) - .content(toRequestBody(new SavePlanRequest(UUID.randomUUID(), new PlaceDetails( - "이디야커피 안성죽산점", - "435", - "http://place.map.kakao.com/1562566188", - "음식점 > 카페 > 커피전문점 > 이디야커피", - "경기 안성시 죽산면 죽산리 118-3", - "경기 안성시 죽산면 죽주로 287-1", - CategoryGroupCode.CE7, - "127.426865189637", - "37.0764635355795")))) + .content( + toRequestBody( + new SavePlanRequest( + UUID.randomUUID(), + new PlaceDetails( + "이디야커피 안성죽산점", + "435", + "http://place.map.kakao.com/1562566188", + "음식점 > 카페 > 커피전문점 > 이디야커피", + "경기 안성시 죽산면 죽산리 118-3", + "경기 안성시 죽산면 죽주로 287-1", + CategoryGroupCode.CE7, + "127.426865189637", + "37.0764635355795")))) .header( "Authorization", "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh"));