Skip to content

Commit cd5ac80

Browse files
committed
MNG-20 docs: docs 파일 생성
1 parent d73cf59 commit cd5ac80

File tree

7 files changed

+256
-28
lines changed

7 files changed

+256
-28
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[[Mission-Comment-API]]
2+
= Mission Comment API
3+
4+
[[Mission-Comment-댓글-생성]]
5+
== Mission Comment 댓글 생성
6+
operation::mission-comment-controller-test/create_mission_comment[snippets='http-request,path-parameters,request-fields,http-response,response-fields']
7+
---
8+
9+
[[Mission-Comment-댓글-삭제]]
10+
== Mission Comment 댓글 삭제
11+
operation::mission-comment-controller-test/delete_mission_comment[snippets='http-request,path-parameters,response-fields']
12+
---
13+
14+
[[MissionArchive-Comment-댓글-전체-조회]]
15+
== Mission Comment 댓글 전체 조회
16+
operation::mission-comment-controller-test/get_board_comment_all[snippets='http-request,path-parameters,http-response,response-fields']
17+
---

src/docs/asciidoc/api.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ include::Mission-API.adoc[]
2222

2323
include::MissionArchive-API.adoc[]
2424

25+
include::MissionArchiveComment_API.adoc[]
26+
2527
include::MissionBoard-API.adoc[]
2628

2729
include::MissionGatherBoard-API.adoc[]

src/main/java/com/moing/backend/domain/board/presentation/BoardController.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,4 @@ public ResponseEntity<SuccessResponse<GetAllBoardResponse>> getBoardAll(@Authent
9292
return ResponseEntity.ok(SuccessResponse.create(GET_BOARD_ALL_SUCCESS.getMessage(), this.getBoardUseCase.getAllBoard(user.getSocialId(), teamId)));
9393
}
9494

95-
@PostMapping("/test")
96-
public void test() {
97-
Thread thread1 = new Thread(() -> {
98-
this.getBoardUseCase.getBoardDetail("KAKAO@tester01", 1L,1L);
99-
});
100-
Thread thread2 = new Thread(() -> {
101-
this.getBoardUseCase.getBoardDetail("KAKAO@tester01", 1L,1L);
102-
});
103-
thread1.start();
104-
thread2.start();
105-
}
106-
10795
}

src/test/java/com/moing/backend/domain/boardComment/presentation/BoardCommentControllerTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.moing.backend.domain.boardComment.presentation;
22

