3333import org .junit .jupiter .api .BeforeEach ;
3434import org .junit .jupiter .api .Test ;
3535import org .mockito .ArgumentCaptor ;
36-
3736import org .springframework .beans .factory .BeanFactory ;
3837import org .springframework .core .convert .converter .Converter ;
3938import org .springframework .dao .DataAccessException ;
@@ -330,14 +329,13 @@ void appliesConverterToIterable() {
330329 @ Test // GH-1323
331330 void queryByListOfTuples () {
332331
333- String [][] tuples = {new String []{ "Albert" , "Einstein" }, new String []{ "Richard" , "Feynman" } };
332+ String [][] tuples = { new String [] { "Albert" , "Einstein" }, new String [] { "Richard" , "Feynman" } };
334333
335334 SqlParameterSource parameterSource = forMethod ("findByListOfTuples" , List .class ) //
336- .withArguments (Arrays .asList (tuples ))
335+ .withArguments (Arrays .asList (tuples )) //
337336 .extractParameterSource ();
338337
339- assertThat (parameterSource .getValue ("tuples" ))
340- .asInstanceOf (LIST )
338+ assertThat (parameterSource .getValue ("tuples" )).asInstanceOf (LIST ) //
341339 .containsExactly (tuples );
342340
343341 assertThat (parameterSource .getSqlType ("tuples" )).isEqualTo (JdbcUtil .TYPE_UNKNOWN .getVendorTypeNumber ());
@@ -348,12 +346,38 @@ void queryByListOfConvertableTuples() {
348346
349347 SqlParameterSource parameterSource = forMethod ("findByListOfTuples" , List .class ) //
350348 .withCustomConverters (DirectionToIntegerConverter .INSTANCE ) //
351- .withArguments (Arrays .asList (new Object []{Direction .LEFT , "Einstein" }, new Object []{Direction .RIGHT , "Feynman" }))
349+ .withArguments (
350+ Arrays .asList (new Object [] { Direction .LEFT , "Einstein" }, new Object [] { Direction .RIGHT , "Feynman" }))
352351 .extractParameterSource ();
353352
354- assertThat (parameterSource .getValue ("tuples" ))
355- .asInstanceOf (LIST )
356- .containsExactly (new Object [][]{new Object []{-1 , "Einstein" }, new Object []{1 , "Feynman" }});
353+ assertThat (parameterSource .getValue ("tuples" )).asInstanceOf (LIST ) //
354+ .containsExactly (new Object [][] { new Object [] { -1 , "Einstein" }, new Object [] { 1 , "Feynman" } });
355+ }
356+
357+ @ Test // GH-619
358+ void spelCanBeUsedInsideQueries () {
359+
360+ JdbcQueryMethod queryMethod = createMethod ("findBySpelExpression" , Object .class );
361+
362+ List <EvaluationContextExtension > list = new ArrayList <>();
363+ list .add (new MyEvaluationContextProvider ());
364+ QueryMethodEvaluationContextProvider evaluationContextProviderImpl = new ExtensionAwareQueryMethodEvaluationContextProvider (
365+ list );
366+
367+ StringBasedJdbcQuery sut = new StringBasedJdbcQuery (queryMethod , operations , defaultRowMapper , converter ,
368+ evaluationContextProviderImpl );
369+
370+ ArgumentCaptor <SqlParameterSource > paramSource = ArgumentCaptor .forClass (SqlParameterSource .class );
371+ ArgumentCaptor <String > query = ArgumentCaptor .forClass (String .class );
372+
373+ sut .execute (new Object [] { "myValue" });
374+
375+ verify (this .operations ).queryForObject (query .capture (), paramSource .capture (), any (RowMapper .class ));
376+
377+ assertThat (query .getValue ())
378+ .isEqualTo ("SELECT * FROM table WHERE c = :__$synthetic$__1 AND c2 = :__$synthetic$__2" );
379+ assertThat (paramSource .getValue ().getValue ("__$synthetic$__1" )).isEqualTo ("test-value1" );
380+ assertThat (paramSource .getValue ().getValue ("__$synthetic$__2" )).isEqualTo ("test-value2" );
357381 }
358382
359383 QueryFixture forMethod (String name , Class ... paramTypes ) {
@@ -486,32 +510,6 @@ interface MyRepository extends Repository<Object, Long> {
486510 Object findByListOfTuples (@ Param ("tuples" ) List <Object []> tuples );
487511 }
488512
489- @ Test // GH-619
490- public void spelCanBeUsedInsideQueries () {
491-
492- JdbcQueryMethod queryMethod = createMethod ("findBySpelExpression" , Object .class );
493-
494- List <EvaluationContextExtension > list = new ArrayList <>();
495- list .add (new MyEvaluationContextProvider ());
496- QueryMethodEvaluationContextProvider evaluationContextProviderImpl = new ExtensionAwareQueryMethodEvaluationContextProvider (
497- list );
498-
499- StringBasedJdbcQuery sut = new StringBasedJdbcQuery (queryMethod , operations , defaultRowMapper , converter ,
500- evaluationContextProviderImpl );
501-
502- ArgumentCaptor <SqlParameterSource > paramSource = ArgumentCaptor .forClass (SqlParameterSource .class );
503- ArgumentCaptor <String > query = ArgumentCaptor .forClass (String .class );
504-
505- sut .execute (new Object [] { "myValue" });
506-
507- verify (this .operations ).queryForObject (query .capture (), paramSource .capture (), any (RowMapper .class ));
508-
509- assertThat (query .getValue ())
510- .isEqualTo ("SELECT * FROM table WHERE c = :__$synthetic$__1 AND c2 = :__$synthetic$__2" );
511- assertThat (paramSource .getValue ().getValue ("__$synthetic$__1" )).isEqualTo ("test-value1" );
512- assertThat (paramSource .getValue ().getValue ("__$synthetic$__2" )).isEqualTo ("test-value2" );
513- }
514-
515513 private static class CustomRowMapper implements RowMapper <Object > {
516514
517515 @ Override
0 commit comments