use of org.springframework.data.repository.core.RepositoryMetadata in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method considersIntermediateMethodsAsFinderMethods.
@Test
public void considersIntermediateMethodsAsFinderMethods() {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(ConcreteRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, RepositoryComposition.empty());
assertThat(information.hasCustomMethod()).isFalse();
}
use of org.springframework.data.repository.core.RepositoryMetadata in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method onlyReturnsMostConcreteQueryMethod.
@Test
public void onlyReturnsMostConcreteQueryMethod() throws Exception {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(ConcreteRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, RepositoryComposition.empty());
Method intermediateMethod = BaseRepository.class.getMethod("genericMethodToOverride", String.class);
Method concreteMethod = ConcreteRepository.class.getMethod("genericMethodToOverride", String.class);
Iterable<Method> queryMethods = information.getQueryMethods();
assertThat(queryMethods).contains(concreteMethod);
assertThat(queryMethods).doesNotContain(intermediateMethod);
}
use of org.springframework.data.repository.core.RepositoryMetadata in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method getQueryShouldNotReturnAnyBridgeMethods.
// DATACMNS-441
@Test
public void getQueryShouldNotReturnAnyBridgeMethods() {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(CustomDefaultRepositoryMethodsRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, RepositoryComposition.empty());
assertThat(information.getQueryMethods()).allMatch(method -> !method.isBridge());
}
use of org.springframework.data.repository.core.RepositoryMetadata in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method discoveresNonRepositoryBaseClassMethod.
@Test
public void discoveresNonRepositoryBaseClassMethod() throws Exception {
Method method = FooRepository.class.getMethod("findById", Long.class);
RepositoryMetadata metadata = new DefaultRepositoryMetadata(FooRepository.class);
DefaultRepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, RepositoryComposition.empty().withMethodLookup(MethodLookups.forRepositoryTypes(metadata)));
assertThat(information.getTargetClassMethod(method)).isEqualTo(method);
}
use of org.springframework.data.repository.core.RepositoryMetadata in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method doesNotConsiderRedeclaredSaveMethodAQueryMethod.
// DATACMNS-151
@Test
public void doesNotConsiderRedeclaredSaveMethodAQueryMethod() throws Exception {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(ConcreteRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, RepositoryComposition.empty());
Method saveMethod = BaseRepository.class.getMethod("save", Object.class);
Method deleteMethod = BaseRepository.class.getMethod("delete", Object.class);
Iterable<Method> queryMethods = information.getQueryMethods();
assertThat(queryMethods).doesNotContain(saveMethod, deleteMethod);
}
Aggregations