77import com .arangodb .model .TransactionCollectionOptions ;
88import com .arangodb .springframework .core .ArangoOperations ;
99import com .arangodb .springframework .repository .query .QueryTransactionBridge ;
10- import org .junit .After ;
11- import org .junit .Before ;
12- import org .junit .Test ;
13- import org .junit .runner . RunWith ;
10+ import org .junit .jupiter . api . AfterEach ;
11+ import org .junit .jupiter . api . BeforeEach ;
12+ import org .junit .jupiter . api . Test ;
13+ import org .junit .jupiter . api . extension . ExtendWith ;
1414import org .mockito .ArgumentCaptor ;
1515import org .mockito .Captor ;
1616import org .mockito .InjectMocks ;
1717import org .mockito .Mock ;
18- import org .mockito .junit .MockitoJUnitRunner ;
18+ import org .mockito .junit .jupiter . MockitoExtension ;
1919import org .springframework .lang .Nullable ;
2020import org .springframework .test .util .ReflectionTestUtils ;
2121import org .springframework .transaction .*;
3535import static org .hamcrest .Matchers .hasItems ;
3636import static org .hamcrest .Matchers .not ;
3737import static org .hamcrest .Matchers .nullValue ;
38+ import static org .junit .jupiter .api .Assertions .assertThrows ;
3839import static org .mockito .ArgumentMatchers .any ;
3940import static org .mockito .Mockito .*;
4041import static org .springframework .beans .PropertyAccessorFactory .forDirectFieldAccess ;
4142
42- @ RunWith ( MockitoJUnitRunner .class )
43+ @ ExtendWith ( MockitoExtension .class )
4344public class ArangoTransactionManagerTest {
4445
4546 @ Mock
@@ -56,14 +57,14 @@ public class ArangoTransactionManagerTest {
5657 @ Captor
5758 private ArgumentCaptor <StreamTransactionOptions > optionsPassed ;
5859
59- @ Before
60+ @ BeforeEach
6061 public void setupMocks () {
6162 streamTransaction = new StreamTransactionEntity ();
6263 when (operations .db ())
6364 .thenReturn (database );
6465 }
6566
66- @ After
67+ @ AfterEach
6768 public void cleanupSync () {
6869 TransactionSynchronizationManager .unbindResourceIfPossible (underTest );
6970 TransactionSynchronizationManager .clear ();
@@ -91,16 +92,13 @@ public void innerGetTransactionIsNotNewTransactionIncludingFormerCollections() {
9192 verifyNoInteractions (database );
9293 }
9394
94- @ Test ( expected = UnexpectedRollbackException . class )
95+ @ Test
9596 public void innerRollbackCausesUnexpectedRollbackOnOuterCommit () {
9697 TransactionStatus outer = underTest .getTransaction (createTransactionAttribute ("outer" ));
9798 TransactionStatus inner = underTest .getTransaction (createTransactionAttribute ("inner" ));
9899 underTest .rollback (inner );
99- try {
100- underTest .commit (outer );
101- } finally {
102- assertThat (TransactionSynchronizationManager .getResource (underTest ), nullValue ());
103- }
100+ assertThrows (UnexpectedRollbackException .class , () -> underTest .commit (outer ));
101+ assertThat (TransactionSynchronizationManager .getResource (underTest ), nullValue ());
104102 }
105103
106104 @ Test
@@ -185,11 +183,11 @@ public void getTransactionWithMultipleBridgeCallsIgnoresAdditionalCollections()
185183 assertThat (getTransactionObject (state ).getHolder ().getCollectionNames (), not (hasItem ("baz" )));
186184 }
187185
188- @ Test ( expected = InvalidIsolationLevelException . class )
186+ @ Test
189187 public void getTransactionThrowsInvalidIsolationLevelExceptionForIsolationSerializable () {
190188 DefaultTransactionAttribute definition = createTransactionAttribute ("serializable" );
191189 definition .setIsolationLevel (TransactionDefinition .ISOLATION_SERIALIZABLE );
192- underTest .getTransaction (definition );
190+ assertThrows ( InvalidIsolationLevelException . class , () -> underTest .getTransaction (definition ) );
193191 }
194192
195193 private void beginTransaction (String id , String ... collectionNames ) {
0 commit comments