DATACMNS-20 - Renamed Repository.findById(…) to findOne(…).
Added some @SuppressWarnings where necessary.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -74,7 +74,7 @@ public class DomainClassPropertyEditor<T, ID extends Serializable> extends
|
||||
return;
|
||||
}
|
||||
|
||||
setValue(repository.findById(getId(idAsString)));
|
||||
setValue(repository.findOne(getId(idAsString)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public class DomainClassConverter implements ConditionalGenericConverter,
|
||||
|
||||
Repository<?, Serializable> repository = repositories.get(info);
|
||||
Serializable id = service.convert(source, info.getIdType());
|
||||
return repository.findById(id);
|
||||
return repository.findOne(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -65,11 +65,11 @@ public class DomainClassPropertyEditorUnitTests {
|
||||
|
||||
User user = new User(1);
|
||||
when(information.getId(user)).thenReturn(user.getId());
|
||||
when(userRepository.findById(1)).thenReturn(user);
|
||||
when(userRepository.findOne(1)).thenReturn(user);
|
||||
|
||||
editor.setAsText("1");
|
||||
|
||||
verify(userRepository, times(1)).findById(1);
|
||||
verify(userRepository, times(1)).findOne(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ public class DomainClassConverterUnitTests {
|
||||
|
||||
when(service.canConvert(String.class, Long.class)).thenReturn(true);
|
||||
when(service.convert(anyString(), eq(Long.class))).thenReturn(1L);
|
||||
when(repository.findById(1L)).thenReturn(USER);
|
||||
when(repository.findOne(1L)).thenReturn(USER);
|
||||
|
||||
Object user =
|
||||
converter.convert("1", sourceDescriptor, targetDescriptor);
|
||||
|
||||
Reference in New Issue
Block a user