Skip to content

Commit

Permalink
Merge pull request #218 from TripInfoWeb/feature/restdocs_setting
Browse files Browse the repository at this point in the history
Feature/restdocs setting
  • Loading branch information
hyeonjaez authored Oct 3, 2024
2 parents 66a7d3d + 55881e0 commit 0f6eebf
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 5 deletions.
31 changes: 27 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ configurations {
compileOnly {
extendsFrom annotationProcessor
}
asciidoctorExt
}

repositories {
Expand Down Expand Up @@ -54,7 +55,7 @@ dependencies {
annotationProcessor "jakarta.persistence:jakarta.persistence-api"

runtimeOnly 'com.mysql:mysql-connector-j'

asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor'
testImplementation 'com.h2database:h2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
Expand All @@ -71,6 +72,28 @@ tasks.named('asciidoctor') {
dependsOn test
}

//clean {
// delete file('src/main/generated')
//}
ext {
snippetsDir = file('build/generated-snippets') // (5)
}

asciidoctor {
configurations 'asciidoctorExt' // (7)
baseDirFollowsSourceFile() // (8)
inputs.dir snippetsDir // (9)
dependsOn test // (10)
}

asciidoctor.doFirst {
delete file('src/main/resources/docs') // (11)
}

task copyDocument(type: Copy) { // (12)
dependsOn asciidoctor
from file("build/docs/asciidoc")
into file("src/main/resources/docs")
}


build {
dependsOn copyDocument
}
11 changes: 11 additions & 0 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
= Solitour -Resource

:doctype: book
:toc: left
:toclevels: 3
:sectnums:
:numbered:


// [[api]]
// includ::ee.adoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import solitour_backend.solitour.auth.config.Authenticated;
import solitour_backend.solitour.auth.config.AuthenticationPrincipal;
import solitour_backend.solitour.auth.exception.TokenNotExistsException;
import solitour_backend.solitour.auth.exception.TokenNotValidException;
import solitour_backend.solitour.auth.support.CookieExtractor;
import solitour_backend.solitour.auth.support.JwtTokenProvider;
import solitour_backend.solitour.error.Utils;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package solitour_backend.solitour.information.controller;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.restdocs.RestDocumentationContextProvider;
import org.springframework.restdocs.RestDocumentationExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import solitour_backend.solitour.information.service.InformationService;

import static org.junit.jupiter.api.Assertions.*;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyUris;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;

@WebMvcTest(InformationController.class)
@ExtendWith({MockitoExtension.class, RestDocumentationExtension.class})
class InformationControllerTest {

@Autowired
private MockMvc mockMvc;

@MockBean
private InformationService informationService;

@BeforeEach
void setUp(WebApplicationContext webApplicationContext,
RestDocumentationContextProvider restDocumentation) {

this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
.apply(documentationConfiguration(restDocumentation)
.operationPreprocessors()
.withRequestDefaults(modifyUris(), prettyPrint())
.withResponseDefaults(prettyPrint()))
.build();
}
}

0 comments on commit 0f6eebf

Please sign in to comment.