use of org.springframework.data.repository.core.RepositoryInformation 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();
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method ignoresDefaultMethod.
// DATACMNS-939
@Test
public void ignoresDefaultMethod() throws SecurityException, NoSuchMethodException {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(FooRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, RepositoryComposition.just(customImplementation));
Method method = FooRepository.class.getMethod("defaultMethod");
assertThat(information.getQueryMethods()).doesNotContain(method);
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class EventPublishingRepositoryProxyPostProcessorUnitTests method registersAdviceIfDomainTypeExposesEvents.
// DATACMNS-928
@Test
public void registersAdviceIfDomainTypeExposesEvents() {
RepositoryInformation information = new DummyRepositoryInformation(SampleRepository.class);
RepositoryProxyPostProcessor processor = new EventPublishingRepositoryProxyPostProcessor(publisher);
ProxyFactory factory = mock(ProxyFactory.class);
processor.postProcess(factory, information);
verify(factory).addAdvice(any(EventPublishingMethodInterceptor.class));
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class RepositoryFactoryBeanSupportUnitTests method returnsRepositoryInformationForFragmentSetup.
// DATACMNS-1117
@Test
public void returnsRepositoryInformationForFragmentSetup() {
//
RepositoryFactoryBeanSupport<SampleWithQuerydslRepository, Object, Long> factoryBean = new DummyRepositoryFactoryBean<>(SampleWithQuerydslRepository.class);
factoryBean.afterPropertiesSet();
RepositoryInformation information = factoryBean.getRepositoryInformation();
assertThat(information.getQueryMethods()).isEmpty();
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class RepositoryFactorySupport method getRepository.
/**
* Returns a repository instance for the given interface backed by an instance providing implementation logic for
* custom logic.
*
* @param repositoryInterface must not be {@literal null}.
* @param fragments must not be {@literal null}.
* @return
* @since 2.0
*/
@SuppressWarnings({ "unchecked" })
public <T> T getRepository(Class<T> repositoryInterface, RepositoryFragments fragments) {
Assert.notNull(repositoryInterface, "Repository interface must not be null!");
Assert.notNull(fragments, "RepositoryFragments must not be null!");
RepositoryMetadata metadata = getRepositoryMetadata(repositoryInterface);
RepositoryComposition composition = getRepositoryComposition(metadata, fragments);
RepositoryInformation information = getRepositoryInformation(metadata, composition);
validate(information, composition);
Object target = getTargetRepository(information);
// Create proxy
ProxyFactory result = new ProxyFactory();
result.setTarget(target);
result.setInterfaces(repositoryInterface, Repository.class, TransactionalProxy.class);
if (MethodInvocationValidator.supports(repositoryInterface)) {
result.addAdvice(new MethodInvocationValidator());
}
result.addAdvice(SurroundingTransactionDetectorMethodInterceptor.INSTANCE);
result.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
postProcessors.forEach(processor -> processor.postProcess(result, information));
result.addAdvice(new DefaultMethodInvokingMethodInterceptor());
ProjectionFactory projectionFactory = getProjectionFactory(classLoader, beanFactory);
result.addAdvice(new QueryExecutorMethodInterceptor(information, projectionFactory));
composition = composition.append(RepositoryFragment.implemented(target));
result.addAdvice(new ImplementationMethodExecutionInterceptor(composition));
return (T) result.getProxy(classLoader);
}
Aggregations