Dan Newton’s 2017 “Simple Spring Boot: Post” tutorial shows a controller accepting a JSON POST request at /persistPerson, returning a status based on validation, and testing the two outcomes with Postman and MockMvc. Its code is a dated example, not confirmation of current Spring Boot conventions.
What the tutorial’s POST endpoint does
The DZone example uses spring-boot-starter-web and spring-boot-starter-test. Its PersonRestController maps POST /persistPerson and takes a PersonDTO from the JSON request body using @RequestBody. The controller passes the person to personService.isValid(person) and branches on the result.
- If valid: it calls
personRepository.persist(person)and responds withHttpStatus.CREATED(201). - If invalid: it responds with
HttpStatus.I_AM_A_TEAPOT(418).
Newton describes 418 as a deliberately silly choice and discusses possible alternatives. Treat that status as a feature of this particular example, not general HTTP guidance.
Send the example request with Postman
The tutorial’s manual test sends a request to localhost:8080/persistPerson. Start the Spring Boot application first, then configure Postman as follows:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →#1 Best Overall
- Choose the
POSTmethod and enterhttp://localhost:8080/persistPerson. - Set the content type to
application/json; charset=UTF-8. - Choose a raw request body and send JSON with the fields
firstName,secondName,dateOfBirth,profession, andsalary. - Submit the request and inspect the HTTP status returned by the controller. A valid person follows the 201 branch; an invalid person follows the example’s 418 branch.
The article does not establish the field types or a complete JSON example, so the request values must match the PersonDTO used in the application.
Test the controller with MockMvc
For a repeatable automated check, the tutorial uses @WebMvcTest(PersonRestController.class) with MockMvc. The test serializes a PersonDTO as JSON, mocks the service and repository, and verifies both the HTTP response and the repository interaction.
Rank #2
Valid request
Configure the mocked service to treat the person as valid. The test expects status 201 and verifies that the repository’s persistence method is called once.
Invalid request
Configure the service to reject the person. The test expects status 418 and verifies that the repository’s persistence method is not called.
Rank #3
When to use each testing approach
| Approach | What it demonstrates in this tutorial |
|---|---|
| Postman | How to set up and manually send a JSON request, then observe the endpoint’s response. |
| MockMvc | How to check response status and whether persistence was invoked in a repeatable controller test with mocked dependencies. |
These examples serve different purposes: a manual request makes the HTTP setup tangible, while the controller test checks selected behavior automatically. The tutorial does not claim that they replace every other kind of application test.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Source and version context
This walkthrough summarizes Dan Newton’s DZone tutorial, published April 6, 2017: “Simple Spring Boot: Post”. The source demonstrates its code and testing approach as presented at publication; it does not verify compatibility or best practices for current Spring Boot versions.
Quick Recap
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

