DATACMNS-20 - Renamed Repository.findById(…) to findOne(…).

Added some @SuppressWarnings where necessary.
This commit is contained in:
Oliver Gierke
2011-03-11 18:15:45 +01:00
parent 80359c4d07
commit e00ca67a12
8 changed files with 16 additions and 13 deletions

View File

@@ -54,7 +54,7 @@ public interface Repository<T, ID extends Serializable> {
* found
* @throws IllegalArgumentException if primaryKey is {@code null}
*/
T findById(ID id);
T findOne(ID id);
/**

View File

@@ -81,6 +81,7 @@ public abstract class RepositoryFactoryBeanSupport<T extends Repository<S, ID>,
/* (non-Javadoc)
* @see org.springframework.data.repository.support.EntityMetadataProvider#getEntityMetadata()
*/
@SuppressWarnings("unchecked")
public EntityInformation<S, ID> getEntityInformation() {
RepositoryMetadata repositoryMetadata = factory.getRepositoryMetadata(repositoryInterface);

View File

@@ -85,20 +85,20 @@ public class DefaultRepositoryMetadataUnitTests {
@Test
public void discoversRepositoryBaseClassMethod() throws Exception {
Method method = FooDao.class.getMethod("findById", Integer.class);
Method method = FooDao.class.getMethod("findOne", Integer.class);
DefaultRepositoryMetadata metadata =
new DefaultRepositoryMetadata(FooDao.class, REPOSITORY);
Method reference = metadata.getBaseClassMethodFor(method);
assertEquals(REPOSITORY, reference.getDeclaringClass());
assertThat(reference.getName(), is("findById"));
assertThat(reference.getName(), is("findOne"));
}
@Test
public void discoveresNonRepositoryBaseClassMethod() throws Exception {
Method method = FooDao.class.getMethod("readById", Long.class);
Method method = FooDao.class.getMethod("findOne", Long.class);
DefaultRepositoryMetadata metadata =
new DefaultRepositoryMetadata(FooDao.class, Repository.class);
@@ -141,11 +141,11 @@ public class DefaultRepositoryMetadataUnitTests {
private static interface FooDao extends Repository<User, Integer> {
// Redeclared method
User findById(Integer primaryKey);
User findOne(Integer primaryKey);
// Not a redeclared method
User readById(Long primaryKey);
User findOne(Long primaryKey);
}
/**
@@ -166,7 +166,7 @@ public class DefaultRepositoryMetadataUnitTests {
static abstract class DummyGenericRepositorySupport<T, ID extends Serializable>
implements Repository<T, ID> {
public T findById(ID id) {
public T findOne(ID id) {
return null;
}

View File

@@ -34,7 +34,7 @@ import org.springframework.data.domain.Persistable;
@RunWith(MockitoJUnitRunner.class)
public class PersistableEntityInformationUnitTests {
@SuppressWarnings("rawtypes")
@SuppressWarnings({ "rawtypes", "unchecked" })
static final PersistableEntityInformation metadata =
new PersistableEntityInformation(Persistable.class);
@@ -43,6 +43,7 @@ public class PersistableEntityInformationUnitTests {
@Test
@SuppressWarnings("unchecked")
public void usesPersistablesGetId() throws Exception {
when(persistable.getId()).thenReturn(2L, 1L, 3L);
@@ -53,6 +54,7 @@ public class PersistableEntityInformationUnitTests {
@Test
@SuppressWarnings("unchecked")
public void usesPersistablesIsNew() throws Exception {
when(persistable.isNew()).thenReturn(true, false);