33
import com.moing.backend.config.CommonControllerTest;
4-
import com.moing.backend.domain.boardComment.application.dto.request.CreateBoardCommentRequest;
5-
import com.moing.backend.domain.boardComment.application.dto.response.CommentBlocks;
6-
import com.moing.backend.domain.boardComment.application.dto.response.CreateBoardCommentResponse;
7-
import com.moing.backend.domain.boardComment.application.dto.response.GetBoardCommentResponse;
84
import com.moing.backend.domain.boardComment.application.service.CreateBoardCommentUseCase;
95
import com.moing.backend.domain.boardComment.application.service.DeleteBoardCommentUseCase;
106
import com.moing.backend.domain.boardComment.application.service.GetBoardCommentUseCase;
117
import com.moing.backend.domain.boardComment.presentattion.BoardCommentController;
8+
import com.moing.backend.domain.comment.application.dto.request.CreateCommentRequest;
9+
import com.moing.backend.domain.comment.application.dto.response.CommentBlocks;
10+
import com.moing.backend.domain.comment.application.dto.response.CreateCommentResponse;
11+
import com.moing.backend.domain.comment.application.dto.response.GetCommentResponse;
1212
import org.junit.jupiter.api.Test;
1313
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
1414
import org.springframework.boot.test.mock.mockito.MockBean;
@@ -44,14 +44,14 @@ public void create_board_comment() throws Exception {
4444
//given
4545
Long teamId = 1L;
4646
Long boardId = 1L;
47-
CreateBoardCommentRequest input = CreateBoardCommentRequest.builder()
47+
CreateCommentRequest input = CreateCommentRequest.builder()
4848
.content("게시글 내용")
4949
.build();
5050

5151
String body = objectMapper.writeValueAsString(input);
5252

53-
CreateBoardCommentResponse output = CreateBoardCommentResponse.builder()
54-
.boardCommentId(1L)
53+
CreateCommentResponse output = CreateCommentResponse.builder()
54+
.commentId(1L)
5555
.build();
5656

5757
given(createBoardCommentUseCase.createBoardComment(any(), any(), any(), any())).willReturn(output);
@@ -83,7 +83,7 @@ public void create_board_comment() throws Exception {
8383
responseFields(
8484
fieldWithPath("isSuccess").description("true"),
8585
fieldWithPath("message").description("댓글을 생성했습니다"),
86-
fieldWithPath("data.boardCommentId").description("생성한 boardCommentId")
86+
fieldWithPath("data.commentId").description("생성한 boardCommentId")
8787
)
8888
)
8989
);
@@ -135,7 +135,7 @@ public void get_board_comment_all() throws Exception {
135135
Long boardId = 1L;
136136

137137
CommentBlocks commentBlock = CommentBlocks.builder()
138-
.boardCommentId(1L)
138+
.commentId(1L)
139139
.content("댓글 내용")
140140
.writerIsLeader(true)
141141
.writerNickName("작성자 닉네임")
@@ -148,7 +148,7 @@ public void get_board_comment_all() throws Exception {
148148

149149
commentBlocks.add(commentBlock);
150150

151-
GetBoardCommentResponse output = new GetBoardCommentResponse(commentBlocks);
151+
GetCommentResponse output = new GetCommentResponse(commentBlocks);
152152

153153
given(getBoardCommentUseCase.getBoardCommentAll(any(), any(), any())).willReturn(output);
154154

@@ -176,7 +176,7 @@ public void get_board_comment_all() throws Exception {
176176
responseFields(
177177
fieldWithPath("isSuccess").description("true"),
178178
fieldWithPath("message").description("댓글 목록을 모두 조회했습니다."),
179-
fieldWithPath("data.commentBlocks[].boardCommentId").description("댓글 아이디"),
179+
fieldWithPath("data.commentBlocks[].commentId").description("댓글 아이디"),
180180
fieldWithPath("data.commentBlocks[].content").description("댓글 내용"),
181181
fieldWithPath("data.commentBlocks[].writerIsLeader").description("작성자 소모임장 여부"),
182182
fieldWithPath("data.commentBlocks[].writerNickName").description("작성자 닉네임"),

src/test/java/com/moing/backend/domain/missionArchive/representation/MissionArchiveControllerTest.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public class MissionArchiveControllerTest extends CommonControllerTest {
6666
.heartStatus("[True/False]")
6767
.hearts(1L)
6868
.contents("contents")
69+
.comments(1L)
6970
.build();
7071

7172
given(missionArchiveCreateUseCase.createArchive(any(),any(),any())).willReturn(output);
@@ -110,8 +111,10 @@ public class MissionArchiveControllerTest extends CommonControllerTest {
110111
fieldWithPath("data.count").description("미션 인증 횟수"),
111112
fieldWithPath("data.hearts").description("미션 인증 좋아요 수"),
112113
fieldWithPath("data.heartStatus").description("미션 인증 좋아요 상태"),
113-
fieldWithPath("data.contents").description("미션 인증 문구")
114-
)
114+
fieldWithPath("data.contents").description("미션 인증 문구"),
115+
fieldWithPath("data.comments").description("미션 댓글 개수")
116+
117+
)
115118
)
116119
)
117120
.andReturn();
@@ -139,6 +142,7 @@ public class MissionArchiveControllerTest extends CommonControllerTest {
139142
.heartStatus("[True/False]")
140143
.hearts(1L)
141144
.contents("contents")
145+
.comments(1L)
142146
.build();
143147

144148
given(missionArchiveUpdateUseCase.updateArchive(any(),any(),any())).willReturn(output);
@@ -183,9 +187,10 @@ public class MissionArchiveControllerTest extends CommonControllerTest {
183187
fieldWithPath("data.count").description("미션 인증 횟수"),
184188
fieldWithPath("data.heartStatus").description("미션 인증 좋아요 상태"),
185189
fieldWithPath("data.hearts").description("미션 인증 좋아요 수"),
186-
fieldWithPath("data.contents").description("미션 인증 문구")
190+
fieldWithPath("data.contents").description("미션 인증 문구"),
191+
fieldWithPath("data.comments").description("미션 댓글 개수")
187192

188-
)
193+
)
189194
)
190195
)
191196
.andReturn();
@@ -248,6 +253,7 @@ public class MissionArchiveControllerTest extends CommonControllerTest {
248253
.heartStatus("[True/False]")
249254
.hearts(1L)
250255
.contents("contents")
256+
.comments(1L)
251257
.build());
252258

