@@ -192,7 +192,7 @@ void doesNotValidateCountQueryIfNotPagingMethod() throws Exception {
192192 createJpaQuery (method );
193193 }
194194
195- @ Test // DATAJPA-352
195+ @ Test // DATAJPA-352, GH-2736
196196 void validatesAndRejectsCountQueryIfPagingMethod () throws Exception {
197197
198198 Method method = SampleRepository .class .getMethod ("pageByAnnotatedQuery" , Pageable .class );
@@ -201,7 +201,7 @@ void validatesAndRejectsCountQueryIfPagingMethod() throws Exception {
201201
202202 assertThatIllegalArgumentException () //
203203 .isThrownBy (() -> createJpaQuery (method )) //
204- .withMessageContaining ("Count " ) //
204+ .withMessageContaining ("User u " ) //
205205 .withMessageContaining (method .getName ());
206206 }
207207
@@ -356,21 +356,21 @@ void resolvesExpressionInCountQuery() throws Exception {
356356 }
357357
358358 private AbstractJpaQuery createJpaQuery (Method method ) {
359- return createJpaQuery (method , null );
359+ return createJpaQuery (method , Optional . empty () );
360360 }
361361
362- private AbstractJpaQuery createJpaQuery (JpaQueryMethod queryMethod , @ Nullable String queryString ,
362+ private AbstractJpaQuery createJpaQuery (JpaQueryMethod queryMethod , String queryString ,
363363 @ Nullable String countQueryString ) {
364364
365365 return JpaQueryFactory .INSTANCE .fromMethodWithQueryString (queryMethod , em , queryString , countQueryString ,
366366 QueryRewriter .IdentityQueryRewriter .INSTANCE , ValueExpressionDelegate .create ());
367367 }
368368
369- private AbstractJpaQuery createJpaQuery (Method method , @ Nullable Optional <String > countQueryString ) {
369+ private AbstractJpaQuery createJpaQuery (Method method , Optional <String > countQueryString ) {
370370
371371 JpaQueryMethod queryMethod = new JpaQueryMethod (method , metadata , factory , extractor );
372372 return createJpaQuery (queryMethod , queryMethod .getAnnotatedQuery (),
373- countQueryString == null ? null : countQueryString .orElse (queryMethod .getCountQuery ()));
373+ countQueryString .orElse (queryMethod .getCountQuery ()));
374374 }
375375
376376 private String createQuery (AbstractStringBasedJpaQuery jpaQuery ) {
0 commit comments