use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class RepositoryCompositionUnitTests method shouldCallMethodsInOrder.
// DATACMNS-102
@Test
public void shouldCallMethodsInOrder() throws Throwable {
RepositoryInformation repositoryInformation = new DefaultRepositoryInformation(new DefaultRepositoryMetadata(OrderedRepository.class), OrderedRepository.class, RepositoryComposition.empty());
RepositoryFragment<?> foo = RepositoryFragment.implemented(FooMixinImpl.INSTANCE);
RepositoryFragment<?> bar = RepositoryFragment.implemented(BarMixinImpl.INSTANCE);
RepositoryComposition fooBar = RepositoryComposition.of(RepositoryFragments.of(foo, bar)).withMethodLookup(MethodLookups.forRepositoryTypes(repositoryInformation));
RepositoryComposition barFoo = RepositoryComposition.of(RepositoryFragments.of(bar, foo)).withMethodLookup(MethodLookups.forRepositoryTypes(repositoryInformation));
Method getString = ReflectionUtils.findMethod(OrderedRepository.class, "getString");
assertThat(fooBar.invoke(fooBar.findMethod(getString).get())).isEqualTo("foo");
assertThat(barFoo.invoke(barFoo.findMethod(getString).get())).isEqualTo("bar");
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class RepositoryCompositionUnitTests method before.
@Before
@SuppressWarnings("rawtypes")
public void before() {
RepositoryInformation repositoryInformation = new DefaultRepositoryInformation(new DefaultRepositoryMetadata(PersonRepository.class), backingRepo.getClass(), RepositoryComposition.empty());
RepositoryFragment<QueryByExampleExecutor> mixin = RepositoryFragment.implemented(QueryByExampleExecutor.class, queryByExampleExecutor);
RepositoryFragment<PersonRepository> base = RepositoryFragment.implemented(backingRepo);
repositoryComposition = RepositoryComposition.of(RepositoryFragments.of(mixin, base)).withMethodLookup(MethodLookups.forRepositoryTypes(repositoryInformation));
}
use of org.springframework.data.repository.core.RepositoryInformation 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.RepositoryInformation 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.RepositoryInformation 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());
}
Aggregations