MockMvc wrapper allowing to easily test Spring HATEOAS HAL(-FORMS) endpoints.
- Add the
spring-boot-starter
dependency:<dependency> <groupId>com.cosium.hal_mock_mvc</groupId> <artifactId>hal-mock-mvc-spring-boot-starter</artifactId> <version>${hal-mock-mvc.version}</version> <scope>test</scope> </dependency>
- Annotate your test class with
AutoConfigureHalMockMvc
and injectHalMockMvc
:@AutoConfigureHalMockMvc @SpringBootTest class MyTest { @Autowired private HalMockMvc halMockMvc; @Test void test() { halMockMvc .follow("current-user") .get() .andExpect(status().isOk()) .andExpect(jsonPath("$.alias").value("jdoe")); } }
- Java 17
- Spring dependencies matching Spring Boot 3 and above.
This project was created following spring-projects/spring-hateoas#733 discussion.