1515 */
1616package org .springframework .data .jpa .repository .query ;
1717
18- import static org .assertj .core .api .Assertions .assertThat ;
18+ import static org .assertj .core .api .Assertions .* ;
1919import static org .mockito .ArgumentMatchers .*;
20- import static org .mockito .ArgumentMatchers .eq ;
2120import static org .mockito .Mockito .*;
2221import static org .springframework .data .jpa .support .EntityManagerTestUtils .*;
2322
24- import java .lang .reflect .Method ;
25- import java .util .List ;
26-
2723import jakarta .persistence .EntityManager ;
2824import jakarta .persistence .LockModeType ;
2925import jakarta .persistence .PersistenceContext ;
3026import jakarta .persistence .Query ;
3127import jakarta .persistence .QueryHint ;
3228import jakarta .persistence .TypedQuery ;
3329
30+ import java .lang .reflect .Method ;
31+ import java .util .List ;
32+
3433import org .junit .Assume ;
3534import org .junit .jupiter .api .BeforeEach ;
3635import org .junit .jupiter .api .Test ;
3736import org .junit .jupiter .api .extension .ExtendWith ;
3837import org .mockito .ArgumentCaptor ;
39-
4038import org .springframework .data .jpa .domain .sample .User ;
4139import org .springframework .data .jpa .provider .PersistenceProvider ;
4240import org .springframework .data .jpa .repository .EntityGraph ;
@@ -80,7 +78,6 @@ void setUp() {
8078 void addsHintsToQueryObject () throws Exception {
8179
8280 JpaQueryMethod queryMethod = getMethod ("findByLastname" , String .class );
83-
8481 AbstractJpaQuery jpaQuery = new DummyJpaQuery (queryMethod , em );
8582
8683 Query result = jpaQuery
@@ -113,8 +110,8 @@ void addsLockingModeToQueryObject() throws Exception {
113110 when (query .setLockMode (any (LockModeType .class ))).thenReturn (query );
114111
115112 JpaQueryMethod queryMethod = getMethod ("findOneLocked" , Integer .class );
116-
117113 AbstractJpaQuery jpaQuery = new DummyJpaQuery (queryMethod , em );
114+
118115 Query result = jpaQuery .createQuery (
119116 new JpaParametersParameterAccessor (queryMethod .getParameters (), new Object [] { Integer .valueOf (1 ) }));
120117 verify (result ).setLockMode (LockModeType .PESSIMISTIC_WRITE );
@@ -127,7 +124,6 @@ void shouldAddEntityGraphHintForFetch() throws Exception {
127124 Assume .assumeTrue (currentEntityManagerIsAJpa21EntityManager (em ));
128125
129126 JpaQueryMethod queryMethod = getMethod ("findAll" );
130-
131127 jakarta .persistence .EntityGraph <?> entityGraph = em .getEntityGraph ("User.overview" );
132128
133129 AbstractJpaQuery jpaQuery = new DummyJpaQuery (queryMethod , em );
@@ -143,7 +139,6 @@ void shouldAddEntityGraphHintForLoad() throws Exception {
143139 Assume .assumeTrue (currentEntityManagerIsAJpa21EntityManager (em ));
144140
145141 JpaQueryMethod queryMethod = getMethod ("getById" , Integer .class );
146-
147142 jakarta .persistence .EntityGraph <?> entityGraph = em .getEntityGraph ("User.detail" );
148143
149144 AbstractJpaQuery jpaQuery = new DummyJpaQuery (queryMethod , em );
@@ -157,12 +152,12 @@ void shouldAddEntityGraphHintForLoad() throws Exception {
157152 void shouldCreateHibernateJpaParameterParametersAccessorForNativeQuery () throws Exception {
158153
159154 JpaQueryMethod queryMethod = getMethod ("findByLastnameNativeQuery" , String .class );
160-
161155 AbstractJpaQuery jpaQuery = new DummyJpaQuery (queryMethod , em );
162156
163- jpaQuery .execute (new Object [] {"some last name" });
157+ jpaQuery .execute (new Object [] { "some last name" });
164158
165- ArgumentCaptor <JpaParametersParameterAccessor > captor = ArgumentCaptor .forClass (JpaParametersParameterAccessor .class );
159+ ArgumentCaptor <JpaParametersParameterAccessor > captor = ArgumentCaptor
160+ .forClass (JpaParametersParameterAccessor .class );
166161 verify (execution ).execute (eq (jpaQuery ), captor .capture ());
167162 JpaParametersParameterAccessor parameterAccessor = captor .getValue ();
168163
@@ -175,9 +170,10 @@ void shouldCreateGenericJpaParameterParametersAccessorForNonNativeQuery() throws
175170 JpaQueryMethod queryMethod = getMethod ("findByFirstname" , String .class );
176171 AbstractJpaQuery jpaQuery = new DummyJpaQuery (queryMethod , em );
177172
178- jpaQuery .execute (new Object [] {"some first name" });
173+ jpaQuery .execute (new Object [] { "some first name" });
179174
180- ArgumentCaptor <JpaParametersParameterAccessor > captor = ArgumentCaptor .forClass (JpaParametersParameterAccessor .class );
175+ ArgumentCaptor <JpaParametersParameterAccessor > captor = ArgumentCaptor
176+ .forClass (JpaParametersParameterAccessor .class );
181177 verify (execution ).execute (eq (jpaQuery ), captor .capture ());
182178 JpaParametersParameterAccessor parameterAccessor = captor .getValue ();
183179
@@ -198,7 +194,8 @@ interface SampleRepository extends Repository<User, Integer> {
198194 @ QueryHints ({ @ QueryHint (name = "foo" , value = "bar" ) })
199195 List <User > findByLastname (String lastname );
200196
201- @ org .springframework .data .jpa .repository .Query (value = "select u from User u where u.lastname = ?1" , nativeQuery = true )
197+ @ org .springframework .data .jpa .repository .Query (value = "select u from User u where u.lastname = ?1" ,
198+ nativeQuery = true )
202199 List <User > findByLastnameNativeQuery (String lastname );
203200
204201 @ QueryHints (value = { @ QueryHint (name = "bar" , value = "foo" ) }, forCounting = false )
0 commit comments