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 b5ea01140..012f5361e 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 @@ -90,8 +90,7 @@ class RepositorySearchController extends AbstractRepositoryRestController { * @return */ @ResponseBody - @RequestMapping(value = BASE_MAPPING, method = RequestMethod.GET, // - produces = { "application/json", "application/x-spring-data-compact+json" }) + @RequestMapping(value = BASE_MAPPING, method = RequestMethod.GET) public Resource listSearches(RepositoryRestRequest request) { SearchResourceMappings resourceMappings = request.getSearchMappings(); @@ -120,8 +119,7 @@ class RepositorySearchController extends AbstractRepositoryRestController { * @throws ResourceNotFoundException */ @ResponseBody - @RequestMapping(value = BASE_MAPPING + "/{search}", method = RequestMethod.GET, // - produces = { "application/json", "application/x-spring-data-verbose+json" }) + @RequestMapping(value = BASE_MAPPING + "/{search}", method = RequestMethod.GET) public ResponseEntity> executeSearch(RepositoryRestRequest request, @PathVariable String search, Pageable pageable) { diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/AbstractWebIntegrationTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/AbstractWebIntegrationTests.java index cebc410b1..4a0cdcf85 100644 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/AbstractWebIntegrationTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/AbstractWebIntegrationTests.java @@ -255,5 +255,22 @@ public abstract class AbstractWebIntegrationTests { andExpect(jsonPath("$._links", notNullValue())); } + /** + * @see DATAREST-203 + */ + @Test + public void exposesSearchesForRootResources() throws Exception { + + MockHttpServletResponse response = request("/"); + + for (String rel : expectedRootLinkRels()) { + + Link link = assertHasLinkWithRel(rel, response); + Link searchLink = assertHasLinkWithRel("search", request(link)); + + request(searchLink); + } + } + protected abstract Iterable expectedRootLinkRels(); } diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/mongodb/ProfileRepository.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/mongodb/ProfileRepository.java index bd39f3517..c09e5b5f2 100644 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/mongodb/ProfileRepository.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/mongodb/ProfileRepository.java @@ -1,8 +1,29 @@ +/* + * Copyright 2012-2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.data.rest.webmvc.mongodb; +import java.util.List; + import org.springframework.data.repository.PagingAndSortingRepository; /** * @author Jon Brisbin + * @author Oliver Gierke */ -public interface ProfileRepository extends PagingAndSortingRepository {} +public interface ProfileRepository extends PagingAndSortingRepository { + + List findByType(String type); +} diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/mongodb/UserRepository.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/mongodb/UserRepository.java index b1a5c051d..428729cfa 100644 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/mongodb/UserRepository.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/mongodb/UserRepository.java @@ -16,6 +16,7 @@ package org.springframework.data.rest.webmvc.mongodb; import java.math.BigInteger; +import java.util.List; import org.springframework.data.repository.CrudRepository; @@ -24,4 +25,5 @@ import org.springframework.data.repository.CrudRepository; */ public interface UserRepository extends CrudRepository { + List findByFirstname(String firstname); }