From 8efc15839dd400e43e2816c17d25e76584520e74 Mon Sep 17 00:00:00 2001 From: brfrn169 Date: Sun, 6 Jul 2025 22:36:47 +0900 Subject: [PATCH 1/2] Minor fixes to unit tests --- .../CoordinatorGroupCommitterTest.java | 3 ++- .../consensuscommit/ParallelExecutorTest.java | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/core/src/test/java/com/scalar/db/transaction/consensuscommit/CoordinatorGroupCommitterTest.java b/core/src/test/java/com/scalar/db/transaction/consensuscommit/CoordinatorGroupCommitterTest.java index 40d2491c5c..0d123cd3ae 100644 --- a/core/src/test/java/com/scalar/db/transaction/consensuscommit/CoordinatorGroupCommitterTest.java +++ b/core/src/test/java/com/scalar/db/transaction/consensuscommit/CoordinatorGroupCommitterTest.java @@ -258,8 +258,9 @@ void remove_GivenAllFullTxIds_ShouldRemoveAll() throws Exception { } } + @SuppressWarnings("ClassCanBeStatic") @Nested - static class CoordinatorGroupCommitKeyManipulatorTest { + class CoordinatorGroupCommitKeyManipulatorTest { private final CoordinatorGroupCommitKeyManipulator keyManipulator = new CoordinatorGroupCommitKeyManipulator(); diff --git a/core/src/test/java/com/scalar/db/transaction/consensuscommit/ParallelExecutorTest.java b/core/src/test/java/com/scalar/db/transaction/consensuscommit/ParallelExecutorTest.java index 84ac27206d..0d60fa5e8d 100644 --- a/core/src/test/java/com/scalar/db/transaction/consensuscommit/ParallelExecutorTest.java +++ b/core/src/test/java/com/scalar/db/transaction/consensuscommit/ParallelExecutorTest.java @@ -1,7 +1,9 @@ package com.scalar.db.transaction.consensuscommit; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.Assertions.catchException; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.atMost; import static org.mockito.Mockito.doThrow; @@ -694,12 +696,21 @@ public void executeTasks_ParallelTrueAndStopOnErrorTrue_ExceptionThrown_ShouldSt List mixedTasks = Arrays.asList(failingTask1, failingTask2, task); // Act Assert - assertThatThrownBy( + Exception exception = + catchException( () -> parallelExecutor.executeTasks( - mixedTasks, parallel, noWait, stopOnError, "test", TX_ID)) - .isEqualTo(executionException1) - .hasSuppressedException(executionException2); + mixedTasks, parallel, noWait, stopOnError, "test", TX_ID)); + + if (exception == executionException1) { + assertThat(exception) + .isEqualTo(executionException1) + .hasSuppressedException(executionException2); + } else { + assertThat(exception) + .isEqualTo(executionException2) + .hasSuppressedException(executionException1); + } verify(parallelExecutorService, times(mixedTasks.size())).execute(any()); } From cfcff7b5bd9016dbcac7dc74d76a4cdb11f708df Mon Sep 17 00:00:00 2001 From: brfrn169 Date: Sun, 6 Jul 2025 22:42:24 +0900 Subject: [PATCH 2/2] Fix based on feedback --- .../consensuscommit/ParallelExecutorTest.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/core/src/test/java/com/scalar/db/transaction/consensuscommit/ParallelExecutorTest.java b/core/src/test/java/com/scalar/db/transaction/consensuscommit/ParallelExecutorTest.java index 0d60fa5e8d..fc889181f4 100644 --- a/core/src/test/java/com/scalar/db/transaction/consensuscommit/ParallelExecutorTest.java +++ b/core/src/test/java/com/scalar/db/transaction/consensuscommit/ParallelExecutorTest.java @@ -695,22 +695,24 @@ public void executeTasks_ParallelTrueAndStopOnErrorTrue_ExceptionThrown_ShouldSt List mixedTasks = Arrays.asList(failingTask1, failingTask2, task); - // Act Assert + // Act Exception exception = catchException( () -> parallelExecutor.executeTasks( mixedTasks, parallel, noWait, stopOnError, "test", TX_ID)); - if (exception == executionException1) { - assertThat(exception) - .isEqualTo(executionException1) - .hasSuppressedException(executionException2); - } else { - assertThat(exception) - .isEqualTo(executionException2) - .hasSuppressedException(executionException1); - } + // Assert + assertThat(exception) + .satisfiesAnyOf( + e -> + assertThat(e) + .isEqualTo(executionException1) + .hasSuppressedException(executionException2), + e -> + assertThat(e) + .isEqualTo(executionException2) + .hasSuppressedException(executionException1)); verify(parallelExecutorService, times(mixedTasks.size())).execute(any()); }