diff --git a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/jpa/PersonRepository.java b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/jpa/PersonRepository.java index be749d0c0..98773b638 100644 --- a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/jpa/PersonRepository.java +++ b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/jpa/PersonRepository.java @@ -27,4 +27,11 @@ public interface PersonRepository extends PagingAndSortingRepository :date") Page findByCreatedUsingISO8601Date(@Param("date") @DateTimeFormat(iso = ISO.DATE_TIME) Date date, Pageable pageable); + + /** + * @see DATAREST-107 - this method matches the earlier one, causing an ambiguous mapping + * except for the exported setting + */ + @RestResource(rel = "firstname", path="firstname", exported = false) + Person findByFirstName(@Param("firstName") String firstName); } diff --git a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/ResourceMappingsIntegrationTest.java b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/ResourceMappingsIntegrationTest.java index 1eb9cb7ff..0197c4697 100644 --- a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/ResourceMappingsIntegrationTest.java +++ b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/ResourceMappingsIntegrationTest.java @@ -36,6 +36,10 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + /** * Integration tests for {@link ResourceMappings}. * @@ -59,7 +63,7 @@ public class ResourceMappingsIntegrationTest { @Test public void detectsAllMappings() { - assertThat(mappings, is(Matchers. iterableWithSize(6))); + assertThat(mappings, is(Matchers.iterableWithSize(6))); } @Test @@ -69,6 +73,15 @@ public class ResourceMappingsIntegrationTest { assertThat(personMappings.isExported(), is(true)); assertThat(personMappings.getSearchResourceMappings().isExported(), is(true)); + + // @see DATAREST-107 + List methodNames = new ArrayList(); + for (MethodResourceMapping method : personMappings.getSearchResourceMappings()) { + methodNames.add(method.getMethod().getName()); + } + assertThat(methodNames.size(), equalTo(3)); + assertThat(methodNames, hasItems("findByFirstName", "findByCreatedGreaterThan", "findByCreatedUsingISO8601Date")); + } @Test @@ -78,6 +91,12 @@ public class ResourceMappingsIntegrationTest { assertThat(creditCardMapping.isExported(), is(false)); assertThat(creditCardMapping.getSearchResourceMappings().isExported(), is(false)); + + int items = 0; + for (MethodResourceMapping method : creditCardMapping.getSearchResourceMappings()) { + items++; + } + assertThat(items, equalTo(0)); } /**