From 73bf5f15240c48ae5f434ccd6ee612a73d9a4e27 Mon Sep 17 00:00:00 2001 From: Harald Aamot Date: Fri, 15 Nov 2024 09:41:52 +0000 Subject: [PATCH] refactor: JUnit Jupiter migration from JUnit 4.x Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.java.testing.junit5.JUnit4to5Migration?organizationId=U0FQ Co-authored-by: Moderne --- gradle/changelog.gradle | 3 +++ gradle/codeCoverage.gradle | 3 +++ gradle/publishing.gradle | 3 +++ gradle/release.gradle | 3 +++ src/test/java/io/neonbee/data/DataExceptionTest.java | 2 +- .../java/io/neonbee/data/internal/DataContextImplTest.java | 6 +++--- .../java/io/neonbee/entity/EntityModelDefinitionTest.java | 2 +- src/test/java/io/neonbee/entity/EntityModelManagerTest.java | 2 +- src/test/java/io/neonbee/entity/EntityModelTest.java | 2 +- .../io/neonbee/internal/deploy/DeployableModuleTest.java | 2 +- .../java/io/neonbee/internal/deploy/DeployablesTest.java | 2 +- .../neonbee/internal/json/ConfigurableJsonFactoryTest.java | 2 +- src/test/java/io/neonbee/logging/LoggingFacadeTest.java | 2 +- .../io/neonbee/logging/internal/LoggingFacadeImplTest.java | 2 +- 14 files changed, 24 insertions(+), 12 deletions(-) diff --git a/gradle/changelog.gradle b/gradle/changelog.gradle index 229c8f55..99e13c1f 100644 --- a/gradle/changelog.gradle +++ b/gradle/changelog.gradle @@ -14,3 +14,6 @@ changelog { commitUrlTemplate = 'https://github.com/SAP/neonbee/commit/:commitId' mentionUrlTemplate = 'https://github.com/:username' } +tasks.withType(Test).configureEach { + useJUnitPlatform() +} diff --git a/gradle/codeCoverage.gradle b/gradle/codeCoverage.gradle index 3f4ae03e..75b955c9 100644 --- a/gradle/codeCoverage.gradle +++ b/gradle/codeCoverage.gradle @@ -107,3 +107,6 @@ jacocoTestReport { // Display the code coverage every time after the jacocoTestReport run finalizedBy project.tasks.reportCoverage } +tasks.withType(Test).configureEach { + useJUnitPlatform() +} diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle index 324be8ad..5e0876c9 100644 --- a/gradle/publishing.gradle +++ b/gradle/publishing.gradle @@ -217,3 +217,6 @@ task setNewVersion { buildFile.setText(buildFile.getText().replaceFirst("version = '$version'", "version = '$newVersion'")) } } +tasks.withType(Test).configureEach { + useJUnitPlatform() +} diff --git a/gradle/release.gradle b/gradle/release.gradle index 0ad2d7e8..8bad75af 100644 --- a/gradle/release.gradle +++ b/gradle/release.gradle @@ -49,4 +49,7 @@ task finishRelease { grgit.push() grgit.close() } +} +tasks.withType(Test).configureEach { + useJUnitPlatform() } \ No newline at end of file diff --git a/src/test/java/io/neonbee/data/DataExceptionTest.java b/src/test/java/io/neonbee/data/DataExceptionTest.java index 6e3992dc..140681a1 100644 --- a/src/test/java/io/neonbee/data/DataExceptionTest.java +++ b/src/test/java/io/neonbee/data/DataExceptionTest.java @@ -1,7 +1,7 @@ package io.neonbee.data; import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.Map; diff --git a/src/test/java/io/neonbee/data/internal/DataContextImplTest.java b/src/test/java/io/neonbee/data/internal/DataContextImplTest.java index 3786755a..87fa976c 100644 --- a/src/test/java/io/neonbee/data/internal/DataContextImplTest.java +++ b/src/test/java/io/neonbee/data/internal/DataContextImplTest.java @@ -3,11 +3,11 @@ import static com.google.common.truth.Truth.assertThat; import static io.neonbee.data.internal.DataContextImpl.NO_SESSION_ID_AVAILABLE_KEY; import static io.neonbee.internal.handler.CorrelationIdHandler.CORRELATION_ID; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/src/test/java/io/neonbee/entity/EntityModelDefinitionTest.java b/src/test/java/io/neonbee/entity/EntityModelDefinitionTest.java index bd9eff6d..63ba034b 100644 --- a/src/test/java/io/neonbee/entity/EntityModelDefinitionTest.java +++ b/src/test/java/io/neonbee/entity/EntityModelDefinitionTest.java @@ -2,7 +2,7 @@ import static com.google.common.truth.Truth.assertThat; import static io.neonbee.test.helper.ResourceHelper.TEST_RESOURCES; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.IOException; import java.nio.file.Files; diff --git a/src/test/java/io/neonbee/entity/EntityModelManagerTest.java b/src/test/java/io/neonbee/entity/EntityModelManagerTest.java index c1cdcdd5..c84a22da 100644 --- a/src/test/java/io/neonbee/entity/EntityModelManagerTest.java +++ b/src/test/java/io/neonbee/entity/EntityModelManagerTest.java @@ -5,8 +5,8 @@ import static io.neonbee.entity.EntityModelManager.getBufferedOData; import static io.neonbee.test.helper.OptionsHelper.defaultOptions; import static io.neonbee.test.helper.ResourceHelper.TEST_RESOURCES; -import static org.junit.Assert.assertThrows; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/src/test/java/io/neonbee/entity/EntityModelTest.java b/src/test/java/io/neonbee/entity/EntityModelTest.java index b7401190..faa44458 100644 --- a/src/test/java/io/neonbee/entity/EntityModelTest.java +++ b/src/test/java/io/neonbee/entity/EntityModelTest.java @@ -1,7 +1,7 @@ package io.neonbee.entity; import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.HashMap; import java.util.Map; diff --git a/src/test/java/io/neonbee/internal/deploy/DeployableModuleTest.java b/src/test/java/io/neonbee/internal/deploy/DeployableModuleTest.java index 5516031e..71f8b6d0 100644 --- a/src/test/java/io/neonbee/internal/deploy/DeployableModuleTest.java +++ b/src/test/java/io/neonbee/internal/deploy/DeployableModuleTest.java @@ -5,7 +5,7 @@ import static io.neonbee.test.helper.DummyVerticleHelper.DUMMY_VERTICLE; import static io.neonbee.test.helper.FileSystemHelper.createTempDirectory; import static io.vertx.core.Future.succeededFuture; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/src/test/java/io/neonbee/internal/deploy/DeployablesTest.java b/src/test/java/io/neonbee/internal/deploy/DeployablesTest.java index 5508a7eb..0b6e3bf0 100644 --- a/src/test/java/io/neonbee/internal/deploy/DeployablesTest.java +++ b/src/test/java/io/neonbee/internal/deploy/DeployablesTest.java @@ -4,8 +4,8 @@ import static io.neonbee.internal.deploy.DeploymentTest.newNeonBeeMockForDeployment; import static io.vertx.core.Future.failedFuture; import static io.vertx.core.Future.succeededFuture; -import static org.junit.Assert.assertThrows; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.List; import java.util.stream.Collectors; diff --git a/src/test/java/io/neonbee/internal/json/ConfigurableJsonFactoryTest.java b/src/test/java/io/neonbee/internal/json/ConfigurableJsonFactoryTest.java index c36fc7e8..cf506d14 100644 --- a/src/test/java/io/neonbee/internal/json/ConfigurableJsonFactoryTest.java +++ b/src/test/java/io/neonbee/internal/json/ConfigurableJsonFactoryTest.java @@ -3,8 +3,8 @@ import static com.fasterxml.jackson.core.StreamReadConstraints.DEFAULT_MAX_STRING_LEN; import static com.google.common.truth.Truth.assertThat; import static io.neonbee.internal.helper.StringHelper.EMPTY; -import static org.junit.Assert.assertThrows; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.lang.reflect.Method; import java.util.function.Supplier; diff --git a/src/test/java/io/neonbee/logging/LoggingFacadeTest.java b/src/test/java/io/neonbee/logging/LoggingFacadeTest.java index d20c1096..1871c98c 100644 --- a/src/test/java/io/neonbee/logging/LoggingFacadeTest.java +++ b/src/test/java/io/neonbee/logging/LoggingFacadeTest.java @@ -2,7 +2,7 @@ import static com.google.common.truth.Truth.assertThat; import static io.neonbee.internal.handler.CorrelationIdHandler.CORRELATION_ID; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.CALLS_REAL_METHODS; diff --git a/src/test/java/io/neonbee/logging/internal/LoggingFacadeImplTest.java b/src/test/java/io/neonbee/logging/internal/LoggingFacadeImplTest.java index adfcf8b1..418fe09a 100644 --- a/src/test/java/io/neonbee/logging/internal/LoggingFacadeImplTest.java +++ b/src/test/java/io/neonbee/logging/internal/LoggingFacadeImplTest.java @@ -2,7 +2,7 @@ import static com.google.common.truth.Truth.assertThat; import static io.neonbee.logging.internal.LoggingFacadeImpl.DEFAULT_MARKER; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock;