Skip to content

Latest commit

 

History

History
45 lines (36 loc) · 1.46 KB

README.md

File metadata and controls

45 lines (36 loc) · 1.46 KB

Build Status Maven Central

HAL Mock MVC

MockMvc wrapper allowing to easily test Spring HATEOAS HAL(-FORMS) endpoints.

Quick start

  1. 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>
  2. Annotate your test class with AutoConfigureHalMockMvc and inject HalMockMvc:
    @AutoConfigureHalMockMvc
    @SpringBootTest
    class MyTest {
      @Autowired
      private HalMockMvc halMockMvc;
    
      @Test
      void test() {
        halMockMvc
           .follow("current-user")
           .get()
           .andExpect(status().isOk())
           .andExpect(jsonPath("$.alias").value("jdoe"));
      }
    }

Prerequisites

  • Java 17+
  • Spring dependencies matching Spring Boot 3 and above.

Genesis

This project was created following spring-projects/spring-hateoas#733 discussion.