Search in sources :

Example 6 with RepositoryMetadata

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

the class DefaultRepositoryMetadataUnitTests method detectsParameterizedEntitiesCorrectly.

@Test
public void detectsParameterizedEntitiesCorrectly() {
    RepositoryMetadata metadata = new DefaultRepositoryMetadata(GenericEntityRepository.class);
    assertThat(metadata.getDomainType()).isEqualTo(GenericEntity.class);
}
Also used : RepositoryMetadata(org.springframework.data.repository.core.RepositoryMetadata) Test(org.junit.Test)

Example 7 with RepositoryMetadata

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

the class DefaultRepositoryMetadataUnitTests method discoversDomainTypeOnNestedReturnTypeWrapper.

// DATACMNS-483
@Test
public void discoversDomainTypeOnNestedReturnTypeWrapper() throws Exception {
    RepositoryMetadata metadata = new DefaultRepositoryMetadata(OptionalRepository.class);
    Method method = OptionalRepository.class.getMethod("findByLastname", String.class);
    assertThat(metadata.getReturnedDomainClass(method)).isEqualTo(User.class);
}
Also used : RepositoryMetadata(org.springframework.data.repository.core.RepositoryMetadata) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 8 with RepositoryMetadata

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

the class ReactiveRepositoryInformationUnitTests method extractTargetMethodFromRepository.

private Method extractTargetMethodFromRepository(Class<?> repositoryType, String methodName, Class<?>... args) throws NoSuchMethodException {
    RepositoryMetadata metadata = new DefaultRepositoryMetadata(repositoryType);
    RepositoryComposition composition = RepositoryComposition.of(RepositoryFragment.structural(BASE_CLASS)).withMethodLookup(MethodLookups.forReactiveTypes(metadata));
    return composition.findMethod(repositoryType.getMethod(methodName, args)).get();
}
Also used : RepositoryMetadata(org.springframework.data.repository.core.RepositoryMetadata)

Example 9 with RepositoryMetadata

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

the class RepositoryConfigurationExtensionSupportUnitTests method doesNotConsiderRepositoryForPlainTypeStrictMatch.

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

Example 10 with RepositoryMetadata

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

the class RepositoryConfigurationExtensionSupportUnitTests method considersRepositoryWithAnnotatedTypeStrictMatch.

// DATACMNS-526
@Test
public void considersRepositoryWithAnnotatedTypeStrictMatch() {
    RepositoryMetadata metadata = AbstractRepositoryMetadata.getMetadata(AnnotatedTypeRepository.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)

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