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:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user