use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method discoversCustomlyImplementedCrudMethodWithGenericParameters.
// DATACMNS-912
@Test
public void discoversCustomlyImplementedCrudMethodWithGenericParameters() throws Exception {
GenericsSaveRepositoryImpl customImplementation = new GenericsSaveRepositoryImpl();
RepositoryMetadata metadata = new DefaultRepositoryMetadata(GenericsSaveRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, RepositoryFactorySupport.class, RepositoryComposition.just(customImplementation).withMethodLookup(MethodLookups.forRepositoryTypes(metadata)));
Method customBaseRepositoryMethod = GenericsSaveRepository.class.getMethod("save", Object.class);
assertThat(information.isCustomMethod(customBaseRepositoryMethod)).isTrue();
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method ignoresCrudMethodsAnnotatedWithQuery.
// DATACMNS-364
@Test
public void ignoresCrudMethodsAnnotatedWithQuery() throws Exception {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(ConcreteRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, RepositoryComposition.empty());
Method method = BaseRepository.class.getMethod("findById", Object.class);
assertThat(information.getQueryMethods()).contains(method);
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method findsTargetSaveForIterableIfEntityImplementsIterable.
// DATACMNS-385
@Test
public void findsTargetSaveForIterableIfEntityImplementsIterable() throws Exception {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(BossRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, RepositoryComposition.empty());
Method method = BossRepository.class.getMethod("saveAll", Iterable.class);
Method reference = CrudRepository.class.getMethod("saveAll", Iterable.class);
assertThat(information.getTargetClassMethod(method)).isEqualTo(reference);
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method discoversCustomlyImplementedCrudMethodWithGenerics.
// DATACMNS-854
@Test
public void discoversCustomlyImplementedCrudMethodWithGenerics() throws SecurityException, NoSuchMethodException {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(FooRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, RepositoryComposition.just(customImplementation));
Method source = FooRepositoryCustom.class.getMethod("exists", Object.class);
Method expected = customImplementation.getClass().getMethod("exists", Object.class);
assertThat(information.getTargetClassMethod(source)).isEqualTo(expected);
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method discoversCustomlyImplementedCrudMethod.
@Test
public void discoversCustomlyImplementedCrudMethod() throws SecurityException, NoSuchMethodException {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(FooRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, RepositoryComposition.just(customImplementation));
Method source = FooRepositoryCustom.class.getMethod("save", User.class);
Method expected = customImplementation.getClass().getMethod("save", User.class);
assertThat(information.getTargetClassMethod(source)).isEqualTo(expected);
}
Aggregations