@@ -2,16 +2,18 @@ package com.epages.restdocs.apispec
22
33import com.epages.restdocs.apispec.ResourceDocumentation.parameterWithName
44import com.epages.restdocs.apispec.ResourceDocumentation.resource
5+ import jakarta.validation.constraints.NotEmpty
56import org.hibernate.validator.constraints.Length
67import org.junit.jupiter.api.extension.ExtendWith
78import org.springframework.boot.SpringApplication
89import org.springframework.boot.autoconfigure.SpringBootApplication
910import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs
1011import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
1112import org.springframework.context.ConfigurableApplicationContext
13+ import org.springframework.hateoas.EntityModel
14+ import org.springframework.hateoas.IanaLinkRelations
1215import org.springframework.hateoas.Link
13- import org.springframework.hateoas.Resource
14- import org.springframework.hateoas.mvc.BasicLinkBuilder
16+ import org.springframework.hateoas.server.mvc.BasicLinkBuilder.linkToCurrentMapping
1517import org.springframework.http.HttpHeaders.ACCEPT
1618import org.springframework.http.HttpHeaders.CONTENT_TYPE
1719import org.springframework.http.ResponseEntity
@@ -26,7 +28,6 @@ import org.springframework.web.bind.annotation.RequestBody
2628import org.springframework.web.bind.annotation.RequestHeader
2729import org.springframework.web.bind.annotation.RestController
2830import java.util.UUID
29- import javax.validation.constraints.NotEmpty
3031
3132@ExtendWith(SpringExtension ::class )
3233@WebMvcTest
@@ -53,17 +54,17 @@ open class ResourceSnippetIntegrationTest {
5354 @PathVariable otherId : Int? ,
5455 @RequestHeader(" X-Custom-Header" ) customHeader : String ,
5556 @RequestBody testDataHolder : TestDataHolder
56- ): ResponseEntity <Resource <TestDataHolder >> {
57- val resource = Resource (testDataHolder.copy(id = UUID .randomUUID().toString()))
58- val link = BasicLinkBuilder . linkToCurrentMapping().slash(" some" ).slash(someId).slash(" other" ).slash(otherId).toUri().toString()
59- resource.add(Link (link, Link . REL_SELF ))
60- resource.add(Link (link, " multiple" ))
61- resource.add(Link (link, " multiple" ))
57+ ): ResponseEntity <EntityModel <TestDataHolder >> {
58+ val resource = EntityModel .of (testDataHolder.copy(id = UUID .randomUUID().toString()))
59+ val link = linkToCurrentMapping().slash(" some" ).slash(someId).slash(" other" ).slash(otherId).toUri().toString()
60+ resource.add(Link .of (link, IanaLinkRelations . SELF ))
61+ resource.add(Link .of (link, " multiple" ))
62+ resource.add(Link .of (link, " multiple" ))
6263
6364 return ResponseEntity
6465 .ok()
6566 .header(" X-Custom-Header" , customHeader)
66- .body<Resource <TestDataHolder >>(resource)
67+ .body<EntityModel <TestDataHolder >>(resource)
6768 }
6869 }
6970 }
0 commit comments