1717import org .mockito .Mock ;
1818import org .mockito .junit .MockitoJUnitRunner ;
1919import org .springframework .lang .Nullable ;
20+ import org .springframework .test .util .ReflectionTestUtils ;
2021import org .springframework .transaction .*;
2122import org .springframework .transaction .interceptor .DefaultTransactionAttribute ;
2223import org .springframework .transaction .support .DefaultTransactionStatus ;
@@ -49,7 +50,6 @@ public class ArangoTransactionManagerTest {
4950 private ArangoTransactionManager underTest ;
5051 @ Mock
5152 private ArangoDatabase database ;
52- @ Mock
5353 private StreamTransactionEntity streamTransaction ;
5454 @ Captor
5555 private ArgumentCaptor <Function <Collection <String >, String >> beginPassed ;
@@ -58,6 +58,7 @@ public class ArangoTransactionManagerTest {
5858
5959 @ Before
6060 public void setupMocks () {
61+ streamTransaction = new StreamTransactionEntity ();
6162 when (operations .db ())
6263 .thenReturn (database );
6364 }
@@ -124,8 +125,6 @@ public void nestedGetTransactionReturnsExistingTransactionWithFormerCollections(
124125 assertThat (outer .isNewTransaction (), is (true ));
125126
126127 beginTransaction ("123" , "foo" , "bar" );
127- when (streamTransaction .getStatus ())
128- .thenReturn (StreamTransactionStatus .running );
129128
130129 DefaultTransactionAttribute second = createTransactionAttribute ("inner" , "bar" );
131130 TransactionStatus inner1 = underTest .getTransaction (second );
@@ -194,8 +193,8 @@ public void getTransactionThrowsInvalidIsolationLevelExceptionForIsolationSerial
194193 }
195194
196195 private void beginTransaction (String id , String ... collectionNames ) {
197- when ( streamTransaction . getId ())
198- . thenReturn ( id );
196+ ReflectionTestUtils . setField ( streamTransaction , "id" , id );
197+ ReflectionTestUtils . setField ( streamTransaction , "status" , StreamTransactionStatus . running );
199198 when (database .beginStreamTransaction (any ()))
200199 .thenReturn (streamTransaction );
201200 lenient ().when (database .getStreamTransaction (any ()))
0 commit comments