253259
MyMissionArchiveRes output = MyMissionArchiveRes.builder()
@@ -291,7 +297,8 @@ public class MissionArchiveControllerTest extends CommonControllerTest {
291297
fieldWithPath("data.archives[].count").description("미션 인증 횟수"),
292298
fieldWithPath("data.archives[].heartStatus").description("미션 인증 좋아요 상태"),
293299
fieldWithPath("data.archives[].hearts").description("미션 인증 좋아요 수"),
294-
fieldWithPath("data.archives[].contents").description("미션 인증 문구")
300+
fieldWithPath("data.archives[].contents").description("미션 인증 문구"),
301+
fieldWithPath("data.archives[].comments").description("미션 댓글 개수")
295302

296303

297304
)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.moing.backend.domain.missionComment.domain;
2+
3+
import com.moing.backend.domain.missionComment.domain.repository.MissionCommentRepository;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
6+
import org.springframework.boot.test.context.SpringBootTest;
7+
import org.springframework.test.context.ActiveProfiles;
8+
import org.springframework.transaction.annotation.Transactional;
9+
10+
@SpringBootTest
11+
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
12+
@ActiveProfiles("dev")
13+
@Transactional
14+
public class MissionRepositoryTest {
15+
16+
@Autowired
17+
MissionCommentRepository missionCommentRepository;
18+
public void create_Mission_Comment(){
19+
20+
}
21+
22+
}
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
package com.moing.backend.domain.missionComment.presentation;
2+
3+
import com.moing.backend.config.CommonControllerTest;
4+
import com.moing.backend.domain.comment.application.dto.request.CreateCommentRequest;
5+
import com.moing.backend.domain.comment.application.dto.response.CommentBlocks;
6+
import com.moing.backend.domain.comment.application.dto.response.CreateCommentResponse;
7+
import com.moing.backend.domain.comment.application.dto.response.GetCommentResponse;
8+
import com.moing.backend.domain.missionComment.application.service.CreateMissionCommentUseCase;
9+
import com.moing.backend.domain.missionComment.application.service.DeleteMissionCommentUseCase;
10+
import com.moing.backend.domain.missionComment.application.service.GetMissionCommentUseCase;
11+
import org.junit.jupiter.api.Test;
12+
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
13+
import org.springframework.boot.test.mock.mockito.MockBean;
14+
import org.springframework.http.MediaType;
15+
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
16+
import org.springframework.test.web.servlet.ResultActions;
17+
18+
import java.util.ArrayList;
19+
import java.util.List;
20+
21+
import static org.mockito.ArgumentMatchers.any;
22+
import static org.mockito.BDDMockito.given;
23+
import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName;
24+
import static org.springframework.restdocs.headers.HeaderDocumentation.requestHeaders;
25+
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
26+
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
27+
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
28+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
29+
30+
@WebMvcTest(MissionCommentController.class)
31+
public class MissionCommentControllerTest extends CommonControllerTest {
32+
33+
@MockBean
34+
private CreateMissionCommentUseCase createMissionCommentUseCase;
35+
@MockBean
36+
private DeleteMissionCommentUseCase deleteMissionCommentUseCase;
37+
@MockBean
38+
private GetMissionCommentUseCase getMissionCommentUseCase;
39+
40+
@Test
41+
public void create_mission_comment() throws Exception {
42+
43+
//given
44+
Long teamId = 1L;
45+
Long missionArchiveId = 1L;
46+
CreateCommentRequest input = CreateCommentRequest.builder()
47+
.content("게시글 내용")
48+
.build();
49+
50+
String body = objectMapper.writeValueAsString(input);
51+
52+
CreateCommentResponse output = CreateCommentResponse.builder()
53+
.commentId(1L)
54+
.build();
55+
56+
given(createMissionCommentUseCase.createBoardComment(any(), any(), any(), any())).willReturn(output);
57+
58+
59+
//when
60+
ResultActions actions = mockMvc.perform(RestDocumentationRequestBuilders.
61+
post("/api/{teamId}/{missionArchiveId}/mcomment", teamId, missionArchiveId)
62+
.header("Authorization", "Bearer ACCESS_TOKEN")
63+
.contentType(MediaType.APPLICATION_JSON)
64+
.content(body)
65+
);
66+
67+
//then
68+
actions
69+
.andExpect(status().isOk())
70+
.andDo(
71+
restDocs.document(
72+
requestHeaders(
73+
headerWithName("Authorization").description("접근 토큰")
74+
),
75+
pathParameters(
76+
parameterWithName("teamId").description("팀 아이디"),
77+
parameterWithName("missionArchiveId").description("미션 게시물 아이디")
78+
),
79+
requestFields(
80+
fieldWithPath("content").description("댓글 내용")
81+
),
82+
responseFields(
83+
fieldWithPath("isSuccess").description("true"),
84+
fieldWithPath("message").description("댓글을 생성했습니다"),
85+
fieldWithPath("data.commentId").description("생성한 boardCommentId")
86+
)
87+
)
88+
);
89+
}
90+
91+
@Test
92+
public void delete_mission_comment() throws Exception {
93+
94+
//given
95+
Long teamId = 1L;
96+
Long boardId = 1L;
97+
Long missionArchiveId = 1L;
98+
99+
100+
//when
101+
ResultActions actions = mockMvc.perform(RestDocumentationRequestBuilders.
102+
delete("/api/{teamId}/{missionArchiveId}/mcomment/{boardCommentId}", teamId, boardId, missionArchiveId)
103+
.header("Authorization", "Bearer ACCESS_TOKEN")
104+
.contentType(MediaType.APPLICATION_JSON)
105+
);
106+
107+
//then
108+
actions
109+
.andExpect(status().isOk())
110+
.andDo(
111+
restDocs.document(
112+
requestHeaders(
113+
headerWithName("Authorization").description("접근 토큰")
114+
),
115+
pathParameters(
116+
parameterWithName("teamId").description("팀 아이디"),
117+
parameterWithName("missionArchiveId").description("미션 게시글 아이디"),
118+
parameterWithName("boardCommentId").description("댓글 아이디")
119+
),
120+
responseFields(
121+
fieldWithPath("isSuccess").description("true"),
122+
fieldWithPath("message").description("댓글을 삭제했습니다")
123+
)
124+
)
125+
);
126+
}
127+
128+
129+
@Test
130+
public void get_board_comment_all() throws Exception {
131+
//given
132+
List<CommentBlocks> commentBlocks = new ArrayList<>();
133+
Long teamId = 1L;
134+
Long boardId = 1L;
135+
136+
CommentBlocks commentBlock = CommentBlocks.builder()
137+
.commentId(1L)
138+
.content("댓글 내용")
139+
.writerIsLeader(true)
140+
.writerNickName("작성자 닉네임")
141+
.writerProfileImage("작성자 프로필 이미지")
142+
.writerIsDeleted(false)
143+
.isWriter(true)
144+
.createdDate("2023/12/05 23:29")
145+
.makerId(1L)
146+
.build();
147+
148+
commentBlocks.add(commentBlock);
149+
150+
GetCommentResponse output = new GetCommentResponse(commentBlocks);
151+
152+
given(getMissionCommentUseCase.getBoardCommentAll(any(), any(), any())).willReturn(output);
153+
154+
155+
//when
156+
ResultActions actions = mockMvc.perform(RestDocumentationRequestBuilders.
157+
get("/api/{teamId}/{missionArchiveId}/mcomment", teamId, boardId)
158+
.header("Authorization", "Bearer ACCESS_TOKEN")
159+
.contentType(MediaType.APPLICATION_JSON)
160+
);
161+
162+
163+
//then
164+
actions
165+
.andExpect(status().isOk())
166+
.andDo(
167+
restDocs.document(
168+
requestHeaders(
169+
headerWithName("Authorization").description("접근 토큰")
170+
),
171+
pathParameters(
172+
parameterWithName("teamId").description("팀 아이디"),
173+
parameterWithName("missionArchiveId").description("게시글 아이디")
174+
),
175+
responseFields(
176+
fieldWithPath("isSuccess").description("true"),
177+
fieldWithPath("message").description("댓글 목록을 모두 조회했습니다."),
178+
fieldWithPath("data.commentBlocks[].commentId").description("댓글 아이디"),
179+
fieldWithPath("data.commentBlocks[].content").description("댓글 내용"),
180+
fieldWithPath("data.commentBlocks[].writerIsLeader").description("작성자 소모임장 여부"),
181+
fieldWithPath("data.commentBlocks[].writerNickName").description("작성자 닉네임"),
182+
fieldWithPath("data.commentBlocks[].writerProfileImage").description("작성자 프로필 이미지"),
183+
fieldWithPath("data.commentBlocks[].writerIsDeleted").description("작성자 삭제 여부"),
184+
fieldWithPath("data.commentBlocks[].isWriter").description("댓글 작성자 여부"),
185+
fieldWithPath("data.commentBlocks[].createdDate").description("생성 시간"),
186+
fieldWithPath("data.commentBlocks[].makerId").description("작성자 Id")
187+
)
188+
189+
)
190+
);
191+
}
192+
}

0 commit comments

Comments
 (0)