Example usage for org.springframework.hateoas Link Link

List of usage examples for org.springframework.hateoas Link Link

Introduction

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

Prototype

public Link(String href) 

Source Link

Document

Creates a new link to the given URI with the self rel.

Usage

From source file:org.springframework.hateoas.LinkUnitTest.java

/**
 * @see #172//  w ww .ja va  2s  .c  om
 */
@Test
public void serializesCorrectly() throws IOException {

    Link link = new Link("http://foobar{?foo,bar}");

    ObjectOutputStream stream = new ObjectOutputStream(new ByteArrayOutputStream());
    stream.writeObject(link);
    stream.close();
}

From source file:org.springframework.hateoas.ResourceIntegrationTest.java

@Test
public void inlinesContent() throws Exception {

    Person person = new Person();
    person.firstname = "Dave";
    person.lastname = "Matthews";

    Resource<Person> resource = new Resource<Person>(person);
    resource.add(new Link("localhost"));

    assertThat(write(resource), is(REFERENCE));
}

From source file:org.springframework.hateoas.ResourceIntegrationTest.java

/**
 * @see #14//from  ww  w . j  av  a2  s  .  c o  m
 */
@Test
public void readsResourceSupportCorrectly() throws Exception {

    PersonResource result = read(REFERENCE, PersonResource.class);

    assertThat(result.getLinks(), hasSize(1));
    assertThat(result.getLinks(), hasItem(new Link("localhost")));
    assertThat(result.getContent().firstname, is("Dave"));
    assertThat(result.getContent().lastname, is("Matthews"));
}