Files
spring-restdocs/build.gradle
Andy Wilkinson e5f35c98f3 Add support for post-processing a response before it is documented
This commit adds support for post-processing a response before it is
documented. Post-processors are provided to pretty-print JSON and XML
responses, remove headers from the response, and mask the hrefs of
Atom- and HAL-formatted links in JSON responses.

Response post-processing is configured prior to configuring the
documentation. For example,

mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON))
        .andExpect(status().isOk())
		.andDo(modifyResponseTo(prettyPrintContent(), removeHeaders("a"),
				maskLinks()).andDocument("post-processed"));

Closes gh-61
Closes gh-31
Closes gh-54
2015-04-30 14:06:40 +01:00

99 lines
2.4 KiB
Groovy

project(':spring-restdocs') {
ext {
hamcrestVersion = '1.3'
jacksonVersion = '2.3.4'
jacocoVersion = '0.7.2.201409121644'
junitVersion = '4.11'
servletApiVersion = '3.1.0'
springHateoasVersion = '0.17.0.RELEASE'
springVersion = '4.1.4.RELEASE'
mockitoVersion = '1.10.19'
}
group = 'org.springframework.restdocs'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'sonar-runner'
sonarRunner {
sonarProperties {
property 'sonar.jacoco.reportPath', "${buildDir.name}/jacoco.exec"
property 'sonar.java.coveragePlugin', 'jacoco'
property 'sonar.links.ci', 'https://build.spring.io/browse/SRD'
property 'sonar.links.homepage', 'https://github.com/spring-projects/spring-restdocs'
property 'sonar.links.issue', 'https://github.com/spring-projects/spring-restdocs'
property 'sonar.links.scm', 'https://github.com/spring-projects/spring-restdocs'
}
}
configurations {
jacoco
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
jcenter()
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from project.sourceSets.main.allSource
}
task javadocJar(type: Jar) {
classifier = "javadoc"
from javadoc
}
artifacts {
archives sourcesJar
archives javadocJar
}
eclipseJdt.onlyIf { false }
cleanEclipseJdt.onlyIf { false }
dependencies {
compile "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
compile "junit:junit:$junitVersion"
compile "org.springframework:spring-test:$springVersion"
compile "org.springframework:spring-web:$springVersion"
compile "org.springframework:spring-webmvc:$springVersion"
compile "javax.servlet:javax.servlet-api:$servletApiVersion"
jacoco "org.jacoco:org.jacoco.agent:$jacocoVersion:runtime"
testCompile "org.springframework.hateoas:spring-hateoas:$springHateoasVersion"
testCompile "org.mockito:mockito-core:$mockitoVersion"
testCompile "org.hamcrest:hamcrest-core:$hamcrestVersion"
testCompile "org.hamcrest:hamcrest-library:$hamcrestVersion"
}
test {
jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=org.springframework.restdocs.*"
testLogging {
exceptionFormat "full"
}
}
}
apply plugin: 'samples'
samples {
dependOn 'spring-restdocs:install'
restNotesSpringHateoas {
workingDir 'samples/rest-notes-spring-hateoas'
}
restNotesSpringDataRest {
workingDir 'samples/rest-notes-spring-data-rest'
}
}
wrapper {
gradleVersion = '2.3'
}