Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,9 @@ void remove_GivenAllFullTxIds_ShouldRemoveAll() throws Exception {
}
}

@SuppressWarnings("ClassCanBeStatic")
@Nested
static class CoordinatorGroupCommitKeyManipulatorTest {
class CoordinatorGroupCommitKeyManipulatorTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Making CoordinatorGroupCommitKeyManipulatorTest a non-static inner class introduces an implicit reference to CoordinatorGroupCommitterTest. Unless required by the testing framework, keeping it static improves clarity.

  @Nested
  static class CoordinatorGroupCommitKeyManipulatorTest {

private final CoordinatorGroupCommitKeyManipulator keyManipulator =
new CoordinatorGroupCommitKeyManipulator();

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -693,13 +695,24 @@ public void executeTasks_ParallelTrueAndStopOnErrorTrue_ExceptionThrown_ShouldSt

List<ParallelExecutorTask> mixedTasks = Arrays.asList(failingTask1, failingTask2, task);

// Act Assert
assertThatThrownBy(
// Act
Exception exception =
catchException(
() ->
parallelExecutor.executeTasks(
mixedTasks, parallel, noWait, stopOnError, "test", TX_ID))
.isEqualTo(executionException1)
.hasSuppressedException(executionException2);
mixedTasks, parallel, noWait, stopOnError, "test", TX_ID));

// Assert
assertThat(exception)
.satisfiesAnyOf(
e ->
assertThat(e)
.isEqualTo(executionException1)
.hasSuppressedException(executionException2),
e ->
assertThat(e)
.isEqualTo(executionException2)
.hasSuppressedException(executionException1));
Comment on lines +706 to +715
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The satisfiesAnyOf assertion can be simplified by extracting the common assertion into a separate variable to avoid redundancy and improve readability.

Suggested change
assertThat(exception)
.satisfiesAnyOf(
e ->
assertThat(e)
.isEqualTo(executionException1)
.hasSuppressedException(executionException2),
e ->
assertThat(e)
.isEqualTo(executionException2)
.hasSuppressedException(executionException1));
assertThat(exception)
.satisfiesAnyOf(
e -> {
assertThat(e).isEqualTo(executionException1);
assertThat(e).hasSuppressedException(executionException2);
},
e -> {
assertThat(e).isEqualTo(executionException2);
assertThat(e).hasSuppressedException(executionException1);
});


verify(parallelExecutorService, times(mixedTasks.size())).execute(any());
}
Expand Down