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")); | |
} |
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
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
import org.springframework.web.context.WebApplicationContext; | |
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; |
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
<phase>prepare-package</phase> |
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.ws.web.api; | |
import java.io.IOException; | |
import java.util.Collection; | |
import javax.servlet.http.HttpServletResponse; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.http.HttpStatus; | |
import org.springframework.http.MediaType; |
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.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; | |
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; | |
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; | |
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; | |
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; | |
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
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
|=== | |
|Path|Type|Description|Constraints | |
{{#fields}} | |
|{{path}} | |
|{{type}} | |
|{{description}} | |
|{{constraints}} | |
{{/fields}} |
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
FieldDescriptor[] offer = new FieldDescriptor[] { | |
fields.withPath("id").description("identifier"), | |
fields.withPath("destination").description("The trips' destination"), | |
fields.withPath("startingPoint").description("The trips' startingPoint"), | |
fields.withPath("username").description("The user who has created the offer"), | |
fields.withPath("date").description("The trip's starting time formatted"), | |
fields.withPath("price").description("The price per person"), | |
fields.withPath("dateObject").description("The trip's starting time as milliseconds") }; | |