-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
== 밸런스 게임 | ||
|
||
=== 카테고리 목록 조회 | ||
|
||
==== curl | ||
|
||
include::{snippets}/balance/category/curl-request.adoc[] | ||
|
||
==== request | ||
|
||
include::{snippets}/balance/category/http-request.adoc[] | ||
|
||
==== response | ||
|
||
include::{snippets}/balance/category/http-response.adoc[] | ||
|
||
response fields | ||
|
||
include::{snippets}/balance/category/response-fields.adoc[] | ||
|
||
''' |
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
48 changes: 48 additions & 0 deletions
48
backend/src/test/java/ddangkong/documentation/balance/BalanceDocumentationTest.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,48 @@ | ||
package ddangkong.documentation.balance; | ||
|
||
import static org.mockito.Mockito.when; | ||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; | ||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; | ||
import static org.springframework.restdocs.payload.JsonFieldType.ARRAY; | ||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; | ||
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
import ddangkong.controller.balance.BalanceController; | ||
import ddangkong.documentation.BaseDocumentationTest; | ||
import ddangkong.domain.balance.content.Category; | ||
import ddangkong.facade.balance.content.BalanceCategoriesResponse; | ||
import ddangkong.facade.balance.content.BalanceFacade; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
|
||
@WebMvcTest(BalanceController.class) | ||
public class BalanceDocumentationTest extends BaseDocumentationTest { | ||
|
||
@MockBean | ||
private BalanceFacade balanceFacade; | ||
|
||
@Nested | ||
class 카테고리 { | ||
|
||
private static final String ENDPOINT = "/api/balances/categories"; | ||
|
||
@Test | ||
void 카테고리_목록을_조회한다() throws Exception { | ||
// given | ||
BalanceCategoriesResponse response = BalanceCategoriesResponse.from(Category.getCategories()); | ||
when(balanceFacade.getBalanceCategories()).thenReturn(response); | ||
|
||
// when & then | ||
mockMvc.perform(get(ENDPOINT)) | ||
.andExpect(status().isOk()) | ||
.andDo(document("balance/category", | ||
responseFields( | ||
fieldWithPath("categories").type(ARRAY).description("카테고리 목록") | ||
) | ||
)); | ||
} | ||
} | ||
} |