Enable rendering as HAL FORMS.

We're now registering an HttpMessageConverter to render requests for HAL FORMS using the HalFormsConfiguration present in the application.

We're currently not adding any affordances yet. The change solely enables user code to add affordances explicitly, e.g. via RepresentationModelProcessor implementations.

Fixes: #1991.
This commit is contained in:
Oliver Drotbohm
2021-01-25 22:55:39 +01:00
parent c89369b410
commit 17538c65d7
3 changed files with 52 additions and 4 deletions

View File

@@ -45,6 +45,7 @@ import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.Links;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.server.LinkRelationProvider;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockHttpServletResponse;
@@ -731,6 +732,14 @@ public class JpaWebTests extends CommonWebTests {
assertThat(content.read("$.calculatedName", String.class)).isEqualTo("calculated-put");
}
@Test // #1991
public void answersToHalFormsRequests() throws Exception {
mvc.perform(get("/")
.accept(MediaTypes.HAL_FORMS_JSON))
.andExpect(status().isOk());
}
private List<Link> preparePersonResources(Person primary, Person... persons) throws Exception {
Link peopleLink = client.discoverUnique(LinkRelation.of("people"));