@ -223,12 +223,12 @@ public class DefaultRepositoryInformationUnitTests {
@@ -223,12 +223,12 @@ public class DefaultRepositoryInformationUnitTests {
@Test // DATACMNS-912
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 ) ) ;
}
@ -244,6 +244,18 @@ public class DefaultRepositoryInformationUnitTests {
@@ -244,6 +244,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 ( ) ) {
@ -346,11 +358,13 @@ public class DefaultRepositoryInformationUnitTests {
@@ -346,11 +358,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 ;
}
}
@ -367,4 +381,15 @@ public class DefaultRepositoryInformationUnitTests {
@@ -367,4 +381,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 ;
}
}
}