15
15
import org .springframework .transaction .TransactionStatus ;
16
16
import org .springframework .transaction .support .DefaultTransactionDefinition ;
17
17
18
+ /**
19
+ * Unit tests for {@link HibernateJpaParametersParameterAccessor}.
20
+ *
21
+ * @author Cedomir Igaly
22
+ */
18
23
@ ExtendWith (SpringExtension .class )
19
24
@ ContextConfiguration ("classpath:hjppa-test.xml" )
20
25
public class HibernateJpaParametersParameterAccessorUnitTests {
@@ -25,23 +30,25 @@ public class HibernateJpaParametersParameterAccessorUnitTests {
25
30
26
31
@ Test
27
32
void withoutTransaction () throws NoSuchMethodException {
28
- simpleTest ();
33
+ parametersCanGetAccessesOutsideTransaction ();
29
34
}
30
35
31
36
@ Test
32
37
void withinTransaction () throws Exception {
33
- final TransactionStatus tx = transactionManager .getTransaction (new DefaultTransactionDefinition ());
38
+
39
+ TransactionStatus tx = transactionManager .getTransaction (new DefaultTransactionDefinition ());
34
40
try {
35
- simpleTest ();
41
+ parametersCanGetAccessesOutsideTransaction ();
36
42
} finally {
37
43
transactionManager .rollback (tx );
38
44
}
39
45
}
40
46
41
- private void simpleTest () throws NoSuchMethodException {
42
- final Method method = EntityManager .class .getMethod ("flush" );
43
- final JpaParameters parameters = new JpaParameters (method );
44
- final HibernateJpaParametersParameterAccessor accessor = new HibernateJpaParametersParameterAccessor (parameters ,
47
+ private void parametersCanGetAccessesOutsideTransaction () throws NoSuchMethodException {
48
+
49
+ Method method = EntityManager .class .getMethod ("flush" );
50
+ JpaParameters parameters = new JpaParameters (method );
51
+ HibernateJpaParametersParameterAccessor accessor = new HibernateJpaParametersParameterAccessor (parameters ,
45
52
new Object [] {}, em );
46
53
Assertions .assertEquals (0 , accessor .getValues ().length );
47
54
Assertions .assertEquals (parameters , accessor .getParameters ());
0 commit comments