spring-projects / spring-projects/spring-data-rest
Document how to use TestRestTemplate with spring-data-rest
Open
@odrotbohm is already working on this.
Since Feb 20, 2024.
status: waiting-for-triage
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
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
TestRestTemplatecan be used with spring-data-rest, please provide examples of using it with response bodies more complex thanStringorMap<?, ?>. e.g., aPersonclass.
- If
-
- Please also include a
postForEntityand/orputForEntity(putForEntitydoesn'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.
- Please also include a
-
- If
TestRestTemplateis 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.
- If
Thanks,
Dan
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.