DATACMNS-453 - Fix NPE in isPageableRepository() for Repositories without a findAll() method.
Added additional null check to isPagingRepository() to handle repository definitions that do not have a findAll method. Original pull request: #69.
This commit is contained in:
committed by
Thomas Darimont
parent
3131ffbc5f
commit
43d731f5ed
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
* Copyright 2011-2014 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.
|
||||
@@ -27,6 +27,7 @@ import org.junit.Test;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.querydsl.User;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
|
||||
@@ -35,6 +36,7 @@ import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
* @author Fabian Buch
|
||||
*/
|
||||
public class AbstractRepositoryMetadataUnitTests {
|
||||
|
||||
@@ -64,6 +66,26 @@ public class AbstractRepositoryMetadataUnitTests {
|
||||
assertThat(metadata.getReturnedDomainClass(method), is(typeCompatibleWith(User.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-453
|
||||
*/
|
||||
@Test
|
||||
public void nonPageableRepository() {
|
||||
|
||||
RepositoryMetadata metadata = new DummyRepositoryMetadata(UserRepository.class);
|
||||
assertThat(metadata.isPagingRepository(), is(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-453
|
||||
*/
|
||||
@Test
|
||||
public void pageableRepository() {
|
||||
|
||||
RepositoryMetadata metadata = new DummyRepositoryMetadata(PagedRepository.class);
|
||||
assertThat(metadata.isPagingRepository(), is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determinesReturnTypeFromGenericType() throws Exception {
|
||||
RepositoryMetadata metadata = new DummyRepositoryMetadata(ExtendingRepository.class);
|
||||
@@ -102,6 +124,10 @@ public class AbstractRepositoryMetadataUnitTests {
|
||||
List<Map<String, Object>> anotherMethod();
|
||||
}
|
||||
|
||||
interface PagedRepository extends PagingAndSortingRepository<User, Long> {
|
||||
|
||||
}
|
||||
|
||||
class GenericType<T> {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user