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));
|
||||
|
||||
Reference in New Issue
Block a user