Skip to content

Commit

Permalink
Merge pull request #63 from HongDam-org/feat/group-plan-api-docs
Browse files Browse the repository at this point in the history
[FEAT] group plan api docs
  • Loading branch information
ohksj77 authored Nov 15, 2023
2 parents c5fc0bf + ae27bdb commit fcca6a6
Show file tree
Hide file tree
Showing 7 changed files with 327 additions and 6 deletions.
24 changes: 24 additions & 0 deletions backend/src/docs/group.adoc
Original file line number Diff line number Diff line change
@@ -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']
1 change: 1 addition & 0 deletions backend/src/docs/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ include::plan.adoc[]
include::place.adoc[]
include::member.adoc[]
include::friend.adoc[]
include::group.adoc[]
15 changes: 15 additions & 0 deletions backend/src/docs/plan.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ResponseEntity<GroupInfoResponse> getGroupById(@PathVariable UUID id) {
return ResponseEntity.ok(groupService.getGroupById(id));
}

@PostMapping()
@PostMapping
public ResponseEntity<GroupInfoResponse> makeGroup(
@RequestBody MakeGroupRequest makeGroupRequest) {
return ResponseEntity.ok(groupService.makeGroup(makeGroupRequest));
Expand All @@ -45,14 +45,14 @@ public ResponseEntity<GroupInfoResponse> inviteGroup(
return ResponseEntity.ok(groupService.inviteGroup(inviteGroupRequest));
}

@PutMapping("/share/{id}")
@PostMapping("/share/{id}")
public ResponseEntity<Void> changeShare(@PathVariable UUID id) {
groupService.changeShare(id);
return ResponseEntity.ok().build();
return ResponseEntity.noContent().build();
}

@GetMapping("/share/{id}")
public ResponseEntity<ShareInfoResponse> getshare(@PathVariable UUID id) {
public ResponseEntity<ShareInfoResponse> getShare(@PathVariable UUID id) {
return ResponseEntity.ok(groupService.getShare(id));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ public class PlanInfoResponse {
private UUID placeId;
private PlaceDetails placeDetail;
private GroupInfoResponse groupInfoResponse;
private List<MemberResponse> memberList;
private List<MemberResponse> members;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
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;

Expand All @@ -28,7 +32,7 @@

@DisplayName("GroupController의")
@WebMvcTest(GroupController.class)
public class GroupControllerTest extends RestDocsTest {
class GroupControllerTest extends RestDocsTest {
@MockBean private GroupService groupService;

@Test
Expand Down Expand Up @@ -93,4 +97,114 @@ 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()));
}
}
Loading

0 comments on commit fcca6a6

Please sign in to comment.