Example usage for org.springframework.hateoas Links hasLink

List of usage examples for org.springframework.hateoas Links hasLink

Introduction

In this page you can find the example usage for org.springframework.hateoas Links hasLink.

Prototype

public boolean hasLink(LinkRelation relation) 

Source Link

Document

Returns whether the current Links contains a Link with the given relation.

Usage

From source file:org.springframework.data.rest.webmvc.jpa.JpaWebTests.java

/**
 * @see DATAREST-658/*from w  w w . j  a  v a2 s .c  o m*/
 */
@Test
public void returnsLinkHeadersForHeadRequestToItemResource() throws Exception {

    MockHttpServletResponse response = client.request(client.discoverUnique("people"));
    String personHref = JsonPath.read(response.getContentAsString(), "$._embedded.people[0]._links.self.href");

    response = mvc.perform(head(personHref))//
            .andExpect(status().isNoContent())//
            .andReturn().getResponse();

    Links links = Links.valueOf(response.getHeader("Link"));
    assertThat(links.hasLink("self"), is(true));
    assertThat(links.hasLink("person"), is(true));
}