diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ControllerUtils.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ControllerUtils.java index f34ea1f6c..2183d96be 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ControllerUtils.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ControllerUtils.java @@ -30,7 +30,7 @@ import org.springframework.http.ResponseEntity; */ public class ControllerUtils { - public static final Resource EMPTY_RESOURCE = new Resource(Collections.emptyList()); + public static final Resource EMPTY_RESOURCE = new Resource(new Object()); public static final Resources> EMPTY_RESOURCES = new Resources>( Collections.> emptyList()); public static final Iterable> EMPTY_RESOURCE_LIST = Collections.emptyList(); diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchController.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchController.java index 012f5361e..f064613ba 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchController.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchController.java @@ -19,7 +19,6 @@ import static org.springframework.data.rest.webmvc.ControllerUtils.*; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; @@ -91,7 +90,7 @@ class RepositorySearchController extends AbstractRepositoryRestController { */ @ResponseBody @RequestMapping(value = BASE_MAPPING, method = RequestMethod.GET) - public Resource listSearches(RepositoryRestRequest request) { + public ResourceSupport listSearches(RepositoryRestRequest request) { SearchResourceMappings resourceMappings = request.getSearchMappings(); @@ -105,7 +104,10 @@ class RepositorySearchController extends AbstractRepositoryRestController { throw new ResourceNotFoundException(); } - return new Resource(Collections.emptyList(), queryMethodLinks); + ResourceSupport result = new ResourceSupport(); + result.add(queryMethodLinks); + + return result; } /** diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositorySearchControllerIntegrationTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositorySearchControllerIntegrationTests.java index 8e390a18b..c5a51e666 100644 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositorySearchControllerIntegrationTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositorySearchControllerIntegrationTests.java @@ -29,7 +29,7 @@ import org.springframework.data.rest.webmvc.jpa.Order; import org.springframework.data.rest.webmvc.jpa.Person; import org.springframework.data.rest.webmvc.jpa.TestDataPopulator; import org.springframework.hateoas.PagedResources; -import org.springframework.hateoas.Resource; +import org.springframework.hateoas.ResourceSupport; import org.springframework.hateoas.Resources; import org.springframework.http.ResponseEntity; import org.springframework.test.context.ContextConfiguration; @@ -56,7 +56,7 @@ public class RepositorySearchControllerIntegrationTests extends AbstractControll public void rendersCorrectSearchLinksForPersons() { RepositoryRestRequest request = getRequest(Person.class); - Resource resource = controller.listSearches(request); + ResourceSupport resource = controller.listSearches(request); ResourceTester tester = ResourceTester.of(resource); tester.assertNumberOfLinks(4);