-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1583 from woowacourse/article-develop
Article develop main merge
- Loading branch information
Showing
47 changed files
with
1,803 additions
and
135 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[[article]] | ||
== 아티클 | ||
|
||
=== 아티클 북마크 추가 | ||
|
||
==== Request | ||
|
||
include::{snippets}/article/bookmark/http-request.adoc[] | ||
|
||
==== Response | ||
|
||
include::{snippets}/article/bookmark/http-response.adoc[] | ||
|
||
=== 아티클 좋아요 추가 | ||
|
||
==== Request | ||
|
||
include::{snippets}/article/likes/http-request.adoc[] | ||
|
||
==== Response | ||
|
||
include::{snippets}/article/likes/http-response.adoc[] | ||
|
||
=== 아티클 조회수 추가 | ||
|
||
==== Request | ||
|
||
include::{snippets}/article/views/http-request.adoc[] | ||
|
||
==== Response | ||
|
||
include::{snippets}/article/views/http-response.adoc[] |
74 changes: 74 additions & 0 deletions
74
backend/src/documentation/java/wooteco/prolog/docu/ArticleDocumentation.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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package wooteco.prolog.docu; | ||
|
||
import static io.netty.handler.codec.http.HttpHeaders.Values.APPLICATION_JSON; | ||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
import io.restassured.module.mockmvc.response.ValidatableMockMvcResponse; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import wooteco.prolog.NewDocumentation; | ||
import wooteco.prolog.article.application.ArticleService; | ||
import wooteco.prolog.article.ui.ArticleBookmarkRequest; | ||
import wooteco.prolog.article.ui.ArticleController; | ||
import wooteco.prolog.article.ui.ArticleLikesRequest; | ||
|
||
@WebMvcTest(controllers = ArticleController.class) | ||
public class ArticleDocumentation extends NewDocumentation { | ||
|
||
@MockBean | ||
private ArticleService articleService; | ||
|
||
@Test | ||
void 아티클에_북마크를_변경한다() { | ||
//given, when | ||
final ArticleBookmarkRequest bookmarkRequest = new ArticleBookmarkRequest(true); | ||
|
||
final ValidatableMockMvcResponse response = given | ||
.header("Authorization", "Bearer " + accessToken) | ||
.contentType(APPLICATION_JSON) | ||
.body(bookmarkRequest) | ||
.when().put("/articles/{article-id}/bookmark", 1L) | ||
.then().log().all(); | ||
|
||
//then | ||
response.expect(status().isOk()); | ||
|
||
//docs | ||
response.apply(document("article/bookmark")); | ||
} | ||
|
||
@Test | ||
void 아티클에_좋아요를_변경한다() { | ||
//given, when | ||
final ArticleLikesRequest articleLikesRequest = new ArticleLikesRequest(true); | ||
|
||
final ValidatableMockMvcResponse response = given | ||
.header("Authorization", "Bearer " + accessToken) | ||
.contentType(APPLICATION_JSON) | ||
.body(articleLikesRequest) | ||
.when().put("/articles/{article-id}/like", 1L) | ||
.then().log().all(); | ||
|
||
//then | ||
response.expect(status().isOk()); | ||
|
||
//docs | ||
response.apply(document("article/like")); | ||
} | ||
|
||
@Test | ||
void 아티클의_조회수를_증가시킨다() { | ||
//given, when | ||
final ValidatableMockMvcResponse response = given | ||
.when().post("/articles/{article-id}/views", 1L) | ||
.then().log().all(); | ||
|
||
//then | ||
response.expect(status().isOk()); | ||
|
||
//docs | ||
response.apply(document("article/views")); | ||
} | ||
} |
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
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
Oops, something went wrong.