Search in sources :

Example 36 with RepositoryMetadata

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

the class AnnotationRepositoryMetadataUnitTests method handlesRepositoryProxyAnnotationCorrectly.

@Test
public void handlesRepositoryProxyAnnotationCorrectly() {
    RepositoryMetadata metadata = new AnnotationRepositoryMetadata(AnnotatedRepository.class);
    assertThat(metadata.getDomainType()).isEqualTo(User.class);
    assertThat(metadata.getIdType()).isEqualTo(Integer.class);
}
Also used : RepositoryMetadata(org.springframework.data.repository.core.RepositoryMetadata) Test(org.junit.Test)

Example 37 with RepositoryMetadata

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

the class DefaultCrudMethodsUnitTests method getMethodsFor.

private static CrudMethods getMethodsFor(Class<?> repositoryInterface) {
    RepositoryMetadata metadata = new DefaultRepositoryMetadata(repositoryInterface);
    RepositoryInformation information = new DefaultRepositoryInformation(metadata, PagingAndSortingRepository.class, RepositoryComposition.empty());
    return new DefaultCrudMethods(information);
}
Also used : RepositoryMetadata(org.springframework.data.repository.core.RepositoryMetadata) RepositoryInformation(org.springframework.data.repository.core.RepositoryInformation)

Example 38 with RepositoryMetadata

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

the class DefaultRepositoryInformationUnitTests method usesCorrectSaveOverload.

// DATACMNS-943
@Test
public void usesCorrectSaveOverload() throws Exception {
    RepositoryMetadata metadata = new DefaultRepositoryMetadata(DummyRepository.class);
    RepositoryInformation information = new DefaultRepositoryInformation(metadata, DummyRepositoryImpl.class, RepositoryComposition.empty());
    Method method = DummyRepository.class.getMethod("saveAll", Iterable.class);
    assertThat(information.getTargetClassMethod(method)).isEqualTo(DummyRepositoryImpl.class.getMethod("saveAll", Iterable.class));
}
Also used : RepositoryMetadata(org.springframework.data.repository.core.RepositoryMetadata) Method(java.lang.reflect.Method) RepositoryInformation(org.springframework.data.repository.core.RepositoryInformation) Test(org.junit.Test)

Example 39 with RepositoryMetadata

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

the class DefaultRepositoryInformationUnitTests method ignoresStaticMethod.

// DATACMNS-939
@Test
public void ignoresStaticMethod() throws SecurityException, NoSuchMethodException {
    RepositoryMetadata metadata = new DefaultRepositoryMetadata(FooRepository.class);
    RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, RepositoryComposition.just(customImplementation));
    Method method = FooRepository.class.getMethod("staticMethod");
    assertThat(information.getQueryMethods()).doesNotContain(method);
}
Also used : RepositoryMetadata(org.springframework.data.repository.core.RepositoryMetadata) Method(java.lang.reflect.Method) RepositoryInformation(org.springframework.data.repository.core.RepositoryInformation) Test(org.junit.Test)

Example 40 with RepositoryMetadata

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

the class DefaultRepositoryInformationUnitTests method discoversCustomlyImplementedCrudMethodWithGenericParameters.

// DATACMNS-912
@Test
public void discoversCustomlyImplementedCrudMethodWithGenericParameters() throws Exception {
    GenericsSaveRepositoryImpl customImplementation = new GenericsSaveRepositoryImpl();
    RepositoryMetadata metadata = new DefaultRepositoryMetadata(GenericsSaveRepository.class);
    RepositoryInformation information = new DefaultRepositoryInformation(metadata, RepositoryFactorySupport.class, RepositoryComposition.just(customImplementation).withMethodLookup(MethodLookups.forRepositoryTypes(metadata)));
    Method customBaseRepositoryMethod = GenericsSaveRepository.class.getMethod("save", Object.class);
    assertThat(information.isCustomMethod(customBaseRepositoryMethod)).isTrue();
}
Also used : RepositoryMetadata(org.springframework.data.repository.core.RepositoryMetadata) Method(java.lang.reflect.Method) RepositoryInformation(org.springframework.data.repository.core.RepositoryInformation) 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