8 changed files with 2728 additions and 7 deletions
@ -0,0 +1,175 @@ |
|||||||
|
ifndef::snippets[] |
||||||
|
:snippets: ./build/generated-snippets |
||||||
|
endif::[] |
||||||
|
|
||||||
|
= KAC App Docs |
||||||
|
API 문서 |
||||||
|
:doctype: book |
||||||
|
:icons: font |
||||||
|
:source-highlighter: highlightjs |
||||||
|
:toc: left |
||||||
|
:toclevels: 2 |
||||||
|
:sectlinks: |
||||||
|
|
||||||
|
[[Common-Code-API]] |
||||||
|
== Common-Code API |
||||||
|
|
||||||
|
[[Code-All]] |
||||||
|
=== [Code 전체코드 조회] |
||||||
|
|
||||||
|
==== [HTTP REQUEST INFO] |
||||||
|
include::{snippets}/com/code/all/http-request.adoc[] |
||||||
|
include::{snippets}/com/code/all/query-parameters.adoc[] |
||||||
|
|
||||||
|
==== [HTTP RESPONSE INFO] |
||||||
|
include::{snippets}/com/code/all/http-response.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/all/response-fields.adoc[] |
||||||
|
|
||||||
|
*** |
||||||
|
|
||||||
|
=== [Code 코드목록 조회] |
||||||
|
|
||||||
|
==== [HTTP REQUEST INFO] |
||||||
|
include::{snippets}/com/code/code/http-request.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/code/query-parameters.adoc[] |
||||||
|
|
||||||
|
==== [HTTP RESPONSE INFO] |
||||||
|
include::{snippets}/com/code/code/http-response.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/code/response-fields.adoc[] |
||||||
|
|
||||||
|
*** |
||||||
|
|
||||||
|
=== [Code 그룹목록 조회] |
||||||
|
|
||||||
|
==== [HTTP REQUEST INFO] |
||||||
|
include::{snippets}/com/code/group/http-request.adoc[] |
||||||
|
|
||||||
|
==== [HTTP RESPONSE INFO] |
||||||
|
include::{snippets}/com/code/group/http-response.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/group/response-fields.adoc[] |
||||||
|
|
||||||
|
*** |
||||||
|
|
||||||
|
=== [Code 그룹 등록] |
||||||
|
|
||||||
|
==== [HTTP REQUEST INFO] |
||||||
|
include::{snippets}/com/code/group/create/http-request.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/group/create/request-fields.adoc[] |
||||||
|
|
||||||
|
==== [HTTP RESPONSE INFO] |
||||||
|
include::{snippets}/com/code/group/create/http-response.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/group/create/response-fields.adoc[] |
||||||
|
|
||||||
|
*** |
||||||
|
|
||||||
|
=== [Code 코드 등록] |
||||||
|
|
||||||
|
==== [HTTP REQUEST INFO] |
||||||
|
include::{snippets}/com/code/code/create/http-request.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/code/create/request-fields.adoc[] |
||||||
|
|
||||||
|
==== [HTTP RESPONSE INFO] |
||||||
|
include::{snippets}/com/code/code/create/http-response.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/code/create/response-fields.adoc[] |
||||||
|
|
||||||
|
*** |
||||||
|
|
||||||
|
=== [Code 코드언어 등록] |
||||||
|
|
||||||
|
==== [HTTP REQUEST INFO] |
||||||
|
include::{snippets}/com/code/lang/create/http-request.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/lang/create/request-fields.adoc[] |
||||||
|
|
||||||
|
==== [HTTP RESPONSE INFO] |
||||||
|
include::{snippets}/com/code/lang/create/http-response.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/lang/create/response-fields.adoc[] |
||||||
|
|
||||||
|
*** |
||||||
|
|
||||||
|
=== [Code 그룹 수정] |
||||||
|
|
||||||
|
==== [HTTP REQUEST INFO] |
||||||
|
include::{snippets}/com/code/group/update/http-request.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/group/update/request-fields.adoc[] |
||||||
|
|
||||||
|
==== [HTTP RESPONSE INFO] |
||||||
|
include::{snippets}/com/code/group/update/http-response.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/group/update/response-fields.adoc[] |
||||||
|
|
||||||
|
*** |
||||||
|
|
||||||
|
=== [Code 코드 수정] |
||||||
|
|
||||||
|
==== [HTTP REQUEST INFO] |
||||||
|
include::{snippets}/com/code/code/update/http-request.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/code/update/request-fields.adoc[] |
||||||
|
|
||||||
|
==== [HTTP RESPONSE INFO] |
||||||
|
include::{snippets}/com/code/code/update/http-response.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/code/update/response-fields.adoc[] |
||||||
|
|
||||||
|
*** |
||||||
|
|
||||||
|
=== [Code 코드언어 수정] |
||||||
|
|
||||||
|
==== [HTTP REQUEST INFO] |
||||||
|
include::{snippets}/com/code/lang/update/http-request.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/lang/update/request-fields.adoc[] |
||||||
|
|
||||||
|
==== [HTTP RESPONSE INFO] |
||||||
|
include::{snippets}/com/code/lang/update/http-response.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/lang/update/response-fields.adoc[] |
||||||
|
|
||||||
|
*** |
||||||
|
|
||||||
|
=== [Code 그룹 삭제] |
||||||
|
|
||||||
|
==== [HTTP REQUEST INFO] |
||||||
|
include::{snippets}/com/code/group/delete/http-request.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/group/delete/query-parameters.adoc[] |
||||||
|
|
||||||
|
==== [HTTP RESPONSE INFO] |
||||||
|
include::{snippets}/com/code/group/delete/http-response.adoc[] |
||||||
|
|
||||||
|
*** |
||||||
|
|
||||||
|
=== [Code 코드 삭제] |
||||||
|
|
||||||
|
==== [HTTP REQUEST INFO] |
||||||
|
include::{snippets}/com/code/code/delete/http-request.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/code/delete/query-parameters.adoc[] |
||||||
|
|
||||||
|
==== [HTTP RESPONSE INFO] |
||||||
|
include::{snippets}/com/code/code/delete/http-response.adoc[] |
||||||
|
|
||||||
|
*** |
||||||
|
|
||||||
|
=== [Code 언어 삭제] |
||||||
|
|
||||||
|
==== [HTTP REQUEST INFO] |
||||||
|
include::{snippets}/com/code/lang/delete/http-request.adoc[] |
||||||
|
|
||||||
|
include::{snippets}/com/code/lang/delete/query-parameters.adoc[] |
||||||
|
|
||||||
|
==== [HTTP RESPONSE INFO] |
||||||
|
include::{snippets}/com/code/lang/delete/http-response.adoc[] |
||||||
|
|
||||||
|
*** |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,39 @@ |
|||||||
|
package kr.co.palnet.kac; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper; |
||||||
|
import org.junit.jupiter.api.BeforeEach; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.restdocs.RestDocumentationContextProvider; |
||||||
|
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation; |
||||||
|
import org.springframework.test.web.servlet.MockMvc; |
||||||
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders; |
||||||
|
import org.springframework.web.context.WebApplicationContext; |
||||||
|
import org.springframework.web.filter.CharacterEncodingFilter; |
||||||
|
|
||||||
|
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyUris; |
||||||
|
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; |
||||||
|
|
||||||
|
public class BaseTest { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
protected WebApplicationContext webApplicationContext; |
||||||
|
|
||||||
|
public MockMvc mockMvc; |
||||||
|
|
||||||
|
@BeforeEach |
||||||
|
public void setUpAll(RestDocumentationContextProvider restDocumentationContextProvider){ |
||||||
|
this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext) // @Autowired로 빈주입 받은 context
|
||||||
|
.addFilter(new CharacterEncodingFilter("UTF-8", true)) // UTF-8 인코딩 필터
|
||||||
|
.apply( |
||||||
|
MockMvcRestDocumentation.documentationConfiguration(restDocumentationContextProvider) |
||||||
|
.operationPreprocessors() |
||||||
|
.withRequestDefaults( |
||||||
|
modifyUris().scheme("http").host("localhost").port(8080), prettyPrint() // URL 정보를 넣어주시면 됩니다.
|
||||||
|
) |
||||||
|
.withResponseDefaults( |
||||||
|
prettyPrint() |
||||||
|
) |
||||||
|
) |
||||||
|
.build(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,493 @@ |
|||||||
|
package kr.co.palnet.kac.com.code; |
||||||
|
|
||||||
|
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; |
||||||
|
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; |
||||||
|
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; |
||||||
|
import static org.springframework.restdocs.payload.PayloadDocumentation.*; |
||||||
|
import static org.springframework.restdocs.request.RequestDocumentation.*; |
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; |
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; |
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
||||||
|
|
||||||
|
import kr.co.palnet.kac.BaseTest; |
||||||
|
import lombok.RequiredArgsConstructor; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
import org.junit.jupiter.api.extension.ExtendWith; |
||||||
|
import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; |
||||||
|
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; |
||||||
|
import org.springframework.boot.test.context.SpringBootTest; |
||||||
|
import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; |
||||||
|
import org.springframework.http.MediaType; |
||||||
|
import org.springframework.restdocs.RestDocumentationExtension; |
||||||
|
import org.springframework.restdocs.payload.JsonFieldType; |
||||||
|
import org.springframework.test.context.BootstrapWith; |
||||||
|
|
||||||
|
import kr.co.palnet.kac.api.v1.com.code.controller.ComCodeController; |
||||||
|
import kr.co.palnet.kac.app.KacAppApplication; |
||||||
|
|
||||||
|
@SpringBootTest(classes = KacAppApplication.class) |
||||||
|
@ExtendWith({RestDocumentationExtension.class}) |
||||||
|
@RequiredArgsConstructor |
||||||
|
public class ComnCodeControllerTest extends BaseTest { |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private final String BASE_URL = "/v1/com/code"; |
||||||
|
|
||||||
|
@Test |
||||||
|
public void deleteLang() throws Exception{ |
||||||
|
String groupCd = "NEW_GROUP001"; |
||||||
|
String cdId = "NEW_CODE170605841699"; |
||||||
|
String langDivCd = "ko_KR"; |
||||||
|
|
||||||
|
this.mockMvc.perform( |
||||||
|
delete(this.BASE_URL + "/lang?groupCd=" + groupCd + "&cdId=" + cdId + "&langDivCd=" + langDivCd) |
||||||
|
.contentType(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
.accept(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
) |
||||||
|
.andDo(print()) |
||||||
|
.andDo( |
||||||
|
document( |
||||||
|
"com/code/lang/delete", // gradle build를 하게 되면 generated-snippets에 만들어질 폴더이름
|
||||||
|
preprocessResponse(prettyPrint()), |
||||||
|
queryParameters( |
||||||
|
parameterWithName("groupCd").description("그룹 아이디"), |
||||||
|
parameterWithName("cdId").description("코드 아이디"), |
||||||
|
parameterWithName("langDivCd").description("삭제할 언어코드") |
||||||
|
) |
||||||
|
) |
||||||
|
) |
||||||
|
.andExpect(status().isOk()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void deleteCode() throws Exception{ |
||||||
|
|
||||||
|
String groupCd = "NEW_GROUP001"; |
||||||
|
String cdId = "NEW_CODE170605841699"; |
||||||
|
|
||||||
|
this.mockMvc.perform( |
||||||
|
delete(this.BASE_URL + "/code?groupCd=" + groupCd + "&cdId=" + cdId) |
||||||
|
.contentType(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
.accept(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
) |
||||||
|
.andDo(print()) |
||||||
|
.andDo( |
||||||
|
document( |
||||||
|
"com/code/code/delete", // gradle build를 하게 되면 generated-snippets에 만들어질 폴더이름
|
||||||
|
preprocessResponse(prettyPrint()), |
||||||
|
queryParameters( |
||||||
|
parameterWithName("groupCd").description("그룹 아이디"), |
||||||
|
parameterWithName("cdId").description("코드 아이디") |
||||||
|
) |
||||||
|
) |
||||||
|
) |
||||||
|
.andExpect(status().isOk()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void deleteCodeGroup() throws Exception { |
||||||
|
String deleteGroupCd = "NEW_Group_1706003812"; |
||||||
|
|
||||||
|
this.mockMvc.perform( |
||||||
|
delete(this.BASE_URL + "/group?groupCd=" + deleteGroupCd) |
||||||
|
.contentType(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
.accept(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
) |
||||||
|
.andDo(print()) |
||||||
|
.andDo( |
||||||
|
document( |
||||||
|
"com/code/group/delete", // gradle build를 하게 되면 generated-snippets에 만들어질 폴더이름
|
||||||
|
preprocessResponse(prettyPrint()), |
||||||
|
queryParameters( |
||||||
|
parameterWithName("groupCd").description("그룹 아이디") |
||||||
|
) |
||||||
|
) |
||||||
|
) |
||||||
|
.andExpect(status().isOk()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void updateCodeLang() throws Exception{ |
||||||
|
String jsonRQ = """ |
||||||
|
{ |
||||||
|
"groupCd": "NEW_GROUP001", |
||||||
|
"cdId": "NEW_CODE001", |
||||||
|
"langDivCd": "en_CA", |
||||||
|
"cdNm": "신규코드001", |
||||||
|
"rm": "비고...." |
||||||
|
} |
||||||
|
"""; |
||||||
|
|
||||||
|
this.mockMvc.perform( |
||||||
|
put(this.BASE_URL + "/lang") |
||||||
|
.contentType(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
.content(jsonRQ) |
||||||
|
.accept(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
) |
||||||
|
.andDo(print()) |
||||||
|
.andDo( |
||||||
|
document( |
||||||
|
"com/code/lang/update", // gradle build를 하게 되면 generated-snippets에 만들어질 폴더이름
|
||||||
|
preprocessResponse(prettyPrint()), |
||||||
|
requestFields( |
||||||
|
fieldWithPath("groupCd").type(JsonFieldType.STRING).description("그룹코드"), |
||||||
|
fieldWithPath("cdId").type(JsonFieldType.STRING).description("코드 아이디"), |
||||||
|
fieldWithPath("langDivCd").type(JsonFieldType.STRING).description("언어코드"), |
||||||
|
fieldWithPath("cdNm").type(JsonFieldType.STRING).description("코드이름[언어별]"), |
||||||
|
fieldWithPath("rm").type(JsonFieldType.STRING).description("비고") |
||||||
|
), |
||||||
|
responseFields( |
||||||
|
fieldWithPath("groupCd").type(JsonFieldType.STRING).description("그룹코드"), |
||||||
|
fieldWithPath("cdId").type(JsonFieldType.STRING).description("코드 아이디"), |
||||||
|
fieldWithPath("langDivCd").type(JsonFieldType.STRING).description("언어코드"), |
||||||
|
fieldWithPath("cdNm").type(JsonFieldType.STRING).description("코드이름[언어별]"), |
||||||
|
fieldWithPath("rm").type(JsonFieldType.STRING).description("비고"), |
||||||
|
fieldWithPath("createUserId").type(JsonFieldType.STRING).description("등록한 유저 아이디"), |
||||||
|
fieldWithPath("createDt").type(JsonFieldType.STRING).description("등록일시"), |
||||||
|
fieldWithPath("updateUserId").type(JsonFieldType.STRING).description("수정한 유저 아이디"), |
||||||
|
fieldWithPath("updateDt").type(JsonFieldType.STRING).description("수정일시") |
||||||
|
) |
||||||
|
) |
||||||
|
) |
||||||
|
.andExpect(status().isOk()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void updateCode() throws Exception{ |
||||||
|
String jsonRQ = """ |
||||||
|
{ |
||||||
|
"groupCd": "NEW_GROUP001", |
||||||
|
"cdId": "NEW_CODE001", |
||||||
|
"sortOrdr": 0, |
||||||
|
"addInfoValue": "추가!!", |
||||||
|
"useYn": "Y" |
||||||
|
} |
||||||
|
"""; |
||||||
|
|
||||||
|
this.mockMvc.perform( |
||||||
|
put(this.BASE_URL + "/code") |
||||||
|
.contentType(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
.content(jsonRQ) |
||||||
|
.accept(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
) |
||||||
|
.andDo(print()) |
||||||
|
.andDo( |
||||||
|
document( |
||||||
|
"com/code/code/update", // gradle build를 하게 되면 generated-snippets에 만들어질 폴더이름
|
||||||
|
preprocessResponse(prettyPrint()), |
||||||
|
requestFields( |
||||||
|
fieldWithPath("groupCd").type(JsonFieldType.STRING).description("그룹코드"), |
||||||
|
fieldWithPath("cdId").type(JsonFieldType.STRING).description("코드 아이디"), |
||||||
|
fieldWithPath("sortOrdr").type(JsonFieldType.NUMBER).description("정렬순서"), |
||||||
|
fieldWithPath("addInfoValue").type(JsonFieldType.STRING).description("추가사항"), |
||||||
|
fieldWithPath("useYn").type(JsonFieldType.STRING).description("사용여부") |
||||||
|
), |
||||||
|
responseFields( |
||||||
|
fieldWithPath("groupCd").type(JsonFieldType.STRING).description("그룹코드"), |
||||||
|
fieldWithPath("cdId").type(JsonFieldType.STRING).description("코드 아이디"), |
||||||
|
fieldWithPath("upperCd").type(JsonFieldType.STRING).description("상위 아이디").optional(), |
||||||
|
fieldWithPath("sortOrdr").type(JsonFieldType.NUMBER).description("정렬순서"), |
||||||
|
fieldWithPath("addInfoValue").type(JsonFieldType.STRING).description("추가사항"), |
||||||
|
fieldWithPath("useYn").type(JsonFieldType.STRING).description("사용여부"), |
||||||
|
fieldWithPath("createUserId").type(JsonFieldType.STRING).description("등록한 유저 아이디"), |
||||||
|
fieldWithPath("createDt").type(JsonFieldType.STRING).description("등록일시"), |
||||||
|
fieldWithPath("updateUserId").type(JsonFieldType.STRING).description("수정한 유저 아이디"), |
||||||
|
fieldWithPath("updateDt").type(JsonFieldType.STRING).description("수정일시") |
||||||
|
) |
||||||
|
) |
||||||
|
) |
||||||
|
.andExpect(status().isOk()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void updateCodeGroup() throws Exception{ |
||||||
|
String jsonRQ = """ |
||||||
|
{ |
||||||
|
"groupCd": "NEW_GROUP001", |
||||||
|
"siteCd": "KAC", |
||||||
|
"groupCdNm": "신규그룹001", |
||||||
|
"rm": "비고...." |
||||||
|
} |
||||||
|
"""; |
||||||
|
|
||||||
|
this.mockMvc.perform( |
||||||
|
put(this.BASE_URL + "/group") |
||||||
|
.contentType(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
.content(jsonRQ) |
||||||
|
.accept(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
) |
||||||
|
.andDo(print()) |
||||||
|
.andDo( |
||||||
|
document( |
||||||
|
"com/code/group/update", // gradle build를 하게 되면 generated-snippets에 만들어질 폴더이름
|
||||||
|
preprocessResponse(prettyPrint()), |
||||||
|
requestFields( |
||||||
|
fieldWithPath("groupCd").type(JsonFieldType.STRING).description("그룹코드"), |
||||||
|
fieldWithPath("siteCd").type(JsonFieldType.STRING).description("사이트코드"), |
||||||
|
fieldWithPath("groupCdNm").type(JsonFieldType.STRING).description("그룹이름"), |
||||||
|
fieldWithPath("rm").type(JsonFieldType.STRING).description("비고") |
||||||
|
), |
||||||
|
responseFields( |
||||||
|
fieldWithPath("groupCd").type(JsonFieldType.STRING).description("그룹코드"), |
||||||
|
fieldWithPath("siteCd").type(JsonFieldType.STRING).description("사이트코드"), |
||||||
|
fieldWithPath("groupCdNm").type(JsonFieldType.STRING).description("그룹이름"), |
||||||
|
fieldWithPath("rm").type(JsonFieldType.STRING).description("비고"), |
||||||
|
fieldWithPath("createUserId").type(JsonFieldType.STRING).description("등록한 유저 아이디"), |
||||||
|
fieldWithPath("createDt").type(JsonFieldType.STRING).description("등록일시"), |
||||||
|
fieldWithPath("updateUserId").type(JsonFieldType.STRING).description("수정한 유저 아이디"), |
||||||
|
fieldWithPath("updateDt").type(JsonFieldType.STRING).description("수정일시") |
||||||
|
) |
||||||
|
) |
||||||
|
) |
||||||
|
.andExpect(status().isOk()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void createCodeLang() throws Exception{ |
||||||
|
|
||||||
|
String langDivCd = "ko_KR"; |
||||||
|
|
||||||
|
String jsonRQ = """ |
||||||
|
{ |
||||||
|
"groupCd": "NEW_GROUP001", |
||||||
|
"cdId": "NEW_CODE001", |
||||||
|
"langDivCd": "%s", |
||||||
|
"cdNm": "신규코드001", |
||||||
|
"rm": "비고...." |
||||||
|
} |
||||||
|
""".formatted(langDivCd); |
||||||
|
|
||||||
|
this.mockMvc.perform( |
||||||
|
post(this.BASE_URL + "/lang") |
||||||
|
.contentType(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
.content(jsonRQ) |
||||||
|
.accept(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
) |
||||||
|
.andDo(print()) |
||||||
|
.andDo( |
||||||
|
document( |
||||||
|
"com/code/lang/create", // gradle build를 하게 되면 generated-snippets에 만들어질 폴더이름
|
||||||
|
preprocessResponse(prettyPrint()), |
||||||
|
requestFields( |
||||||
|
fieldWithPath("groupCd").type(JsonFieldType.STRING).description("그룹코드"), |
||||||
|
fieldWithPath("cdId").type(JsonFieldType.STRING).description("코드 아이디"), |
||||||
|
fieldWithPath("langDivCd").type(JsonFieldType.STRING).description("언어코드"), |
||||||
|
fieldWithPath("cdNm").type(JsonFieldType.STRING).description("코드이름[언어별]"), |
||||||
|
fieldWithPath("rm").type(JsonFieldType.STRING).description("비고") |
||||||
|
), |
||||||
|
responseFields( |
||||||
|
fieldWithPath("groupCd").type(JsonFieldType.STRING).description("그룹코드"), |
||||||
|
fieldWithPath("cdId").type(JsonFieldType.STRING).description("코드 아이디"), |
||||||
|
fieldWithPath("langDivCd").type(JsonFieldType.STRING).description("언어코드"), |
||||||
|
fieldWithPath("cdNm").type(JsonFieldType.STRING).description("코드이름[언어별]"), |
||||||
|
fieldWithPath("rm").type(JsonFieldType.STRING).description("비고"), |
||||||
|
fieldWithPath("createUserId").type(JsonFieldType.STRING).description("등록한 유저 아이디"), |
||||||
|
fieldWithPath("createDt").type(JsonFieldType.STRING).description("등록일시"), |
||||||
|
fieldWithPath("updateUserId").type(JsonFieldType.STRING).description("수정한 유저 아이디"), |
||||||
|
fieldWithPath("updateDt").type(JsonFieldType.STRING).description("수정일시") |
||||||
|
) |
||||||
|
) |
||||||
|
) |
||||||
|
.andExpect(status().isOk()); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void createCode() throws Exception{ |
||||||
|
String codeNm = "NEW_CODE" + System.currentTimeMillis(); |
||||||
|
codeNm = codeNm.substring(0, 20); |
||||||
|
|
||||||
|
String jsonRQ = """ |
||||||
|
{ |
||||||
|
"groupCd": "NEW_GROUP001", |
||||||
|
"cdId": "%s", |
||||||
|
"sortOrdr": 0, |
||||||
|
"addInfoValue": "추가!!", |
||||||
|
"useYn": "Y" |
||||||
|
} |
||||||
|
""".formatted(codeNm); |
||||||
|
|
||||||
|
this.mockMvc.perform( |
||||||
|
post(this.BASE_URL + "/code") |
||||||
|
.contentType(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
.content(jsonRQ) |
||||||
|
.accept(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
) |
||||||
|
.andDo(print()) |
||||||
|
.andDo( |
||||||
|
document( |
||||||
|
"com/code/code/create", // gradle build를 하게 되면 generated-snippets에 만들어질 폴더이름
|
||||||
|
preprocessResponse(prettyPrint()), |
||||||
|
requestFields( |
||||||
|
fieldWithPath("groupCd").type(JsonFieldType.STRING).description("그룹코드"), |
||||||
|
fieldWithPath("cdId").type(JsonFieldType.STRING).description("코드 아이디"), |
||||||
|
fieldWithPath("sortOrdr").type(JsonFieldType.NUMBER).description("정렬순서"), |
||||||
|
fieldWithPath("addInfoValue").type(JsonFieldType.STRING).description("추가사항"), |
||||||
|
fieldWithPath("useYn").type(JsonFieldType.STRING).description("사용여부") |
||||||
|
), |
||||||
|
responseFields( |
||||||
|
fieldWithPath("groupCd").type(JsonFieldType.STRING).description("그룹코드"), |
||||||
|
fieldWithPath("cdId").type(JsonFieldType.STRING).description("코드 아이디"), |
||||||
|
fieldWithPath("upperCd").type(JsonFieldType.STRING).description("상위 아이디").optional(), |
||||||
|
fieldWithPath("sortOrdr").type(JsonFieldType.NUMBER).description("정렬순서"), |
||||||
|
fieldWithPath("addInfoValue").type(JsonFieldType.STRING).description("추가사항"), |
||||||
|
fieldWithPath("useYn").type(JsonFieldType.STRING).description("사용여부"), |
||||||
|
fieldWithPath("createUserId").type(JsonFieldType.STRING).description("등록한 유저 아이디"), |
||||||
|
fieldWithPath("createDt").type(JsonFieldType.STRING).description("등록일시"), |
||||||
|
fieldWithPath("updateUserId").type(JsonFieldType.STRING).description("수정한 유저 아이디"), |
||||||
|
fieldWithPath("updateDt").type(JsonFieldType.STRING).description("수정일시") |
||||||
|
) |
||||||
|
) |
||||||
|
) |
||||||
|
.andExpect(status().isOk()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void createCodeGroup() throws Exception{ |
||||||
|
|
||||||
|
String randomNm = "NEW_GROUP_" + System.currentTimeMillis(); |
||||||
|
randomNm = randomNm.substring(0, 20); |
||||||
|
|
||||||
|
String jsonRQ = """ |
||||||
|
{ |
||||||
|
"groupCd": "%s", |
||||||
|
"siteCd": "KAC", |
||||||
|
"groupCdNm": "신규그룹001", |
||||||
|
"rm": "비고...." |
||||||
|
} |
||||||
|
""".formatted(randomNm); |
||||||
|
|
||||||
|
this.mockMvc.perform( |
||||||
|
post(this.BASE_URL + "/group") |
||||||
|
.contentType(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
.content(jsonRQ) |
||||||
|
.accept(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
) |
||||||
|
.andDo(print()) |
||||||
|
.andDo( |
||||||
|
document( |
||||||
|
"com/code/group/create", // gradle build를 하게 되면 generated-snippets에 만들어질 폴더이름
|
||||||
|
preprocessResponse(prettyPrint()), |
||||||
|
requestFields( |
||||||
|
fieldWithPath("groupCd").type(JsonFieldType.STRING).description("그룹코드"), |
||||||
|
fieldWithPath("siteCd").type(JsonFieldType.STRING).description("사이트코드"), |
||||||
|
fieldWithPath("groupCdNm").type(JsonFieldType.STRING).description("그룹이름"), |
||||||
|
fieldWithPath("rm").type(JsonFieldType.STRING).description("비고") |
||||||
|
), |
||||||
|
responseFields( |
||||||
|
fieldWithPath("groupCd").type(JsonFieldType.STRING).description("그룹코드"), |
||||||
|
fieldWithPath("siteCd").type(JsonFieldType.STRING).description("사이트코드"), |
||||||
|
fieldWithPath("groupCdNm").type(JsonFieldType.STRING).description("그룹이름"), |
||||||
|
fieldWithPath("rm").type(JsonFieldType.STRING).description("비고"), |
||||||
|
fieldWithPath("createUserId").type(JsonFieldType.STRING).description("등록한 유저 아이디"), |
||||||
|
fieldWithPath("createDt").type(JsonFieldType.STRING).description("등록일시"), |
||||||
|
fieldWithPath("updateUserId").type(JsonFieldType.STRING).description("수정한 유저 아이디"), |
||||||
|
fieldWithPath("updateDt").type(JsonFieldType.STRING).description("수정일시") |
||||||
|
) |
||||||
|
) |
||||||
|
) |
||||||
|
.andExpect(status().isOk()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void getAllCodeByGroup() throws Exception{ |
||||||
|
String groupCd = "NEW_GROUP001"; |
||||||
|
String langDivCd = "ko_KR"; |
||||||
|
|
||||||
|
this.mockMvc.perform( |
||||||
|
get(this.BASE_URL + "/code") |
||||||
|
.param("groupCd", groupCd) |
||||||
|
.param("langDivCd", langDivCd) |
||||||
|
.contentType(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
.accept(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
) |
||||||
|
.andDo(print()) |
||||||
|
.andDo( |
||||||
|
document( |
||||||
|
"com/code/code", // gradle build를 하게 되면 generated-snippets에 만들어질 폴더이름
|
||||||
|
preprocessResponse(prettyPrint()), |
||||||
|
queryParameters( |
||||||
|
parameterWithName("groupCd").description("그룹코드"), |
||||||
|
parameterWithName("langDivCd").description("언어코드") |
||||||
|
), |
||||||
|
responseFields( |
||||||
|
fieldWithPath("[].groupCd").type(JsonFieldType.STRING).description("코드의 그룹"), |
||||||
|
fieldWithPath("[].cdId").type(JsonFieldType.STRING).description("코드의 ID"), |
||||||
|
fieldWithPath("[].cdNm").type(JsonFieldType.STRING).description("코드의 이름").optional(), |
||||||
|
fieldWithPath("[].upperCd").type(JsonFieldType.STRING).description("상위 코드의 이름").optional(), |
||||||
|
fieldWithPath("[].sortOrdr").type(JsonFieldType.NUMBER).description("코드의 정렬순서").optional(), |
||||||
|
fieldWithPath("[].addInfoValue").type(JsonFieldType.STRING).description("코드의 추가 밸류").optional(), |
||||||
|
fieldWithPath("[].children").type(JsonFieldType.STRING).description("코드의 하위요소").optional() |
||||||
|
) |
||||||
|
) |
||||||
|
) |
||||||
|
.andExpect(status().isOk()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void getAllGroupCode() throws Exception{ |
||||||
|
this.mockMvc.perform( |
||||||
|
get(this.BASE_URL + "/group") |
||||||
|
.contentType(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
.accept(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
) |
||||||
|
.andDo(print()) |
||||||
|
.andDo( |
||||||
|
document( |
||||||
|
"com/code/group", // gradle build를 하게 되면 generated-snippets에 만들어질 폴더이름
|
||||||
|
preprocessResponse(prettyPrint()), |
||||||
|
responseFields( |
||||||
|
fieldWithPath("[].groupCd").type(JsonFieldType.STRING).description("그룹 코드"), |
||||||
|
fieldWithPath("[].siteCd").type(JsonFieldType.STRING).description("사이트 코드"), |
||||||
|
fieldWithPath("[].groupCdNm").type(JsonFieldType.STRING).description("그룹 명"), |
||||||
|
fieldWithPath("[].rm").type(JsonFieldType.STRING).description("비고"), |
||||||
|
fieldWithPath("[].codeList").type(JsonFieldType.ARRAY).description("그룹에 포함된 코드 리스트").optional() |
||||||
|
) |
||||||
|
) |
||||||
|
) |
||||||
|
.andExpect(status().isOk()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void getAllGroup() throws Exception{ |
||||||
|
|
||||||
|
String siteCd = "KAC"; |
||||||
|
String langDivCd = "ko_KR"; |
||||||
|
|
||||||
|
this.mockMvc.perform( |
||||||
|
get(this.BASE_URL + "/all") |
||||||
|
.param("siteCd", siteCd) |
||||||
|
.param("langDivCd", langDivCd) |
||||||
|
.contentType(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
.accept(MediaType.APPLICATION_JSON_VALUE) |
||||||
|
) |
||||||
|
.andDo(print()) |
||||||
|
.andDo( |
||||||
|
document( |
||||||
|
"com/code/all", // gradle build를 하게 되면 generated-snippets에 만들어질 폴더이름
|
||||||
|
preprocessResponse(prettyPrint()), |
||||||
|
queryParameters( |
||||||
|
parameterWithName("siteCd").description("사이트코드"), |
||||||
|
parameterWithName("langDivCd").description("언어코드") |
||||||
|
), |
||||||
|
responseFields( |
||||||
|
fieldWithPath("[].groupCd").type(JsonFieldType.STRING).description("그룹 코드"), |
||||||
|
fieldWithPath("[].siteCd").type(JsonFieldType.STRING).description("사이트 코드"), |
||||||
|
fieldWithPath("[].groupCdNm").type(JsonFieldType.STRING).description("그룹 명"), |
||||||
|
fieldWithPath("[].rm").type(JsonFieldType.STRING).description("비고"), |
||||||
|
fieldWithPath("[].codeList").type(JsonFieldType.ARRAY).description("그룹에 포함된 코드 리스트").optional(), |
||||||
|
fieldWithPath("[].codeList[].groupCd").type(JsonFieldType.STRING).description("코드의 그룹"), |
||||||
|
fieldWithPath("[].codeList[].cdId").type(JsonFieldType.STRING).description("코드의 ID"), |
||||||
|
fieldWithPath("[].codeList[].cdNm").type(JsonFieldType.STRING).description("코드의 이름").optional(), |
||||||
|
fieldWithPath("[].codeList[].upperCd").type(JsonFieldType.STRING).description("상위 코드의 이름").optional(), |
||||||
|
fieldWithPath("[].codeList[].sortOrdr").type(JsonFieldType.NUMBER).description("코드의 정렬순서").optional(), |
||||||
|
fieldWithPath("[].codeList[].addInfoValue").type(JsonFieldType.STRING).description("코드의 추가 밸류").optional(), |
||||||
|
fieldWithPath("[].codeList[].children").type(JsonFieldType.STRING).description("코드의 하위요소").optional() |
||||||
|
) |
||||||
|
) |
||||||
|
) |
||||||
|
.andExpect(status().isOk()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue