HTTP/1.1 201 Created
Content-Type: application/json;charset=UTF-8
Content-Length: 144
{"id":3,"startingPoint":"Innsbruck","destination":"Lindau","username":"admin","date":"2016-10-10T09:50","price":40.0,"dateObject":1476085800000}
This file contains hidden or 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
package com.espen.documentation; | |
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; | |
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | |
import org.junit.Before; | |
import org.junit.runner.RunWith; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.test.context.SpringBootTest; | |
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; |
This file contains hidden or 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
<dependency> | |
<groupId>org.springframework.restdocs</groupId> | |
<artifactId>spring-restdocs-mockmvc</artifactId> | |
</dependency> |
This file contains hidden or 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
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-surefire-plugin</artifactId> | |
<configuration> | |
<includes> | |
<include>**/*Documentation.java</include> | |
</includes> | |
</configuration> | |
</plugin> | |
<plugin> |
This file contains hidden or 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
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-surefire-plugin</artifactId> | |
<configuration> | |
<includes> | |
<include>**/*Documentation.java</include> | |
</includes> | |
</configuration> | |
</plugin> | |
<plugin> |
This file contains hidden or 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
<properties> | |
<snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory> | |
</properties> |
This file contains hidden or 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
package com.espen.documentation; | |
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; | |
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | |
import org.junit.Before; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.test.context.SpringBootTest; |
This file contains hidden or 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
package com.espen.documentation; | |
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; | |
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; | |
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | |
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; | |
import org.junit.Before; | |
import org.junit.Rule; | |
import org.junit.Test; |
This file contains hidden or 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
@Test | |
public void postOffer() throws Exception { | |
Offer newOffer = new Offer("Innsbruck", "Lindau", "admin", "2016-10-10T09:50", 40); | |
String json = mapper.writeValueAsString(newOffer); | |
mockMvc.perform(post("/api/offers").contentType(MediaType.APPLICATION_JSON_UTF8).content(json)) | |
.andExpect(status().isCreated()) | |
.andDo(document("index", responseFields( | |
fieldWithPath("destination").description("The trips' destination"), | |
fieldWithPath("id").description("The offer's id"), | |
fieldWithPath("startingPoint").description("The trips' startingPoint"), |
Path | Type | Description |
---|---|---|
|
|
The trips' destination |
|
|
The offer’s id |
OlderNewer