use of org.springframework.data.repository.core.RepositoryMetadata 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.RepositoryMetadata 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.RepositoryMetadata 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.RepositoryMetadata 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);
}
use of org.springframework.data.repository.core.RepositoryMetadata in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method doesNotConsiderManuallyDefinedSaveMethodAQueryMethod.
// DATACMNS-151
@Test
public void doesNotConsiderManuallyDefinedSaveMethodAQueryMethod() {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(CustomRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, PagingAndSortingRepository.class, RepositoryComposition.empty());
assertThat(information.getQueryMethods()).isEmpty();
}
Aggregations