Search in sources :

Example 1 with RepositoryFactorySupport

use of org.springframework.data.repository.core.support.RepositoryFactorySupport in project spring-boot by spring-projects.

the class MetricsRepositoryMethodInvocationListenerBeanPostProcessorTests method postProcessBeforeInitializationWhenRepositoryFactoryBeanSupportAddsListener.

@Test
@SuppressWarnings("rawtypes")
void postProcessBeforeInitializationWhenRepositoryFactoryBeanSupportAddsListener() {
    RepositoryFactoryBeanSupport bean = mock(RepositoryFactoryBeanSupport.class);
    Object result = this.postProcessor.postProcessBeforeInitialization(bean, "name");
    assertThat(result).isSameAs(bean);
    ArgumentCaptor<RepositoryFactoryCustomizer> customizer = ArgumentCaptor.forClass(RepositoryFactoryCustomizer.class);
    then(bean).should().addRepositoryFactoryCustomizer(customizer.capture());
    RepositoryFactorySupport repositoryFactory = mock(RepositoryFactorySupport.class);
    customizer.getValue().customize(repositoryFactory);
    then(repositoryFactory).should().addInvocationListener(this.listener);
}
Also used : RepositoryFactoryBeanSupport(org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport) RepositoryFactorySupport(org.springframework.data.repository.core.support.RepositoryFactorySupport) RepositoryFactoryCustomizer(org.springframework.data.repository.core.support.RepositoryFactoryCustomizer) Test(org.junit.jupiter.api.Test)

Example 2 with RepositoryFactorySupport

use of org.springframework.data.repository.core.support.RepositoryFactorySupport in project spring-data-mongodb by spring-projects.

the class MongoRepositoryFactoryBeanUnitTests method getListenersFromFactory.

@SuppressWarnings({ "unchecked", "rawtypes" })
private List<Object> getListenersFromFactory(MongoRepositoryFactoryBean factoryBean) {
    when(operations.getConverter()).thenReturn(converter);
    when(converter.getMappingContext()).thenReturn(context);
    factoryBean.setLazyInit(true);
    factoryBean.setMongoOperations(operations);
    factoryBean.afterPropertiesSet();
    RepositoryFactorySupport factory = factoryBean.createRepositoryFactory();
    return (List<Object>) ReflectionTestUtils.getField(factory, "queryPostProcessors");
}
Also used : RepositoryFactorySupport(org.springframework.data.repository.core.support.RepositoryFactorySupport) List(java.util.List)

Example 3 with RepositoryFactorySupport

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

the class CdiRepositoryBean method create.

/**
 * Creates the actual component instance given a {@link RepositoryFactorySupport repository factory supplier} and the
 * repository {@link Class type}. This method is an utility for to create a repository. This method will obtain a
 * {@link RepositoryFactorySupport repository factory} and configure it with {@link CdiRepositoryConfiguration}.
 *
 * @param factorySupplier must not be {@literal null}.
 * @param repositoryType must not be {@literal null}.
 * @return
 * @since 2.1
 */
protected T create(Supplier<? extends RepositoryFactorySupport> factorySupplier, Class<T> repositoryType) {
    CdiRepositoryConfiguration configuration = lookupConfiguration(beanManager, qualifiers);
    RepositoryFragments repositoryFragments = getRepositoryFragments(repositoryType, configuration);
    RepositoryFactorySupport factory = factorySupplier.get();
    applyConfiguration(factory, configuration);
    return create(factory, repositoryType, repositoryFragments);
}
Also used : RepositoryFragments(org.springframework.data.repository.core.support.RepositoryComposition.RepositoryFragments) RepositoryFactorySupport(org.springframework.data.repository.core.support.RepositoryFactorySupport)

Example 4 with RepositoryFactorySupport

use of org.springframework.data.repository.core.support.RepositoryFactorySupport in project spring-cloud-gcp by spring-cloud.

the class SpannerRepositoryFactoryBeanTests method createRepositoryFactoryTest.

@Test
public void createRepositoryFactoryTest() {
    RepositoryFactorySupport factory = this.spannerRepositoryFactoryBean.createRepositoryFactory();
    assertThat(factory).isInstanceOf(SpannerRepositoryFactory.class);
}
Also used : RepositoryFactorySupport(org.springframework.data.repository.core.support.RepositoryFactorySupport) Test(org.junit.Test)

Example 5 with RepositoryFactorySupport

use of org.springframework.data.repository.core.support.RepositoryFactorySupport in project spring-cloud-gcp by spring-cloud.

the class DatastoreRepositoryFactoryBeanTests method createRepositoryFactoryTest.

@Test
public void createRepositoryFactoryTest() {
    RepositoryFactorySupport factory = this.datastoreRepositoryFactoryBean.createRepositoryFactory();
    assertThat(factory.getClass()).isEqualTo(DatastoreRepositoryFactory.class);
}
Also used : RepositoryFactorySupport(org.springframework.data.repository.core.support.RepositoryFactorySupport) Test(org.junit.Test)

Aggregations

RepositoryFactorySupport (org.springframework.data.repository.core.support.RepositoryFactorySupport)5 Test (org.junit.Test)2 List (java.util.List)1 Test (org.junit.jupiter.api.Test)1 RepositoryFragments (org.springframework.data.repository.core.support.RepositoryComposition.RepositoryFragments)1 RepositoryFactoryBeanSupport (org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport)1 RepositoryFactoryCustomizer (org.springframework.data.repository.core.support.RepositoryFactoryCustomizer)1