DATAREST-1341 - Adapt to package refactorings in Spring HATEOAS.

This commit is contained in:
Oliver Drotbohm
2019-02-27 12:59:45 +01:00
parent 85694576b2
commit 1bf08180db
69 changed files with 370 additions and 1043 deletions

View File

@@ -48,7 +48,7 @@ import org.springframework.data.rest.webmvc.jpa.Order;
import org.springframework.data.rest.webmvc.jpa.Person;
import org.springframework.data.rest.webmvc.support.DefaultedPageable;
import org.springframework.data.rest.webmvc.support.ETag;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.EntityModel;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@@ -243,7 +243,7 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll
Mockito.when(assembler.toFullResource(Mockito.any(Object.class))).thenReturn(resource);
ResponseEntity<Resource<?>> entity = controller.getItemResource(getResourceInformation(Address.class), address.id,
ResponseEntity<EntityModel<?>> entity = controller.getItemResource(getResourceInformation(Address.class), address.id,
assembler, new HttpHeaders());
assertThat(entity.getHeaders().getETag()).isNotNull();

View File

@@ -35,9 +35,9 @@ import org.springframework.data.rest.webmvc.jpa.JpaRepositoryConfig;
import org.springframework.data.rest.webmvc.jpa.Person;
import org.springframework.data.rest.webmvc.jpa.TestDataPopulator;
import org.springframework.data.rest.webmvc.support.DefaultedPageable;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.hateoas.Resources;
import org.springframework.hateoas.PagedModel;
import org.springframework.hateoas.RepresentationModel;
import org.springframework.hateoas.CollectionModel;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -72,7 +72,7 @@ public class RepositorySearchControllerIntegrationTests extends AbstractControll
public void rendersCorrectSearchLinksForPersons() throws Exception {
RootResourceInformation request = getResourceInformation(Person.class);
ResourceSupport resource = controller.listSearches(request);
RepresentationModel resource = controller.listSearches(request);
ResourceTester tester = ResourceTester.of(resource);
tester.assertNumberOfLinks(7); // Self link included
@@ -107,7 +107,7 @@ public class RepositorySearchControllerIntegrationTests extends AbstractControll
Sort.unsorted(), assembler, new HttpHeaders());
ResourceTester tester = ResourceTester.of(response.getBody());
PagedResources<Object> pagedResources = tester.assertIsPage();
PagedModel<Object> pagedResources = tester.assertIsPage();
assertThat(pagedResources.getContent()).hasSize(1);
ResourceMetadata metadata = getMetadata(Person.class);
@@ -169,7 +169,7 @@ public class RepositorySearchControllerIntegrationTests extends AbstractControll
ResponseEntity<?> result = controller.executeSearch(resourceInformation, parameters, "findByAuthorsContains",
PAGEABLE, Sort.unsorted(), assembler, new HttpHeaders());
assertThat(result.getBody()).isInstanceOf(Resources.class);
assertThat(result.getBody()).isInstanceOf(CollectionModel.class);
}
@Test // DATAREST-515

View File

@@ -38,9 +38,9 @@ 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.LinkDiscoverer;
import org.springframework.hateoas.LinkDiscoverers;
import org.springframework.hateoas.core.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;

View File

@@ -40,7 +40,7 @@ import org.springframework.data.rest.webmvc.PersistentEntityResource;
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.EntityModel;
import org.springframework.http.HttpHeaders;
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter;
import org.springframework.mock.web.MockHttpServletRequest;
@@ -122,7 +122,7 @@ public class DataRest262Tests {
JpaPersistentEntity<?> persistentEntity = mappingContext.getRequiredPersistentEntity(AircraftMovement.class);
Resource<Object> resource = PersistentEntityResource.build(movement, persistentEntity).//
EntityModel<Object> resource = PersistentEntityResource.build(movement, persistentEntity).//
withLink(new Link("/api/airports/" + movement.id)).//
build();

View File

@@ -28,9 +28,9 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.data.rest.tests.TestMvcClient;
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
import org.springframework.hateoas.LinkDiscoverer;
import org.springframework.hateoas.LinkDiscoverers;
import org.springframework.hateoas.core.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.junit4.SpringJUnit4ClassRunner;

View File

@@ -41,7 +41,7 @@ import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.Links;
import org.springframework.hateoas.RelProvider;
import org.springframework.hateoas.server.RelProvider;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.context.ContextConfiguration;

View File

@@ -31,7 +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.LinkDiscoverers;
import org.springframework.hateoas.client.LinkDiscoverers;
import org.springframework.http.MediaType;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.web.WebAppConfiguration;

View File

@@ -41,14 +41,14 @@ import org.springframework.data.rest.webmvc.PersistentEntityResource;
import org.springframework.data.rest.webmvc.jpa.*;
import org.springframework.data.rest.webmvc.util.TestUtils;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkDiscoverer;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.PagedResources.PageMetadata;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.core.EmbeddedWrapper;
import org.springframework.hateoas.core.EmbeddedWrappers;
import org.springframework.hateoas.hal.HalLinkDiscoverer;
import org.springframework.hateoas.PagedModel;
import org.springframework.hateoas.PagedModel.PageMetadata;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.server.core.EmbeddedWrapper;
import org.springframework.hateoas.server.core.EmbeddedWrappers;
import org.springframework.hateoas.mediatype.hal.HalLinkDiscoverer;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -204,7 +204,7 @@ public class PersistentEntitySerializationTests {
withLink(new Link("/orders/1")).//
build();
PagedResources<PersistentEntityResource> persistentEntityResource = new PagedResources<PersistentEntityResource>(
PagedModel<PersistentEntityResource> persistentEntityResource = new PagedModel<PersistentEntityResource>(
Arrays.asList(orderResource), new PageMetadata(1, 0, 10));
String result = mapper.writeValueAsString(persistentEntityResource);
@@ -260,7 +260,7 @@ public class PersistentEntitySerializationTests {
ProjectionFactory factory = new SpelAwareProxyProjectionFactory();
PersonSummary projection = factory.createProjection(PersonSummary.class, person);
String result = mapper.writeValueAsString(new Resource<PersonSummary>(projection));
String result = mapper.writeValueAsString(new EntityModel<PersonSummary>(projection));
assertThat(JsonPath.<Object> read(result, "$._links.self")).isNotNull();
}

View File

@@ -50,12 +50,12 @@ import org.springframework.data.rest.webmvc.support.PagingAndSortingTemplateVari
import org.springframework.data.rest.webmvc.support.RepositoryEntityLinks;
import org.springframework.format.support.DefaultFormattingConversionService;
import org.springframework.format.support.FormattingConversionService;
import org.springframework.hateoas.EntityLinks;
import org.springframework.hateoas.RelProvider;
import org.springframework.hateoas.ResourceProcessor;
import org.springframework.hateoas.core.EvoInflectorRelProvider;
import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.hateoas.mvc.ResourceProcessorInvoker;
import org.springframework.hateoas.server.EntityLinks;
import org.springframework.hateoas.server.RelProvider;
import org.springframework.hateoas.server.RepresentationModelProcessor;
import org.springframework.hateoas.server.core.EvoInflectorRelProvider;
import org.springframework.hateoas.mediatype.hal.Jackson2HalModule;
import org.springframework.hateoas.server.mvc.RepresentationModelProcessorInvoker;
import org.springframework.plugin.core.PluginRegistry;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -129,7 +129,7 @@ public class RepositoryTestsConfig {
return new PersistentEntityJackson2Module(associations, persistentEntities(), uriToEntityConverter, collector,
invokerFactory, mock(LookupObjectSerializer.class),
new ResourceProcessorInvoker(Collections.<ResourceProcessor<?>> emptyList()),
new RepresentationModelProcessorInvoker(Collections.<RepresentationModelProcessor<?>> emptyList()),
new EmbeddedResourcesAssembler(persistentEntities(), associations, mock(ExcerptProjector.class)));
}

View File

@@ -51,7 +51,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt
@Test
public void returnsLinkToSingleResource() {
Link link = entityLinks.linkToSingleResource(Person.class, 1);
Link link = entityLinks.linkToItemResource(Person.class, 1);
assertThat(link.getHref(), endsWith("/people/1{?projection}"));
assertThat(link.getRel()).isEqualTo(LinkRelation.of("person"));
@@ -70,7 +70,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt
@Test // DATAREST-221
public void returnsLinkWithProjectionTemplateVariableIfProjectionIsDefined() {
Link link = entityLinks.linkToSingleResource(Order.class, 1);
Link link = entityLinks.linkToItemResource(Order.class, 1);
assertThat(link.isTemplated()).isTrue();
assertThat(link.getVariableNames()).contains(configuration.getProjectionConfiguration().getParameterName());
@@ -79,7 +79,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt
@Test // DATAREST-155
public void usesCustomGeneratedBackendId() {
Link link = entityLinks.linkToSingleResource(Book.class, 7L);
Link link = entityLinks.linkToItemResource(Book.class, 7L);
assertThat(link.expand().getHref(), endsWith("/7-7-7-7-7-7-7"));
}