diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/alps/RootResourceInformationToAlpsDescriptorConverter.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/alps/RootResourceInformationToAlpsDescriptorConverter.java index 361e0f127..2069c6691 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/alps/RootResourceInformationToAlpsDescriptorConverter.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/alps/RootResourceInformationToAlpsDescriptorConverter.java @@ -150,6 +150,7 @@ public class RootResourceInformationToAlpsDescriptorConverter { return descriptor().// id(metadata.getItemResourceRel().concat("-representation")).// + href(entityLinks.linkFor(type).slash("schema").toString()).// doc(getDocFor(metadata.getItemResourceDescription())).// descriptors(buildPropertyDescriptors(type, metadata.getItemResourceRel())).// build(); diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/alps/AlpsControllerIntegrationTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/alps/AlpsControllerIntegrationTests.java index 6c89a4153..427103b16 100644 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/alps/AlpsControllerIntegrationTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/alps/AlpsControllerIntegrationTests.java @@ -18,7 +18,6 @@ package org.springframework.data.rest.webmvc.alps; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; import org.junit.Before; @@ -37,6 +36,7 @@ import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.result.MockMvcResultHandlers; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; @@ -104,7 +104,6 @@ public class AlpsControllerIntegrationTests extends AbstractControllerIntegratio Link peopleLink = discoverUnique(profileLink.getHref(), "people"); mvc.perform(get(peopleLink.getHref())).// - andDo(print()).// andExpect(jsonPath("$.version").value("1.0")).// andExpect(jsonPath("$.descriptors[*].name", hasItems("people", "person"))); } @@ -121,12 +120,26 @@ public class AlpsControllerIntegrationTests extends AbstractControllerIntegratio assertThat(usersLink, is(nullValue())); - mvc.perform(get(itemsLink.getHref())).// - andDo(print()).// - andExpect(jsonPath("$.descriptors[*].descriptors[*].name", hasItems("id", "name"))).// - andExpect(jsonPath("$.descriptors[*].descriptors[*].name", - everyItem(not(isIn(new String[]{"owner", "manager", "curator"}))))); + mvc.perform(get(itemsLink.getHref())) + .andExpect(jsonPath("$.descriptors[*].descriptors[*].name", hasItems("id", "name"))) + .andExpect( + jsonPath("$.descriptors[*].descriptors[*].name", everyItem(not(isIn(new String[] { "owner", "manager", + "curator" }))))); + } + /** + * @see DATAREST-494 + */ + @Test + public void linksToJsonSchemaFromRepresentationDescriptor() throws Exception { + + Link profileLink = discoverUnique("/", "profile"); + Link usersLink = discoverUnique(profileLink.getHref(), "items"); + + assertThat(usersLink, is(notNullValue())); + + mvc.perform(get(usersLink.getHref())).andDo(MockMvcResultHandlers.print()) + .andExpect(jsonPath("$.descriptors[?(@.id == 'item-representation')].href", is(notNullValue()))); } private Link discoverUnique(String href, String rel) throws Exception {