@ -247,12 +247,12 @@ public class DefaultRepositoryInformationUnitTests {
@@ -247,12 +247,12 @@ public class DefaultRepositoryInformationUnitTests {
@Test
public void discoversCustomlyImplementedCrudMethodWithGenericParameters ( ) throws Exception {
Sampl eRepositoryImpl customImplementation = new Sampl eRepositoryImpl( ) ;
RepositoryMetadata metadata = new DefaultRepositoryMetadata ( Sampl eRepository. class ) ;
GenericsSav eRepositoryImpl customImplementation = new GenericsSav eRepositoryImpl( ) ;
RepositoryMetadata metadata = new DefaultRepositoryMetadata ( GenericsSav eRepository. class ) ;
RepositoryInformation information = new DefaultRepositoryInformation ( metadata , RepositoryFactorySupport . class ,
customImplementation . getClass ( ) ) ;
Method customBaseRepositoryMethod = Sampl eRepository. class . getMethod ( "save" , Object . class ) ;
Method customBaseRepositoryMethod = GenericsSav eRepository. class . getMethod ( "save" , Object . class ) ;
assertThat ( information . isCustomMethod ( customBaseRepositoryMethod ) , is ( true ) ) ;
}
@ -272,6 +272,18 @@ public class DefaultRepositoryInformationUnitTests {
@@ -272,6 +272,18 @@ public class DefaultRepositoryInformationUnitTests {
is ( DummyRepositoryImpl . class . getMethod ( "save" , Iterable . class ) ) ) ;
}
@Test // DATACMNS-1008, DATACMNS-912, DATACMNS-854
public void discoversCustomlyImplementedCrudMethodWithoutGenericParameters ( ) throws Exception {
SimpleSaveRepositoryImpl customImplementation = new SimpleSaveRepositoryImpl ( ) ;
RepositoryMetadata metadata = new DefaultRepositoryMetadata ( SimpleSaveRepository . class ) ;
RepositoryInformation information = new DefaultRepositoryInformation ( metadata , RepositoryFactorySupport . class ,
customImplementation . getClass ( ) ) ;
Method customBaseRepositoryMethod = SimpleSaveRepository . class . getMethod ( "save" , Object . class ) ;
assertThat ( information . isCustomMethod ( customBaseRepositoryMethod ) , is ( true ) ) ;
}
private static Method getMethodFrom ( Class < ? > type , String name ) {
for ( Method method : type . getMethods ( ) ) {
@ -374,11 +386,13 @@ public class DefaultRepositoryInformationUnitTests {
@@ -374,11 +386,13 @@ public class DefaultRepositoryInformationUnitTests {
List < User > findAll ( ) ;
}
interface SampleRepository extends CrudRepository < Sample , Long > { }
// DATACMNS-854, DATACMNS-912
interface GenericsSaveRepository extends CrudRepository < Sample , Long > { }
static class SampleRepositoryImpl {
static class GenericsSav eRepositoryImpl {
public < S extends Sample > S save ( S entity ) {
public < T extends Sample > T save ( T entity ) {
return entity ;
}
}
@ -395,4 +409,15 @@ public class DefaultRepositoryInformationUnitTests {
@@ -395,4 +409,15 @@ public class DefaultRepositoryInformationUnitTests {
private @Delegate CrudRepository < T , ID > delegate ;
}
// DATACMNS-1008, DATACMNS-854, DATACMNS-912
interface SimpleSaveRepository extends CrudRepository < Sample , Long > { }
static class SimpleSaveRepositoryImpl {
public Sample save ( Sample entity ) {
return entity ;
}
}
}