Browse Source

feat: SpringRestDocs 라이브러리 및 예제 추가

pull/6/head
lkd9125(이경도) 8 months ago committed by Gitea
parent
commit
1d5bed9ce7
  1. 49
      app/kac-app/build.gradle
  2. 175
      app/kac-app/src/docs/asciidoc/index.adoc
  3. 1955
      app/kac-app/src/main/resources/static/docs/index.html
  4. 39
      app/kac-app/src/test/java/kr/co/palnet/kac/BaseTest.java
  5. 493
      app/kac-app/src/test/java/kr/co/palnet/kac/com/code/ComnCodeControllerTest.java
  6. 12
      data/com/src/test/java/kr/co/palnet/kac/data/com/DataComApplicationTestApp.java
  7. 6
      data/user/build.gradle
  8. 6
      web/api-user/build.gradle

49
app/kac-app/build.gradle

@ -1,5 +1,13 @@
plugins {
id "org.asciidoctor.jvm.convert" version "3.3.2"
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
asciidoctorExt
}
dependencies {
implementation "$boot:spring-boot-starter-web"
// db
@ -14,12 +22,51 @@ dependencies {
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation project(":common-core")
implementation project(":web-api-com")
// TDOO: ...
compileOnly project(":data-com")
}
ext {
snippetsDir = file('build/generated-snippets')
}
test {
useJUnitPlatform()
outputs.dir snippetsDir
}
asciidoctor {
dependsOn test
inputs.dir snippetsDir
}
bootJar {
dependsOn asciidoctor
from ("${asciidoctor.outputDir}/html5") {
into 'static/docs'
}
}
asciidoctor.doFirst {
delete file('src/main/resources/static/docs')
}
task copyDocument(type: Copy) {
dependsOn asciidoctor
from file("build/docs/asciidoc")
into file("src/main/resources/static/docs")
}
build {
dependsOn copyDocument
}
// querydsl
def querydslDir = layout.buildDirectory.dir("generated/querydsl").get().asFile

175
app/kac-app/src/docs/asciidoc/index.adoc

@ -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[]
***

1955
app/kac-app/src/main/resources/static/docs/index.html

File diff suppressed because it is too large Load Diff

39
app/kac-app/src/test/java/kr/co/palnet/kac/BaseTest.java

@ -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();
}
}

493
app/kac-app/src/test/java/kr/co/palnet/kac/com/code/ComnCodeControllerTest.java

@ -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());
}
}

12
data/com/src/test/java/kr/co/palnet/kac/data/com/DataComApplicationTestApp.java

@ -15,12 +15,12 @@ public class DataComApplicationTestApp {
@Configuration
@ComponentScan("kr.co.palnet.kac.data.com")
@EnableJpaRepositories(basePackages = {
"kr.co.palnet.kac.data.com.repository"
})
@EntityScan(basePackages = {
"kr.co.palnet.kac.data.com.domain"
})
// @EnableJpaRepositories(basePackages = {
// "kr.co.palnet.kac.data.com.repository"
// })
// @EntityScan(basePackages = {
// "kr.co.palnet.kac.data.com.domain"
// })
public class Config {
}

6
data/user/build.gradle

@ -0,0 +1,6 @@
dependencies {
}

6
web/api-user/build.gradle

@ -0,0 +1,6 @@
dependencies {
}
Loading…
Cancel
Save