DATACMNS-1158 - ProjectionFactory is now configurable by module implementations.

Introduced RepositoryFactorySupport.getProjectionFactory(…) to create a ProjectionFactory to be used for repository instances created. The default implementation uses the SpelAwareProxyProjectionFactory.

The ProjectionInformation implementation is now a named class so it can be used for more specialized implementations.

Original pull request: #243.
Related issue: DATAJPA-1173.
This commit is contained in:
Jens Schauder
2017-09-15 06:45:22 +02:00
committed by Oliver Gierke
parent 0237760345
commit 300f3cfd66
3 changed files with 65 additions and 38 deletions

View File

@@ -23,6 +23,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
import org.springframework.data.repository.core.RepositoryInformation;
import org.springframework.data.repository.query.QueryLookupStrategy;
import org.springframework.data.util.Streamable;
@@ -32,6 +33,7 @@ import org.springframework.data.util.Streamable;
*
* @author Oliver Gierke
* @author Mark Paluch
* @author Jens Schauder
*/
@RunWith(MockitoJUnitRunner.class)
public class QueryExecutorMethodInterceptorUnitTests {
@@ -46,7 +48,7 @@ public class QueryExecutorMethodInterceptorUnitTests {
when(information.hasQueryMethods()).thenReturn(true);
when(factory.getQueryLookupStrategy(any(), any())).thenReturn(Optional.empty());
factory.new QueryExecutorMethodInterceptor(information);
factory.new QueryExecutorMethodInterceptor(information, new SpelAwareProxyProjectionFactory());
}
@Test
@@ -55,7 +57,7 @@ public class QueryExecutorMethodInterceptorUnitTests {
when(information.getQueryMethods()).thenReturn(Streamable.empty());
when(factory.getQueryLookupStrategy(any(), any())).thenReturn(Optional.of(strategy));
factory.new QueryExecutorMethodInterceptor(information);
factory.new QueryExecutorMethodInterceptor(information, new SpelAwareProxyProjectionFactory());
verify(strategy, times(0)).resolveQuery(any(), any(), any(), any());
}