2020import static java .lang .String .format ;
2121import static java .util .Collections .emptyList ;
2222import static java .util .Comparator .comparing ;
23+ import static org .apache .ignite .internal .IgniteExceptionTestUtils .publicException ;
24+ import static org .apache .ignite .internal .IgniteExceptionTestUtils .publicExceptionWithHint ;
2325import static org .apache .ignite .internal .TestWrappers .unwrapIgniteImpl ;
2426import static org .apache .ignite .internal .testframework .matchers .CompletableFutureExceptionMatcher .willThrowWithCauseOrSuppressed ;
2527import static org .apache .ignite .internal .testframework .matchers .CompletableFutureMatcher .willSucceedFast ;
2628import static org .awaitility .Awaitility .await ;
2729import static org .hamcrest .MatcherAssert .assertThat ;
28- import static org .hamcrest .Matchers .containsString ;
30+ import static org .hamcrest .Matchers .isA ;
2931import static org .hamcrest .Matchers .startsWith ;
3032import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
3133import static org .junit .jupiter .api .Assertions .assertEquals ;
7072import org .apache .ignite .internal .tx .TxState ;
7173import org .apache .ignite .internal .util .CollectionUtils ;
7274import org .apache .ignite .lang .ErrorGroups ;
75+ import org .apache .ignite .lang .ErrorGroups .Common ;
7376import org .apache .ignite .lang .ErrorGroups .Transactions ;
7477import org .apache .ignite .lang .IgniteException ;
7578import org .apache .ignite .network .ClusterNode ;
@@ -316,11 +319,14 @@ public boolean isReadOnly() {
316319 };
317320
318321 var ex = assertThrows (IgniteException .class , () -> kvView ().put (tx , 1 , "1" ));
319-
320- String expected = "Unsupported transaction implementation: "
321- + "'class org.apache.ignite.internal.client.ItThinClientTransactionsTest" ;
322-
323- assertThat (ex .getMessage (), containsString (expected ));
322+ assertThat (ex ,
323+ publicException (
324+ IgniteException .class ,
325+ Common .INTERNAL_ERR ,
326+ format ("Unsupported transaction implementation: 'class %s'" , tx .getClass ().getName ()),
327+ emptyList ()
328+ )
329+ );
324330 }
325331
326332 @ Test
@@ -332,8 +338,14 @@ void testTransactionFromAnotherChannelThrows() {
332338 RecordView <Tuple > recordView = client2 .tables ().tables ().get (0 ).recordView ();
333339
334340 var ex = assertThrows (IgniteException .class , () -> recordView .upsert (tx , Tuple .create ()));
335-
336- assertThat (ex .getMessage (), containsString ("Transaction belongs to a different client instance" ));
341+ assertThat (ex ,
342+ publicException (
343+ IgniteException .class ,
344+ Common .INTERNAL_ERR ,
345+ "Transaction belongs to a different client instance" ,
346+ emptyList ()
347+ ).withCause (isA (IllegalArgumentException .class ))
348+ );
337349 }
338350 }
339351
@@ -366,8 +378,13 @@ void testUpdateInReadOnlyTxThrows() {
366378 Transaction tx = client ().transactions ().begin (new TransactionOptions ().readOnly (true ));
367379 var ex = assertThrows (TransactionException .class , () -> kvView .put (tx , 1 , "2" ));
368380
369- assertThat (ex .getMessage (), containsString ("Failed to enlist read-write operation into read-only transaction" ));
370- assertEquals (ErrorGroups .Transactions .TX_FAILED_READ_WRITE_OPERATION_ERR , ex .code ());
381+ assertThat (ex ,
382+ publicExceptionWithHint (
383+ TransactionException .class ,
384+ ErrorGroups .Transactions .TX_FAILED_READ_WRITE_OPERATION_ERR ,
385+ "Failed to enlist read-write operation into read-only transaction"
386+ )
387+ );
371388 }
372389
373390 @ ParameterizedTest
0 commit comments