DATAREST-445 - Fixed domain type lookup in RepositoryCollectionResourceMapping.

We now use the domain type provided by RepositoryMetadata instead of manually looking up to be sure to pick up customizations correctly.
This commit is contained in:
Oliver Gierke
2015-01-16 12:22:17 +01:00
parent a2ba4224fb
commit 8700c60cef
2 changed files with 20 additions and 1 deletions

View File

@@ -74,7 +74,7 @@ class RepositoryCollectionResourceMapping implements CollectionResourceMapping {
this.repositoryAnnotation = AnnotationUtils.findAnnotation(repositoryType, RepositoryRestResource.class);
this.repositoryIsExportCandidate = Modifier.isPublic(repositoryType.getModifiers());
Class<?> domainType = RepositoriesUtils.getDomainType(repositoryType);
Class<?> domainType = metadata.getDomainType();
this.domainTypeMapping = EVO_INFLECTOR_IS_PRESENT ? new EvoInflectorTypeBasedCollectionResourceMapping(domainType,
relProvider) : new TypeBasedCollectionResourceMapping(domainType, relProvider);

View File

@@ -91,6 +91,25 @@ public class RepositoryCollectionResourceMappingUnitTests {
assertThat(mapping.getItemResourceRel(), is("bar"));
}
/**
* @see DATAREST-445
*/
@Test
public void usesDomainTypeFromRepositoryMetadata() {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(PersonRepository.class) {
@Override
public Class<?> getDomainType() {
return Object.class;
}
};
RepositoryCollectionResourceMapping mapping = new RepositoryCollectionResourceMapping(metadata);
assertThat(mapping.getPath(), is(new Path("/objects")));
}
private static CollectionResourceMapping getResourceMappingFor(Class<?> repositoryInterface) {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(repositoryInterface);