DATAREST-203 - Fixed listing of searches.
RepositorySearchController now returns a ResourceSupport instead of a Resource as it will only return links anyway. Latest changes in Spring HATEOAS prevent Resource from being used with collection based content to prevent invalid rendering.
This commit is contained in:
@@ -30,7 +30,7 @@ import org.springframework.http.ResponseEntity;
|
||||
*/
|
||||
public class ControllerUtils {
|
||||
|
||||
public static final Resource<?> EMPTY_RESOURCE = new Resource<Object>(Collections.emptyList());
|
||||
public static final Resource<?> EMPTY_RESOURCE = new Resource<Object>(new Object());
|
||||
public static final Resources<Resource<?>> EMPTY_RESOURCES = new Resources<Resource<?>>(
|
||||
Collections.<Resource<?>> emptyList());
|
||||
public static final Iterable<Resource<?>> EMPTY_RESOURCE_LIST = Collections.emptyList();
|
||||
|
||||
@@ -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<Object>(Collections.emptyList(), queryMethodLinks);
|
||||
ResourceSupport result = new ResourceSupport();
|
||||
result.add(queryMethodLinks);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user