Example usage for org.springframework.hateoas Link valueOf

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

Introduction

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

Prototype

public static Link valueOf(String element) 

Source Link

Document

Factory method to easily create Link instances from RFC-5988 compatible String representations of a link.

Usage

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

@Test
public void returnsNullForNullOrEmptyLink() {

    assertThat(Link.valueOf(null), is(nullValue()));
    assertThat(Link.valueOf(""), is(nullValue()));
}

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

@Test
public void parsesRFC5988HeaderIntoLink() {

    assertThat(Link.valueOf("</something>;rel=\"foo\""), is(new Link("/something", "foo")));
    assertThat(Link.valueOf("</something>;rel=\"foo\";title=\"Some title\""),
            is(new Link("/something", "foo")));
}

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

@Test(expected = IllegalArgumentException.class)
public void rejectsMissingRelAttribute() {
    Link.valueOf("</something>);title=\"title\"");
}

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

@Test(expected = IllegalArgumentException.class)
public void rejectsLinkWithoutAttributesAtAll() {
    Link.valueOf("</something>);title=\"title\"");
}

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

@Test(expected = IllegalArgumentException.class)
public void rejectsNonRFC5988String() {
    Link.valueOf("foo");
}