List of usage examples for org.springframework.hateoas Link Link
public Link(String href)
From source file:org.springframework.hateoas.hal.Jackson2HalIntegrationTest.java
@Test public void deserializeMultipleLinks() throws Exception { ResourceSupport expected = new ResourceSupport(); expected.add(new Link("localhost")); expected.add(new Link("localhost2")); assertThat(read(LIST_LINK_REFERENCE, ResourceSupport.class), is(expected)); }
From source file:org.springframework.hateoas.hal.Jackson2HalIntegrationTest.java
@Test public void rendersSimpleResourcesAsEmbedded() throws Exception { List<String> content = new ArrayList<String>(); content.add("first"); content.add("second"); Resources<String> resources = new Resources<String>(content); resources.add(new Link("localhost")); assertThat(write(resources), is(SIMPLE_EMBEDDED_RESOURCE_REFERENCE)); }
From source file:org.springframework.hateoas.hal.Jackson2HalIntegrationTest.java
@Test public void deserializesSimpleResourcesAsEmbedded() throws Exception { List<String> content = new ArrayList<String>(); content.add("first"); content.add("second"); Resources<String> expected = new Resources<String>(content); expected.add(new Link("localhost")); Resources<String> result = mapper.readValue(SIMPLE_EMBEDDED_RESOURCE_REFERENCE, mapper.getTypeFactory().constructParametricType(Resources.class, String.class)); assertThat(result, is(expected));//from w w w.j a v a 2 s . co m }
From source file:org.springframework.hateoas.hal.Jackson2HalIntegrationTest.java
@Test public void rendersSingleResourceResourcesAsEmbedded() throws Exception { List<Resource<SimplePojo>> content = new ArrayList<Resource<SimplePojo>>(); content.add(new Resource<SimplePojo>(new SimplePojo("test1", 1), new Link("localhost"))); Resources<Resource<SimplePojo>> resources = new Resources<Resource<SimplePojo>>(content); resources.add(new Link("localhost")); assertThat(write(resources), is(SINGLE_EMBEDDED_RESOURCE_REFERENCE)); }
From source file:org.springframework.hateoas.hal.Jackson2HalIntegrationTest.java
@Test public void deserializesSingleResourceResourcesAsEmbedded() throws Exception { List<Resource<SimplePojo>> content = new ArrayList<Resource<SimplePojo>>(); content.add(new Resource<SimplePojo>(new SimplePojo("test1", 1), new Link("localhost"))); Resources<Resource<SimplePojo>> expected = new Resources<Resource<SimplePojo>>(content); expected.add(new Link("localhost")); Resources<Resource<SimplePojo>> result = mapper.readValue(SINGLE_EMBEDDED_RESOURCE_REFERENCE, mapper.getTypeFactory().constructParametricType(Resources.class, mapper.getTypeFactory().constructParametricType(Resource.class, SimplePojo.class))); assertThat(result, is(expected));//from w ww . j av a 2s. co m }
From source file:org.springframework.hateoas.hal.Jackson2HalIntegrationTest.java
@Test public void rendersMultipleResourceResourcesAsEmbedded() throws Exception { Resources<Resource<SimplePojo>> resources = setupResources(); resources.add(new Link("localhost")); assertThat(write(resources), is(LIST_EMBEDDED_RESOURCE_REFERENCE)); }
From source file:org.springframework.hateoas.hal.Jackson2HalIntegrationTest.java
@Test public void deserializesMultipleResourceResourcesAsEmbedded() throws Exception { Resources<Resource<SimplePojo>> expected = setupResources(); expected.add(new Link("localhost")); Resources<Resource<SimplePojo>> result = mapper.readValue(LIST_EMBEDDED_RESOURCE_REFERENCE, mapper.getTypeFactory().constructParametricType(Resources.class, mapper.getTypeFactory().constructParametricType(Resource.class, SimplePojo.class))); assertThat(result, is(expected));/* ww w. ja v a 2 s . co m*/ }
From source file:org.springframework.hateoas.hal.Jackson2HalIntegrationTest.java
/** * @see #47, #60//from w w w.jav a2 s .c o m */ @Test public void serializesAnnotatedResourceResourcesAsEmbedded() throws Exception { List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<Resource<SimpleAnnotatedPojo>>(); content.add(new Resource<SimpleAnnotatedPojo>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost"))); Resources<Resource<SimpleAnnotatedPojo>> resources = new Resources<Resource<SimpleAnnotatedPojo>>(content); resources.add(new Link("localhost")); assertThat(write(resources), is(ANNOTATED_EMBEDDED_RESOURCE_REFERENCE)); }
From source file:org.springframework.hateoas.hal.Jackson2HalIntegrationTest.java
/** * @see #47, #60// w w w . j a v a 2s .c o m */ @Test public void deserializesAnnotatedResourceResourcesAsEmbedded() throws Exception { List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<Resource<SimpleAnnotatedPojo>>(); content.add(new Resource<SimpleAnnotatedPojo>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost"))); Resources<Resource<SimpleAnnotatedPojo>> expected = new Resources<Resource<SimpleAnnotatedPojo>>(content); expected.add(new Link("localhost")); Resources<Resource<SimpleAnnotatedPojo>> result = mapper.readValue(ANNOTATED_EMBEDDED_RESOURCE_REFERENCE, mapper.getTypeFactory().constructParametricType(Resources.class, mapper.getTypeFactory() .constructParametricType(Resource.class, SimpleAnnotatedPojo.class))); assertThat(result, is(expected)); }
From source file:org.springframework.hateoas.hal.Jackson2HalIntegrationTest.java
/** * @see #125//from ww w .ja va 2s . c o m */ @Test public void rendersCuriesCorrectly() throws Exception { Resources<Object> resources = new Resources<Object>(Collections.emptySet(), new Link("foo"), new Link("bar", "myrel")); assertThat(getCuriedObjectMapper().writeValueAsString(resources), is(CURIED_DOCUMENT)); }