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