Search⌘ K

Testing Our HypermediaItemController

Explore how to test the HypermediaItemController using Spring REST Docs. Understand the process of verifying hypermedia links, capturing HTTP responses, and generating documentation snippets. This lesson helps you enhance API testing and documentation for hypermedia-driven Spring Boot applications.

We'll cover the following...

Using Spring REST Docs, this web controller can be tested, just like the plain old JSON API was. Let’s look at a new test we created. We’re only focusing on the hypermedia controller.

Java
@WebFluxTest(controllers = HypermediaItemController.class)
@AutoConfigureRestDocs
public class HypermediaItemControllerDocumentationTest {
@Autowired private WebTestClient webTestClient;
@MockBean InventoryService service;
@MockBean ItemRepository repository;
}
Building hypermedia for a single Item

Once again, the setup for a documentation test case is identical. The only difference is that we point it at the HypermediaItemController. The bottom line is that capturing HTTP ...