timoninmaxim commented on code in PR #11713: URL: https://github.com/apache/ignite/pull/11713#discussion_r1895614761
########## modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/NonTransactionalOperationsInTxTest.java: ########## @@ -115,11 +119,80 @@ private void checkIgniteCacheOperation(IgniteEx ignite, boolean near, Consumer<I return null; }), CacheException.class, - NON_TRANSACTIONAL_IGNITE_CACHE_CLEAR_IN_TX_ERROR_MESSAGE + String.format(NON_TRANSACTIONAL_IGNITE_CACHE_CLEAR_IN_TX_ERROR_MESSAGE, checkClearAsync(async)) ); assertTrue(cache.containsKey(1)); assertFalse(cache.containsKey(2)); } + + /** */ + private String checkClearAsync(boolean async) { + return async ? "clearAsync" : "clear"; + } + + /** */ + @Test + public void testIgniteCacheRemove() throws Exception { + startGrid(0); + + checkRemoveOperation(grid(0)); + } + + /** */ + @Test + public void testIgniteCacheRemoveOnClientNode() throws Exception { + startGrid(0); + + startClientGrid(1); + + checkRemoveOperation(grid(1)); + } + + /** + * It should throw exception. + * + * @param ignite Ignite. + */ + private void checkRemoveOperation(IgniteEx ignite) { + checkIgniteCacheRemoveOperation(ignite, false, cache -> cache.removeAll()); + + checkIgniteCacheRemoveOperation(ignite, true, cache -> cache.removeAllAsync()); + } + + /** + * It should throw exception. + * + * @param ignite Ignite. + * @param async Async flag. + * @param op Operation. + */ + private void checkIgniteCacheRemoveOperation(IgniteEx ignite, boolean async, + Consumer<IgniteCache<Object, Object>> op) { + IgniteCache<Object, Object> cache = ignite.cache(DEFAULT_CACHE_NAME); + + cache.put(1, 1); + + assertThrows(null, + () -> doInTransaction(ignite, () -> { + cache.put(2, 2); + + op.accept(cache); + + return null; + }), + CacheException.class, + String.format(NON_TRANSACTIONAL_IGNITE_CACHE_IN_TX_ERROR_MESSAGE, checkRemoveAsync(async)) + ); + + assertTrue(cache.containsKey(1)); + + assertFalse(cache.containsKey(2)); + } + + /** */ + private String checkRemoveAsync(boolean async) { + return async ? "removeAllAsync" : "removeAll"; Review Comment: Inline this method -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org