Skip to content

make use of @ParameterizedClass feature (since JUnit 5.13) to simplify tests #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
# limitations under the License.

[versions]
junit-jupiter = "5.11.4"
junit-jupiter = "5.13.4"
assertj = "3.27.3"
google-errorprone-core = "2.36.0"
nullaway = "0.12.4"
jspecify = "1.0.0"
hibernate-orm = "6.6.23.Final"
hibernate-orm = "6.6.25.Final"
mongo-java-driver-sync = "5.3.1"
slf4j-api = "2.0.16"
logback-classic = "1.5.16"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.Parameter;
import org.junit.jupiter.params.ParameterizedClass;
import org.junit.jupiter.params.provider.ValueSource;

@ExtendWith(MongoExtension.class)
@ParameterizedClass
@ValueSource(booleans = {true, false})
class MongoPreparedStatementIntegrationTests {

@AutoClose
Expand All @@ -63,6 +68,9 @@ class MongoPreparedStatementIntegrationTests {
@AutoClose
private Session session;

@Parameter
private boolean autoCommit;

@BeforeAll
static void beforeAll() {
sessionFactory = new Configuration().buildSessionFactory();
Expand Down Expand Up @@ -405,6 +413,7 @@ private void doWorkAwareOfAutoCommit(Work work) {
}

void doAwareOfAutoCommit(Connection connection, SqlExecutable work) throws SQLException {
doWithSpecifiedAutoCommit(false, connection, () -> doAndTerminateTransaction(connection, work));
doWithSpecifiedAutoCommit(
autoCommit, connection, autoCommit ? work : () -> doAndTerminateTransaction(connection, work));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.Parameter;
import org.junit.jupiter.params.ParameterizedClass;
import org.junit.jupiter.params.provider.ValueSource;

@ExtendWith(MongoExtension.class)
@ParameterizedClass
@ValueSource(booleans = {true, false})
class MongoStatementIntegrationTests {

@AutoClose
Expand All @@ -54,6 +59,9 @@ class MongoStatementIntegrationTests {
@AutoClose
private Session session;

@Parameter
boolean autoCommit;

@BeforeAll
static void beforeAll() {
sessionFactory = new Configuration().buildSessionFactory();
Expand Down Expand Up @@ -278,7 +286,8 @@ private void doWorkAwareOfAutoCommit(Work work) {
}

void doAwareOfAutoCommit(Connection connection, SqlExecutable work) throws SQLException {
doWithSpecifiedAutoCommit(false, connection, () -> doAndTerminateTransaction(connection, work));
doWithSpecifiedAutoCommit(
autoCommit, connection, autoCommit ? work : () -> doAndTerminateTransaction(connection, work));
}

static void doWithSpecifiedAutoCommit(boolean autoCommit, Connection connection, SqlExecutable work)
Expand Down

This file was deleted.