An endpoint contract is the behavior a web endpoint promises its clients. A controller integration test checks that the endpoint is mapped correctly, handles the request as expected, runs validation, and returns the expected response. section 16.2
A controller test can catch problems that service tests alone might miss:
- The endpoint is mapped incorrectly or the request body is not deserialized as expected. section 16.2
- Validation does not run, or the response differs from what the client expects. section 16.2
- MockMvc exercises the web layer without starting a real HTTP server; TestRestTemplate and WebTestClient are other options. section 16.2
Money transfer
A MockMvc test sends a JSON POST request to /transfer and expects an OK status; the scenario checks that both account balances are updated. section 16.2
Figure 16.2 A controller integration test. A tool such as MockMvc lets the test execute the web layer without starting a real server. The test sends a simulated HTTP request to the controller, while the developer decides which objects in the request-processing flow are real and which ones are replaced with mocks.

See how a simulated request reaches the controller while the test chooses which objects in the request-processing flow are real or mocked. section 16.2
