DATAJPA-1163 - Polishing.

Reduced visibility of newly introduced method.
Moved method for test into inner class of the test

Original pull request: #283.
This commit is contained in:
Jens Schauder
2018-07-19 14:36:07 +02:00
parent 6513385812
commit e51024e20a
3 changed files with 9 additions and 7 deletions

View File

@@ -68,7 +68,7 @@ class ExpressionBasedStringQuery extends StringQuery {
* @param parser Parser for resolving SpEL expressions. Must not be {@literal null}.
* @return A query supporting SpEL expressions.
*/
public static ExpressionBasedStringQuery from(DeclaredQuery query, JpaEntityMetadata metadata,
static ExpressionBasedStringQuery from(DeclaredQuery query, JpaEntityMetadata metadata,
SpelExpressionParser parser) {
return new ExpressionBasedStringQuery(query.getQueryString(), metadata, parser);
}

View File

@@ -16,7 +16,9 @@
package org.springframework.data.jpa.repository.query;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import java.lang.reflect.Method;
@@ -235,7 +237,7 @@ public class SimpleJpaQueryUnitTests {
when(em.createQuery(Mockito.anyString())).thenReturn(query);
Method method = UserRepository.class.getMethod("findAllWithExpressionInCountQuery", Pageable.class);
Method method = SampleRepository.class.getMethod("findAllWithExpressionInCountQuery", Pageable.class);
JpaQueryMethod queryMethod = new JpaQueryMethod(method, metadata, factory, extractor);
AbstractJpaQuery jpaQuery = new SimpleJpaQuery(queryMethod, em, "select u from User u", EVALUATION_CONTEXT_PROVIDER,
@@ -277,6 +279,10 @@ public class SimpleJpaQueryUnitTests {
@Query("select u from User u")
Collection<UserProjection> projectWithExplicitQuery();
@Query(value = "select u from #{#entityName} u", countQuery = "select count(u.id) from #{#entityName} u")
List<User> findAllWithExpressionInCountQuery(Pageable pageable);
}
interface UserProjection {}

View File

@@ -556,10 +556,6 @@ public interface UserRepository
// DATAJPA-1334
List<NameOnlyDto> findByNamedQueryWithConstructorExpression();
// DATAJPA-1163
@Query(value = "select u from #{#entityName} u", countQuery = "select count(u.id) from #{#entityName} u")
List<User> findAllWithExpressionInCountQuery(Pageable pageable);
interface RolesAndFirstname {
String getFirstname();