Search in sources :

Example 26 with RepositoryMetadata

use of org.springframework.data.repository.core.RepositoryMetadata in project spring-data-commons by spring-projects.

the class PaginginAndSortingRepositoryInvokerUnitTests method getInvokerFor.

@SuppressWarnings({ "unchecked", "rawtypes" })
private static RepositoryInvoker getInvokerFor(Object repository) {
    RepositoryMetadata metadata = new DefaultRepositoryMetadata(repository.getClass().getInterfaces()[0]);
    GenericConversionService conversionService = new DefaultFormattingConversionService();
    return new PagingAndSortingRepositoryInvoker((PagingAndSortingRepository) repository, metadata, conversionService);
}
Also used : DefaultRepositoryMetadata(org.springframework.data.repository.core.support.DefaultRepositoryMetadata) RepositoryMetadata(org.springframework.data.repository.core.RepositoryMetadata) DefaultRepositoryMetadata(org.springframework.data.repository.core.support.DefaultRepositoryMetadata) GenericConversionService(org.springframework.core.convert.support.GenericConversionService) DefaultFormattingConversionService(org.springframework.format.support.DefaultFormattingConversionService)

Example 27 with RepositoryMetadata

use of org.springframework.data.repository.core.RepositoryMetadata in project spring-data-commons by spring-projects.

the class RepositoriesUnitTests method discoversRepositoryForAlternativeDomainType.

// DATACMNS-673
@Test
public void discoversRepositoryForAlternativeDomainType() {
    RepositoryMetadata metadata = new CustomRepositoryMetadata(SampleRepository.class);
    RepositoryFactoryInformation<?, ?> information = new SampleRepoFactoryInformation<>(metadata);
    GenericApplicationContext context = new GenericApplicationContext();
    context.getBeanFactory().registerSingleton("foo", information);
    context.refresh();
    Repositories repositories = new Repositories(context);
    assertThat(repositories.getRepositoryFor(Sample.class)).isNotNull();
    assertThat(repositories.getRepositoryFor(SampleEntity.class)).isNotNull();
    context.close();
}
Also used : GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) DefaultRepositoryMetadata(org.springframework.data.repository.core.support.DefaultRepositoryMetadata) RepositoryMetadata(org.springframework.data.repository.core.RepositoryMetadata) Test(org.junit.Test)

Example 28 with RepositoryMetadata

use of org.springframework.data.repository.core.RepositoryMetadata in project spring-data-commons by spring-projects.

the class RepositoryConfigurationExtensionSupportUnitTests method considersRepositoryInterfaceExtendingStoreInterfaceStrictMatch.

// DATACMNS-526
@Test
public void considersRepositoryInterfaceExtendingStoreInterfaceStrictMatch() {
    RepositoryMetadata metadata = AbstractRepositoryMetadata.getMetadata(ExtendingInterface.class);
    assertThat(extension.isStrictRepositoryCandidate(metadata)).isTrue();
}
Also used : AbstractRepositoryMetadata(org.springframework.data.repository.core.support.AbstractRepositoryMetadata) RepositoryMetadata(org.springframework.data.repository.core.RepositoryMetadata) Test(org.junit.Test)

Example 29 with RepositoryMetadata

use of org.springframework.data.repository.core.RepositoryMetadata in project spring-data-commons by spring-projects.

the class QueryMethodUnitTests method doesNotRejectStreamingForPagination.

// DATACMNS-650
@Test
public void doesNotRejectStreamingForPagination() throws Exception {
    RepositoryMetadata repositoryMetadata = new DefaultRepositoryMetadata(SampleRepository.class);
    Method method = SampleRepository.class.getMethod("streaming", Pageable.class);
    assertThat(new QueryMethod(method, repositoryMetadata, factory).isStreamQuery()).isTrue();
}
Also used : DefaultRepositoryMetadata(org.springframework.data.repository.core.support.DefaultRepositoryMetadata) RepositoryMetadata(org.springframework.data.repository.core.RepositoryMetadata) DefaultRepositoryMetadata(org.springframework.data.repository.core.support.DefaultRepositoryMetadata) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 30 with RepositoryMetadata

use of org.springframework.data.repository.core.RepositoryMetadata in project spring-data-commons by spring-projects.

the class QueryMethodUnitTests method detectsSliceMethod.

// DATACMNS-397
@Test
public void detectsSliceMethod() throws Exception {
    RepositoryMetadata repositoryMetadata = new DefaultRepositoryMetadata(SampleRepository.class);
    Method method = SampleRepository.class.getMethod("sliceOfUsers");
    QueryMethod queryMethod = new QueryMethod(method, repositoryMetadata, factory);
    assertThat(queryMethod.isSliceQuery()).isTrue();
    assertThat(queryMethod.isCollectionQuery()).isFalse();
    assertThat(queryMethod.isPageQuery()).isFalse();
}
Also used : DefaultRepositoryMetadata(org.springframework.data.repository.core.support.DefaultRepositoryMetadata) RepositoryMetadata(org.springframework.data.repository.core.RepositoryMetadata) DefaultRepositoryMetadata(org.springframework.data.repository.core.support.DefaultRepositoryMetadata) Method(java.lang.reflect.Method) Test(org.junit.Test)

Aggregations

RepositoryMetadata (org.springframework.data.repository.core.RepositoryMetadata)60 Test (org.junit.Test)52 Method (java.lang.reflect.Method)37 RepositoryInformation (org.springframework.data.repository.core.RepositoryInformation)17 DefaultRepositoryMetadata (org.springframework.data.repository.core.support.DefaultRepositoryMetadata)16 AbstractRepositoryMetadata (org.springframework.data.repository.core.support.AbstractRepositoryMetadata)4 GenericConversionService (org.springframework.core.convert.support.GenericConversionService)3 ProjectionFactory (org.springframework.data.projection.ProjectionFactory)3 DefaultFormattingConversionService (org.springframework.format.support.DefaultFormattingConversionService)3 SpelAwareProxyProjectionFactory (org.springframework.data.projection.SpelAwareProxyProjectionFactory)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ProxyFactory (org.springframework.aop.framework.ProxyFactory)1 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)1 AbstractBeanDefinition (org.springframework.beans.factory.support.AbstractBeanDefinition)1 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)1 SpelQueryCreator (org.springframework.data.keyvalue.repository.query.SpelQueryCreator)1 DefaultMethodInvokingMethodInterceptor (org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor)1 ParametersParameterAccessor (org.springframework.data.repository.query.ParametersParameterAccessor)1 QueryMethod (org.springframework.data.repository.query.QueryMethod)1