spring-projects / spring-data-rest

Simplifies building hypermedia-driven REST web services on top of Spring Data repositories
https://spring.io/projects/spring-data-rest
Apache License 2.0
905 stars 558 forks source link

Document how to use TestRestTemplate with spring-data-rest #2365

Open DanKaplanSES opened 4 months ago

DanKaplanSES commented 4 months ago

TestRestTemplate is relatively popular in the spring world but it's not obvious how to use it with the spring-data-rest CrudRepository generated endpoints. spring-data-rest wraps every response in an object I didn't create. It's not obvious how to use TestRestTemplate with this object unless I return simple response classes like String or Map<?, ?>.

    • [ ] If TestRestTemplate can be used with spring-data-rest, please provide examples of using it with response bodies more complex than String or Map<?, ?>. e.g., a Person class.
    • [ ] Please also include a postForEntity and/or putForEntity(putForEntity doesn't exist) example, because I see a lot of people struggling to make requests that send a complex class, e.g., Person, in the request body.
    • [ ] If TestRestTemplate is the wrong tool for the job, please recommend the right tool or a better tool. This might already be documented, but I've been unable to find it.

Thanks, Dan