DATAREST-203 - Fixed accidentally broken RepositorySearchController.

Due to the change in the default media type, the RepositorySearchController was totally broken as it used "produces" clauses in the request mapping. I've removed them and added test cases to make sure the search resources are exposed and are accessible.
This commit is contained in:
Oliver Gierke
2013-12-28 15:50:45 +01:00
parent f641398465
commit c953e6f54d
4 changed files with 43 additions and 5 deletions

View File

@@ -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<Resources<?>> executeSearch(RepositoryRestRequest request, @PathVariable String search,
Pageable pageable) {

View File

@@ -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<String> expectedRootLinkRels();
}

View File

@@ -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<Profile, String> {}
public interface ProfileRepository extends PagingAndSortingRepository<Profile, String> {
List<Profile> findByType(String type);
}

View File

@@ -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<User, BigInteger> {
List<User> findByFirstname(String firstname);
}