DATAREST-1421 - Deprecate ALPS_JSON and ALPS_JSON_VALUE.
Instead, use Spring HATEAOS's MediaTypes.ALPS_JSON and ALPS_JSON_VALUE.
This commit is contained in:
@@ -89,7 +89,7 @@ public abstract class CommonWebTests extends AbstractWebIntegrationTests {
|
||||
client.follow(profileLink, RestMediaTypes.SCHEMA_JSON).andExpect(status().is2xxSuccessful());
|
||||
|
||||
// ALPS
|
||||
client.follow(profileLink, RestMediaTypes.ALPS_JSON).andExpect(status().is2xxSuccessful());
|
||||
client.follow(profileLink, MediaTypes.ALPS_JSON).andExpect(status().is2xxSuccessful());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,6 @@ import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
import net.minidev.json.JSONArray;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -33,14 +31,14 @@ import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
|
||||
import org.springframework.data.rest.tests.AbstractControllerIntegrationTests;
|
||||
import org.springframework.data.rest.tests.TestMvcClient;
|
||||
import org.springframework.data.rest.webmvc.ProfileController;
|
||||
import org.springframework.data.rest.webmvc.RestMediaTypes;
|
||||
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
|
||||
import org.springframework.data.rest.webmvc.jpa.Item;
|
||||
import org.springframework.data.rest.webmvc.jpa.JpaRepositoryConfig;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.hateoas.client.JsonPathLinkDiscoverer;
|
||||
import org.springframework.hateoas.client.LinkDiscoverer;
|
||||
import org.springframework.hateoas.client.LinkDiscoverers;
|
||||
import org.springframework.hateoas.client.JsonPathLinkDiscoverer;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
@@ -50,6 +48,8 @@ import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
|
||||
import net.minidev.json.JSONArray;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link AlpsController}.
|
||||
*
|
||||
@@ -99,7 +99,7 @@ public class AlpsControllerIntegrationTests extends AbstractControllerIntegratio
|
||||
Link profileLink = client.discoverUnique("profile");
|
||||
Link peopleLink = client.discoverUnique(profileLink, "people", MediaType.ALL);
|
||||
|
||||
client.follow(peopleLink, RestMediaTypes.ALPS_JSON)//
|
||||
client.follow(peopleLink, MediaTypes.ALPS_JSON)//
|
||||
.andExpect(jsonPath("$.alps.version").value("1.0"))//
|
||||
.andExpect(jsonPath("$.alps.descriptor[*].name", hasItems("people", "person")));
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class AlpsControllerIntegrationTests extends AbstractControllerIntegratio
|
||||
Link profileLink = client.discoverUnique("profile");
|
||||
Link itemsLink = client.discoverUnique(profileLink, "items", MediaType.ALL);
|
||||
|
||||
client.follow(itemsLink, RestMediaTypes.ALPS_JSON)//
|
||||
client.follow(itemsLink, MediaTypes.ALPS_JSON)//
|
||||
// Exposes standard property
|
||||
.andExpect(jsonPath("$.alps.descriptor[*].descriptor[*].name", hasItems("name")))
|
||||
// Does not expose explicitly @JsonIgnored property
|
||||
@@ -139,7 +139,7 @@ public class AlpsControllerIntegrationTests extends AbstractControllerIntegratio
|
||||
|
||||
assertThat(itemsLink).isNotNull();
|
||||
|
||||
String result = client.follow(itemsLink, RestMediaTypes.ALPS_JSON).andReturn().getResponse().getContentAsString();
|
||||
String result = client.follow(itemsLink, MediaTypes.ALPS_JSON).andReturn().getResponse().getContentAsString();
|
||||
String href = JsonPath.<JSONArray> read(result, "$.alps.descriptor[?(@.id == 'item-representation')].href").get(0)
|
||||
.toString();
|
||||
|
||||
@@ -157,7 +157,7 @@ public class AlpsControllerIntegrationTests extends AbstractControllerIntegratio
|
||||
jsonPath += "descriptor[?(@.name == 'father')]."; // First father descriptor
|
||||
jsonPath += "rt"; // Return type
|
||||
|
||||
String result = client.follow(usersLink, RestMediaTypes.ALPS_JSON).andReturn().getResponse().getContentAsString();
|
||||
String result = client.follow(usersLink, MediaTypes.ALPS_JSON).andReturn().getResponse().getContentAsString();
|
||||
String rt = JsonPath.<JSONArray> read(result, jsonPath).get(0).toString();
|
||||
|
||||
assertThat(rt).contains(ProfileController.PROFILE_ROOT_MAPPING).endsWith("-representation");
|
||||
@@ -169,7 +169,7 @@ public class AlpsControllerIntegrationTests extends AbstractControllerIntegratio
|
||||
Link profileLink = client.discoverUnique("profile");
|
||||
Link itemsLink = client.discoverUnique(profileLink, "items", MediaType.ALL);
|
||||
|
||||
client.follow(itemsLink, RestMediaTypes.ALPS_JSON)//
|
||||
client.follow(itemsLink, MediaTypes.ALPS_JSON)//
|
||||
// Exposes identifier if configured to
|
||||
.andExpect(jsonPath("$.alps.descriptor[*].descriptor[*].name", hasItems("id", "name")));
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.data.rest.webmvc.ProfileResourceProcessor;
|
||||
import org.springframework.data.rest.webmvc.RestMediaTypes;
|
||||
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.hateoas.client.LinkDiscoverers;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -102,8 +103,8 @@ public class ProfileIntegrationTests extends AbstractControllerIntegrationTests
|
||||
Link peopleLink = client.discoverUnique(new Link(ROOT_URI), "people");
|
||||
Link profileLink = client.discoverUnique(peopleLink, ProfileResourceProcessor.PROFILE_REL);
|
||||
|
||||
client.follow(profileLink, RestMediaTypes.ALPS_JSON).andExpect(status().is2xxSuccessful())
|
||||
.andExpect(content().contentTypeCompatibleWith(RestMediaTypes.ALPS_JSON));
|
||||
client.follow(profileLink, MediaTypes.ALPS_JSON).andExpect(status().is2xxSuccessful())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaTypes.ALPS_JSON));
|
||||
|
||||
client.follow(profileLink, RestMediaTypes.SCHEMA_JSON).andExpect(status().is2xxSuccessful())
|
||||
.andExpect(content().contentTypeCompatibleWith(RestMediaTypes.SCHEMA_JSON));
|
||||
|
||||
@@ -32,8 +32,17 @@ public class RestMediaTypes {
|
||||
public static final MediaType JSON_PATCH_JSON = MediaType.valueOf("application/json-patch+json");
|
||||
public static final MediaType MERGE_PATCH_JSON = MediaType.valueOf("application/merge-patch+json");
|
||||
|
||||
/**
|
||||
* @deprecated Migrate to {@link MediaTypes#ALPS_JSON_VALUE}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String ALPS_JSON_VALUE = "application/alps+json";
|
||||
public static final MediaType ALPS_JSON = MediaType.parseMediaType(ALPS_JSON_VALUE);
|
||||
|
||||
/**
|
||||
* @deprecated Migrate to {@link MediaTypes#ALPS_JSON}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final MediaType ALPS_JSON = MediaType.parseMediaType(MediaTypes.ALPS_JSON_VALUE);
|
||||
|
||||
public static final String SCHEMA_JSON_VALUE = "application/schema+json";
|
||||
public static final MediaType SCHEMA_JSON = MediaType.valueOf(SCHEMA_JSON_VALUE);
|
||||
|
||||
@@ -25,8 +25,8 @@ import org.springframework.data.rest.core.mapping.ResourceMappings;
|
||||
import org.springframework.data.rest.webmvc.BasePathAwareController;
|
||||
import org.springframework.data.rest.webmvc.ProfileController;
|
||||
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
|
||||
import org.springframework.data.rest.webmvc.RestMediaTypes;
|
||||
import org.springframework.data.rest.webmvc.RootResourceInformation;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -68,7 +68,7 @@ public class AlpsController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = ProfileController.RESOURCE_PROFILE_MAPPING, method = OPTIONS,
|
||||
produces = RestMediaTypes.ALPS_JSON_VALUE)
|
||||
produces = MediaTypes.ALPS_JSON_VALUE)
|
||||
HttpEntity<?> alpsOptions() {
|
||||
|
||||
verifyAlpsEnabled();
|
||||
@@ -86,7 +86,7 @@ public class AlpsController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = ProfileController.RESOURCE_PROFILE_MAPPING, method = GET,
|
||||
produces = { MediaType.ALL_VALUE, RestMediaTypes.ALPS_JSON_VALUE })
|
||||
produces = { MediaType.ALL_VALUE, MediaTypes.ALPS_JSON_VALUE })
|
||||
HttpEntity<RootResourceInformation> descriptor(RootResourceInformation information) {
|
||||
|
||||
verifyAlpsEnabled();
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.util.Collections;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.rest.webmvc.RestMediaTypes;
|
||||
import org.springframework.data.rest.webmvc.RootResourceInformation;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.hateoas.mediatype.alps.Alps;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
@@ -61,7 +61,7 @@ public class AlpsJsonHttpMessageConverter extends MappingJackson2HttpMessageConv
|
||||
mapper.setSerializationInclusion(Include.NON_EMPTY);
|
||||
|
||||
setPrettyPrint(true);
|
||||
setSupportedMediaTypes(Arrays.asList(RestMediaTypes.ALPS_JSON, MediaType.APPLICATION_JSON, MediaType.ALL));
|
||||
setSupportedMediaTypes(Arrays.asList(MediaTypes.ALPS_JSON, MediaType.APPLICATION_JSON, MediaType.ALL));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user