Search in sources :

Example 1 with CustomRepositoryImplementationDetector

use of org.springframework.data.repository.config.CustomRepositoryImplementationDetector in project spring-data-commons by spring-projects.

the class CdiRepositoryBeanUnitTests method passesCorrectBeanNameToTheImplementationDetector.

// DATACMNS-764
@Test
public void passesCorrectBeanNameToTheImplementationDetector() {
    CustomRepositoryImplementationDetector detector = mock(CustomRepositoryImplementationDetector.class);
    CdiRepositoryBean<SampleRepository> bean = new // 
    CdiRepositoryBean<SampleRepository>(// 
    SINGLE_ANNOTATION, // 
    SampleRepository.class, // 
    beanManager, // 
    Optional.of(detector)) {

        @Override
        protected // 
        SampleRepository create(// 
        CreationalContext<SampleRepository> creationalContext, // 
        Class<SampleRepository> repositoryType, // 
        Optional<Object> customImplementation) {
            return null;
        }
    };
    bean.create(mock(CreationalContext.class), SampleRepository.class);
    // 
    verify(detector).detectCustomImplementation(// 
    eq("CdiRepositoryBeanUnitTests.SampleRepositoryImpl"), // 
    eq("CdiRepositoryBeanUnitTests.SampleRepositoryImpl"), // 
    anySet(), // 
    anySet(), // 
    Mockito.any(Function.class));
}
Also used : CreationalContext(javax.enterprise.context.spi.CreationalContext) Function(java.util.function.Function) Optional(java.util.Optional) CustomRepositoryImplementationDetector(org.springframework.data.repository.config.CustomRepositoryImplementationDetector) Test(org.junit.Test)

Aggregations

Optional (java.util.Optional)1 Function (java.util.function.Function)1 CreationalContext (javax.enterprise.context.spi.CreationalContext)1 Test (org.junit.Test)1 CustomRepositoryImplementationDetector (org.springframework.data.repository.config.CustomRepositoryImplementationDetector)1