diff --git a/extensions/email-sms/sources/pom.xml b/extensions/email-sms/sources/pom.xml index 5b5d44ee..f78c46ba 100644 --- a/extensions/email-sms/sources/pom.xml +++ b/extensions/email-sms/sources/pom.xml @@ -91,9 +91,8 @@ - junit - junit - ${junit.version} + org.junit.jupiter + junit-jupiter test diff --git a/extensions/entity-files/sources/core/src/test/java/tools/dynamia/modules/entityfile/remote/BuckieEntityFileStorageTest.java b/extensions/entity-files/sources/core/src/test/java/tools/dynamia/modules/entityfile/remote/BuckieEntityFileStorageTest.java index 1ad115ea..50b9e4c2 100644 --- a/extensions/entity-files/sources/core/src/test/java/tools/dynamia/modules/entityfile/remote/BuckieEntityFileStorageTest.java +++ b/extensions/entity-files/sources/core/src/test/java/tools/dynamia/modules/entityfile/remote/BuckieEntityFileStorageTest.java @@ -17,10 +17,10 @@ package tools.dynamia.modules.entityfile.remote; -import org.junit.Assume; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.springframework.mock.env.MockEnvironment; import tools.dynamia.domain.InMemoryCrudService; import tools.dynamia.domain.query.Parameter; @@ -40,13 +40,13 @@ import java.util.Collection; import java.util.List; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * Integration tests for {@link BuckieEntityFileStorage}. * *

Pure-logic tests (buildKey, getFileName, etc.) always run. - * HTTP tests are skipped automatically via {@code Assume.assumeTrue} + * HTTP tests are skipped automatically via {@code Assumptions.assumeTrue} * when the SFS server is not reachable.

* *

Server configuration via system properties or environment variables: @@ -70,7 +70,7 @@ public class BuckieEntityFileStorageTest { // ── Setup ───────────────────────────────────────────────────────────────── - @BeforeClass + @BeforeAll public static void readConfiguration() { sfsUrl = systemOrEnv(BuckieEntityFileStorage.SFS_URL, "http://localhost:8500"); sfsBucket = systemOrEnv(BuckieEntityFileStorage.SFS_BUCKET, "test"); @@ -80,7 +80,7 @@ public static void readConfiguration() { System.out.println("[SFS Test] URL=" + sfsUrl + " | BUCKET=" + sfsBucket); } - @Before + @BeforeEach public void setUp() { MockEnvironment env = new MockEnvironment(); env.setProperty(BuckieEntityFileStorage.SFS_URL, sfsUrl); @@ -103,7 +103,7 @@ public void testGetId() { @Test public void testGetName() { assertNotNull(storage.getName()); - assertFalse("Storage name must not be blank", storage.getName().isBlank()); + assertFalse(storage.getName().isBlank(), "Storage name must not be blank"); } @Test @@ -111,8 +111,8 @@ public void testBuildKey_withoutSubfolder() { EntityFile ef = buildEntityFile("report.pdf", null, 10L); String key = storage.buildKey(ef); - assertTrue("Key must start with account10/", key.startsWith("account10/")); - assertTrue("Key must contain the uuid", key.contains(ef.getUuid())); + assertTrue(key.startsWith("account10/"), "Key must start with account10/"); + assertTrue(key.contains(ef.getUuid()), "Key must contain the uuid"); } @Test @@ -120,8 +120,8 @@ public void testBuildKey_withSubfolder() { EntityFile ef = buildEntityFile("image.jpg", "photos/2026", 5L); String key = storage.buildKey(ef); - assertTrue("Key must start with account5/", key.startsWith("account5/")); - assertTrue("Key must contain the subfolder path", key.contains("photos/2026/")); + assertTrue(key.startsWith("account5/"), "Key must start with account5/"); + assertTrue(key.contains("photos/2026/"), "Key must contain the subfolder path"); } @Test @@ -129,9 +129,9 @@ public void testGetFileName_withSpacesAndDashes() { EntityFile ef = buildEntityFile("My File-Final.pdf", null, 1L); String name = BuckieEntityFileStorage.getFileName(ef); - assertFalse("File name must not contain spaces", name.contains(" ")); - assertFalse("File name base must not contain dashes", - name.substring(name.lastIndexOf('/') + 1).replace(ef.getUuid(), "").contains("-")); + assertFalse(name.contains(" "), "File name must not contain spaces"); + assertFalse(name.substring(name.lastIndexOf('/') + 1).replace(ef.getUuid(), "").contains("-"), + "File name base must not contain dashes"); } @Test @@ -139,10 +139,10 @@ public void testGetFileName_withAccentsAndSpecialChars() { EntityFile ef = buildEntityFile("Ñoño Ávido Murió.pdf", null, 1L); String name = BuckieEntityFileStorage.getFileName(ef); - assertFalse("File name must not contain ñ", name.contains("ñ")); - assertFalse("File name must not contain á", name.contains("á")); - assertFalse("File name must not contain ó", name.contains("ó")); - assertFalse("File name must not contain spaces", name.contains(" ")); + assertFalse(name.contains("ñ"), "File name must not contain ñ"); + assertFalse(name.contains("á"), "File name must not contain á"); + assertFalse(name.contains("ó"), "File name must not contain ó"); + assertFalse(name.contains(" "), "File name must not contain spaces"); } @Test @@ -152,7 +152,7 @@ public void testGetFileName_usesStoredFileNameWhenSet() { String name = BuckieEntityFileStorage.getFileName(ef); - assertEquals("Must use storedFileName when it is set", "custom_stored_name.pdf", name); + assertEquals("custom_stored_name.pdf", name, "Must use storedFileName when it is set"); } @Test @@ -160,8 +160,8 @@ public void testGetFileName_withoutSubfolder() { EntityFile ef = buildEntityFile("doc.txt", null, 1L); String name = BuckieEntityFileStorage.getFileName(ef); - assertFalse("Without subfolder the name must not start with /", name.startsWith("/")); - assertTrue("Name must contain the uuid", name.contains(ef.getUuid())); + assertFalse(name.startsWith("/"), "Without subfolder the name must not start with /"); + assertTrue(name.contains(ef.getUuid()), "Name must contain the uuid"); } @Test @@ -176,10 +176,10 @@ public void testBuildRemoteUrl_containsUrlBucketAndKey() { EntityFile ef = buildEntityFile("document.pdf", null, 3L); String url = storage.buildRemoteUrl(ef); - assertTrue("URL must start with the SFS base URL", url.startsWith(sfsUrl)); - assertTrue("URL must contain the bucket name", url.contains(sfsBucket)); - assertTrue("URL must contain the account folder", url.contains("account3/")); - assertTrue("URL must contain the file uuid", url.contains(ef.getUuid())); + assertTrue(url.startsWith(sfsUrl), "URL must start with the SFS base URL"); + assertTrue(url.contains(sfsBucket), "URL must contain the bucket name"); + assertTrue(url.contains("account3/"), "URL must contain the account folder"); + assertTrue(url.contains(ef.getUuid()), "URL must contain the file uuid"); } @Test @@ -187,9 +187,9 @@ public void testDownload_returnsRemoteStoredEntityFile() { EntityFile ef = buildEntityFile("file.txt", null, 1L); StoredEntityFile stored = storage.download(ef); - assertNotNull("StoredEntityFile must not be null", stored); - assertNotNull("URL must not be null", stored.getUrl()); - assertNull("Remote file must not have a local real file", stored.getRealFile()); + assertNotNull(stored, "StoredEntityFile must not be null"); + assertNotNull(stored.getUrl(), "URL must not be null"); + assertNull(stored.getRealFile(), "Remote file must not have a local real file"); } @Test @@ -198,12 +198,12 @@ public void testThumbnailUrl_containsDimensionParameters() { StoredEntityFile stored = storage.download(ef); String thumb100 = stored.getThumbnailUrl(100, 100); - assertTrue("Thumbnail URL must contain w=100", thumb100.contains("w=100")); - assertTrue("Thumbnail URL must contain h=100", thumb100.contains("h=100")); + assertTrue(thumb100.contains("w=100"), "Thumbnail URL must contain w=100"); + assertTrue(thumb100.contains("h=100"), "Thumbnail URL must contain h=100"); String thumb200 = stored.getThumbnailUrl(200, 300); - assertTrue("Thumbnail URL must contain w=200", thumb200.contains("w=200")); - assertTrue("Thumbnail URL must contain h=300", thumb200.contains("h=300")); + assertTrue(thumb200.contains("w=200"), "Thumbnail URL must contain w=200"); + assertTrue(thumb200.contains("h=300"), "Thumbnail URL must contain h=300"); } @Test @@ -215,12 +215,12 @@ public void testReloadParams_resetsAndRebuildsClient() { storage.reloadParams(); // First call after reload must rebuild the client without throwing - assertNotNull("Client must be rebuilt after reloadParams", storage.client()); + assertNotNull(storage.client(), "Client must be rebuilt after reloadParams"); } @Test public void testToResource_returnsInputStreamResource() { - Assume.assumeTrue("SFS server not available at " + sfsUrl, isServerReachable()); + Assumptions.assumeTrue(isServerReachable(), "SFS server not available at " + sfsUrl); // Upload a file first so the URL is actually retrievable EntityFile ef = buildEntityFile("to-resource-" + System.currentTimeMillis() + ".txt", null, 1L); @@ -231,12 +231,12 @@ public void testToResource_returnsInputStreamResource() { StoredEntityFile stored = storage.download(ef); // toResource() must authenticate with SFS and return an InputStreamResource - assertNotNull("toResource() must not throw or return null", stored.toResource()); + assertNotNull(stored.toResource(), "toResource() must not throw or return null"); } @Test public void testToThumbnailResource_returnsInputStreamResource() { - Assume.assumeTrue("SFS server not available at " + sfsUrl, isServerReachable()); + Assumptions.assumeTrue(isServerReachable(), "SFS server not available at " + sfsUrl); EntityFile ef = buildEntityFile("to-thumb-" + System.currentTimeMillis() + ".png", null, 1L); byte[] bytes = new byte[]{(byte) 0xFF, (byte) 0xD8}; // minimal JPEG-like stub @@ -246,15 +246,15 @@ public void testToThumbnailResource_returnsInputStreamResource() { StoredEntityFile stored = storage.download(ef); // toThumbnailResource() must authenticate with SFS and return an InputStreamResource - assertNotNull("toThumbnailResource() must not throw or return null", - stored.toThumbnailResource(200, 200)); + assertNotNull(stored.toThumbnailResource(200, 200), + "toThumbnailResource() must not throw or return null"); } // ── Integration tests (require a live SFS server) ───────────────────────── @Test public void testUpload_textFile() { - Assume.assumeTrue("SFS server not available at " + sfsUrl, isServerReachable()); + Assumptions.assumeTrue(isServerReachable(), "SFS server not available at " + sfsUrl); EntityFile ef = buildEntityFile("test-upload-" + System.currentTimeMillis() + ".txt", null, 1L); String content = "Hello SFS from automated test - " + System.currentTimeMillis(); @@ -266,12 +266,12 @@ public void testUpload_textFile() { storage.upload(ef, info); - assertTrue("File size must be > 0 after a successful upload", ef.getSize() > 0); + assertTrue(ef.getSize() > 0, "File size must be > 0 after a successful upload"); } @Test public void testUpload_withSubfolder() { - Assume.assumeTrue("SFS server not available at " + sfsUrl, isServerReachable()); + Assumptions.assumeTrue(isServerReachable(), "SFS server not available at " + sfsUrl); EntityFile ef = buildEntityFile("document.txt", "subfolder/tests", 1L); byte[] bytes = "content with subfolder".getBytes(StandardCharsets.UTF_8); @@ -283,12 +283,12 @@ public void testUpload_withSubfolder() { storage.upload(ef, info); String key = storage.buildKey(ef); - assertTrue("Key must include the subfolder path", key.contains("subfolder/tests/")); + assertTrue(key.contains("subfolder/tests/"), "Key must include the subfolder path"); } @Test public void testUpload_nameWithSpacesDoesNotFail() { - Assume.assumeTrue("SFS server not available at " + sfsUrl, isServerReachable()); + Assumptions.assumeTrue(isServerReachable(), "SFS server not available at " + sfsUrl); EntityFile ef = buildEntityFile("file with spaces and ñ.txt", null, 1L); byte[] bytes = "content".getBytes(StandardCharsets.UTF_8); @@ -303,7 +303,7 @@ public void testUpload_nameWithSpacesDoesNotFail() { @Test public void testDelete_changesStateToDeleted() { - Assume.assumeTrue("SFS server not available at " + sfsUrl, isServerReachable()); + Assumptions.assumeTrue(isServerReachable(), "SFS server not available at " + sfsUrl); // 1. Upload a file first EntityFile ef = buildEntityFile("test-delete-" + System.currentTimeMillis() + ".txt", null, 1L); @@ -319,12 +319,12 @@ public void testDelete_changesStateToDeleted() { storage.delete(ef); // 3. Verify state - assertEquals("State must change to DELETED", EntityFileState.DELETED, ef.getState()); + assertEquals(EntityFileState.DELETED, ef.getState(), "State must change to DELETED"); } @Test public void testUploadAndDownloadUrl_areConsistent() { - Assume.assumeTrue("SFS server not available at " + sfsUrl, isServerReachable()); + Assumptions.assumeTrue(isServerReachable(), "SFS server not available at " + sfsUrl); EntityFile ef = buildEntityFile("consistency-" + System.currentTimeMillis() + ".txt", null, 1L); byte[] bytes = "URL consistency check content".getBytes(StandardCharsets.UTF_8); @@ -340,8 +340,8 @@ public void testUploadAndDownloadUrl_areConsistent() { // The URL returned by download() must point to the same resource that was uploaded assertNotNull(url); - assertTrue("URL must contain the bucket name", url.contains(sfsBucket)); - assertTrue("URL must contain the key of the uploaded file", url.contains(storage.buildKey(ef))); + assertTrue(url.contains(sfsBucket), "URL must contain the bucket name"); + assertTrue(url.contains(storage.buildKey(ef)), "URL must contain the key of the uploaded file"); } // ── Helpers ─────────────────────────────────────────────────────────────── @@ -478,4 +478,3 @@ public Parameter findParameter(Class c, String n, QueryPara }; } } - diff --git a/extensions/entity-files/sources/pom.xml b/extensions/entity-files/sources/pom.xml index effcb51c..c8c72121 100644 --- a/extensions/entity-files/sources/pom.xml +++ b/extensions/entity-files/sources/pom.xml @@ -86,8 +86,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/extensions/entity-files/sources/s3/pom.xml b/extensions/entity-files/sources/s3/pom.xml index 9857c5bd..b1897e7a 100644 --- a/extensions/entity-files/sources/s3/pom.xml +++ b/extensions/entity-files/sources/s3/pom.xml @@ -58,9 +58,8 @@ - junit - junit - ${junit.version} + org.junit.jupiter + junit-jupiter test diff --git a/extensions/entity-files/sources/s3/src/test/java/tools/dynamia/modules/entityfiles/s3/AppTest.java b/extensions/entity-files/sources/s3/src/test/java/tools/dynamia/modules/entityfiles/s3/AppTest.java index b814161a..7ceba596 100644 --- a/extensions/entity-files/sources/s3/src/test/java/tools/dynamia/modules/entityfiles/s3/AppTest.java +++ b/extensions/entity-files/sources/s3/src/test/java/tools/dynamia/modules/entityfiles/s3/AppTest.java @@ -17,37 +17,19 @@ package tools.dynamia.modules.entityfiles.s3; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Unit test for simple App. */ public class AppTest - extends TestCase { - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - /** * Rigourous Test :-) */ + @Test public void testApp() { assertTrue( true ); diff --git a/extensions/http-functions/sources/core/pom.xml b/extensions/http-functions/sources/core/pom.xml index 05603c50..0f8d332f 100644 --- a/extensions/http-functions/sources/core/pom.xml +++ b/extensions/http-functions/sources/core/pom.xml @@ -50,5 +50,10 @@ spring-test test + + org.hamcrest + hamcrest + test + diff --git a/extensions/saas/sources/core/pom.xml b/extensions/saas/sources/core/pom.xml index 0311debf..c9135771 100644 --- a/extensions/saas/sources/core/pom.xml +++ b/extensions/saas/sources/core/pom.xml @@ -64,9 +64,8 @@ - junit - junit - ${junit.version} + org.junit.jupiter + junit-jupiter test diff --git a/extensions/saas/sources/core/src/test/java/tools/dynamia/modules/saas/AccountTest.java b/extensions/saas/sources/core/src/test/java/tools/dynamia/modules/saas/AccountTest.java index a02743cb..de079280 100644 --- a/extensions/saas/sources/core/src/test/java/tools/dynamia/modules/saas/AccountTest.java +++ b/extensions/saas/sources/core/src/test/java/tools/dynamia/modules/saas/AccountTest.java @@ -1,7 +1,7 @@ package tools.dynamia.modules.saas; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import tools.dynamia.modules.saas.domain.Account; import java.time.LocalDateTime; @@ -22,24 +22,24 @@ public void testTrialPeriod() { int left = account.computeTrialLeft(account.getFreeTrial(), creation.toLocalDate()); System.out.println("Trial Left 0 = " + left); - Assert.assertEquals(TRIAL, left); + Assertions.assertEquals(TRIAL, left); left = account.computeTrialLeft(account.getFreeTrial(), createLocalDate(2022, 1, 5)); System.out.println("Trial Left 1 = " + left); - Assert.assertEquals(10 + 1, left); + Assertions.assertEquals(10 + 1, left); left = account.computeTrialLeft(account.getFreeTrial(), createLocalDate(2022, 1, 10)); System.out.println("Trial Left 2 = " + left); - Assert.assertEquals(5 + 1, left); + Assertions.assertEquals(5 + 1, left); left = account.computeTrialLeft(account.getFreeTrial(), createLocalDate(2022, 1, 15)); System.out.println("Trial Left 3 = " + left); - Assert.assertEquals(1, left); + Assertions.assertEquals(1, left); left = account.computeTrialLeft(account.getFreeTrial(), createLocalDate(2022, 1, 20)); System.out.println("Trial Left 4 = " + left); - Assert.assertEquals(0, left); + Assertions.assertEquals(0, left); - Assert.assertFalse(account.isInFreeTrial()); + Assertions.assertFalse(account.isInFreeTrial()); } } diff --git a/extensions/saas/sources/migration/pom.xml b/extensions/saas/sources/migration/pom.xml index 391983e0..332fb1af 100644 --- a/extensions/saas/sources/migration/pom.xml +++ b/extensions/saas/sources/migration/pom.xml @@ -127,9 +127,8 @@ - junit - junit - ${junit.version} + org.junit.jupiter + junit-jupiter test @@ -140,6 +139,13 @@ test + + org.mockito + mockito-junit-jupiter + 5.20.0 + test + + diff --git a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/AccountMigrationJobTest.java b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/AccountMigrationJobTest.java index 36cf348c..b23c61ee 100644 --- a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/AccountMigrationJobTest.java +++ b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/AccountMigrationJobTest.java @@ -10,8 +10,8 @@ */ package tools.dynamia.modules.saas.migration; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import tools.dynamia.modules.saas.migration.api.MigrationProgress; import tools.dynamia.modules.saas.migration.domain.AccountJobStatus; import tools.dynamia.modules.saas.migration.domain.AccountMigrationJob; @@ -21,19 +21,19 @@ public class AccountMigrationJobTest { @Test public void newJobIsInPendingStatus() { AccountMigrationJob job = new AccountMigrationJob(); - Assert.assertEquals(AccountJobStatus.PENDING, job.getStatus()); + Assertions.assertEquals(AccountJobStatus.PENDING, job.getStatus()); } @Test public void newJobIsNotFinished() { - Assert.assertFalse(new AccountMigrationJob().isFinished()); + Assertions.assertFalse(new AccountMigrationJob().isFinished()); } @Test public void newJobHasUuid() { AccountMigrationJob job = new AccountMigrationJob(); - Assert.assertNotNull(job.getUuid()); - Assert.assertFalse(job.getUuid().isEmpty()); + Assertions.assertNotNull(job.getUuid()); + Assertions.assertFalse(job.getUuid().isEmpty()); } @Test @@ -41,9 +41,9 @@ public void markRunningTransitionsToRunning() { AccountMigrationJob job = new AccountMigrationJob(); job.markRunning(); - Assert.assertEquals(AccountJobStatus.RUNNING, job.getStatus()); - Assert.assertNotNull(job.getStartedAt()); - Assert.assertFalse(job.isFinished()); + Assertions.assertEquals(AccountJobStatus.RUNNING, job.getStatus()); + Assertions.assertNotNull(job.getStartedAt()); + Assertions.assertFalse(job.isFinished()); } @Test @@ -52,10 +52,10 @@ public void markCompletedSetsProgressTo100AndFinishedAt() { job.markRunning(); job.markCompleted(); - Assert.assertEquals(AccountJobStatus.COMPLETED, job.getStatus()); - Assert.assertEquals(100, job.getProgress()); - Assert.assertNotNull(job.getFinishedAt()); - Assert.assertTrue(job.isFinished()); + Assertions.assertEquals(AccountJobStatus.COMPLETED, job.getStatus()); + Assertions.assertEquals(100, job.getProgress()); + Assertions.assertNotNull(job.getFinishedAt()); + Assertions.assertTrue(job.isFinished()); } @Test @@ -64,10 +64,10 @@ public void markFailedStoresMessage() { job.markRunning(); job.markFailed("DB connection lost"); - Assert.assertEquals(AccountJobStatus.FAILED, job.getStatus()); - Assert.assertEquals("DB connection lost", job.getErrorMessage()); - Assert.assertNotNull(job.getFinishedAt()); - Assert.assertTrue(job.isFinished()); + Assertions.assertEquals(AccountJobStatus.FAILED, job.getStatus()); + Assertions.assertEquals("DB connection lost", job.getErrorMessage()); + Assertions.assertNotNull(job.getFinishedAt()); + Assertions.assertTrue(job.isFinished()); } @Test @@ -76,10 +76,10 @@ public void markCancelledStoresReason() { job.markRunning(); job.markCancelled("User requested cancellation"); - Assert.assertEquals(AccountJobStatus.CANCELLED, job.getStatus()); - Assert.assertEquals("User requested cancellation", job.getProgressMessage()); - Assert.assertNotNull(job.getFinishedAt()); - Assert.assertTrue(job.isFinished()); + Assertions.assertEquals(AccountJobStatus.CANCELLED, job.getStatus()); + Assertions.assertEquals("User requested cancellation", job.getProgressMessage()); + Assertions.assertNotNull(job.getFinishedAt()); + Assertions.assertTrue(job.isFinished()); } @Test @@ -87,20 +87,20 @@ public void updateProgressClampsTo0_100Range() { AccountMigrationJob job = new AccountMigrationJob(); job.updateProgress(MigrationProgress.of(-5L, 0L, "below zero", 0)); - Assert.assertEquals(0, job.getProgress()); + Assertions.assertEquals(0, job.getProgress()); job.updateProgress(MigrationProgress.of(130, 5, "above hundred", 0)); - Assert.assertEquals(100, job.getProgress()); + Assertions.assertEquals(100, job.getProgress()); job.updateProgress(MigrationProgress.of(42, 100, "normal", 0)); - Assert.assertEquals(42, job.getProgress()); - Assert.assertEquals("normal", job.getProgressMessage()); + Assertions.assertEquals(42, job.getProgress()); + Assertions.assertEquals("normal", job.getProgressMessage()); } @Test public void twoJobsHaveDifferentUuids() { AccountMigrationJob a = new AccountMigrationJob(); AccountMigrationJob b = new AccountMigrationJob(); - Assert.assertNotEquals(a.getUuid(), b.getUuid()); + Assertions.assertNotEquals(a.getUuid(), b.getUuid()); } } diff --git a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/CancellationTokenTest.java b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/CancellationTokenTest.java index a11cc3f9..cb3cda62 100644 --- a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/CancellationTokenTest.java +++ b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/CancellationTokenTest.java @@ -10,8 +10,8 @@ */ package tools.dynamia.modules.saas.migration; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import tools.dynamia.modules.saas.migration.api.CancellationToken; import java.util.concurrent.CountDownLatch; @@ -23,8 +23,8 @@ public class CancellationTokenTest { @Test public void newTokenIsNotCancelled() { CancellationToken token = CancellationToken.active(); - Assert.assertFalse(token.isCancelled()); - Assert.assertNull(token.getReason()); + Assertions.assertFalse(token.isCancelled()); + Assertions.assertNull(token.getReason()); } @Test @@ -32,8 +32,8 @@ public void cancelWithoutReasonUsesDefault() { CancellationToken token = CancellationToken.active(); token.cancel(); - Assert.assertTrue(token.isCancelled()); - Assert.assertNotNull(token.getReason()); + Assertions.assertTrue(token.isCancelled()); + Assertions.assertNotNull(token.getReason()); } @Test @@ -41,8 +41,8 @@ public void cancelWithReasonStoresReason() { CancellationToken token = CancellationToken.active(); token.cancel("Timeout exceeded"); - Assert.assertTrue(token.isCancelled()); - Assert.assertEquals("Timeout exceeded", token.getReason()); + Assertions.assertTrue(token.isCancelled()); + Assertions.assertEquals("Timeout exceeded", token.getReason()); } @Test @@ -51,8 +51,8 @@ public void cancelIsIdempotent() { token.cancel("first"); token.cancel("second"); - Assert.assertTrue(token.isCancelled()); - Assert.assertEquals("second", token.getReason()); + Assertions.assertTrue(token.isCancelled()); + Assertions.assertEquals("second", token.getReason()); } @Test @@ -70,6 +70,6 @@ public void cancelFromOtherThreadIsVisibleImmediately() throws InterruptedExcept seen.set(token.isCancelled()); t.join(1000); - Assert.assertTrue("Cancel from another thread must be visible", seen.get()); + Assertions.assertTrue(seen.get(), "Cancel from another thread must be visible"); } } diff --git a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/api/OptionsFluentBuilderTest.java b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/api/OptionsFluentBuilderTest.java index d6c5252e..ccef16d2 100644 --- a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/api/OptionsFluentBuilderTest.java +++ b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/api/OptionsFluentBuilderTest.java @@ -12,9 +12,9 @@ import tools.jackson.databind.ObjectMapper; import tools.jackson.databind.json.JsonMapper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests for the fluent builder APIs on options classes and their Jackson serialization @@ -24,7 +24,7 @@ public class OptionsFluentBuilderTest { private ObjectMapper objectMapper; - @Before + @BeforeEach public void setUp() { objectMapper = JsonMapper.builder() .build(); @@ -35,8 +35,8 @@ public void setUp() { @Test public void exportOptionsDefaults() { AccountExportOptions opts = new AccountExportOptions(); - Assert.assertEquals(AccountExportOptions.DEFAULT_CHUNK_SIZE, opts.getChunkSize()); - Assert.assertEquals(IdentityStrategy.KEEP_IDS, opts.getIdentityStrategy()); + Assertions.assertEquals(AccountExportOptions.DEFAULT_CHUNK_SIZE, opts.getChunkSize()); + Assertions.assertEquals(IdentityStrategy.KEEP_IDS, opts.getIdentityStrategy()); } @Test @@ -46,9 +46,9 @@ public void exportOptionsFluentBuilder() { .identityStrategy(IdentityStrategy.REGENERATE_IDS) .label("my-export"); - Assert.assertEquals(200, opts.getChunkSize()); - Assert.assertEquals(IdentityStrategy.REGENERATE_IDS, opts.getIdentityStrategy()); - Assert.assertEquals("my-export", opts.getLabel()); + Assertions.assertEquals(200, opts.getChunkSize()); + Assertions.assertEquals(IdentityStrategy.REGENERATE_IDS, opts.getIdentityStrategy()); + Assertions.assertEquals("my-export", opts.getLabel()); } @Test @@ -58,12 +58,12 @@ public void exportOptionsIsJsonSerializable() { .identityStrategy(IdentityStrategy.KEEP_IDS); String json = objectMapper.writeValueAsString(opts); - Assert.assertNotNull(json); - Assert.assertTrue(json.contains("chunkSize")); - Assert.assertTrue(json.contains("KEEP_IDS")); + Assertions.assertNotNull(json); + Assertions.assertTrue(json.contains("chunkSize")); + Assertions.assertTrue(json.contains("KEEP_IDS")); AccountExportOptions roundtrip = objectMapper.readValue(json, AccountExportOptions.class); - Assert.assertEquals(100, roundtrip.getChunkSize()); + Assertions.assertEquals(100, roundtrip.getChunkSize()); } // ─── AccountImportOptions ──────────────────────────────────────────────── @@ -71,10 +71,10 @@ public void exportOptionsIsJsonSerializable() { @Test public void importOptionsDefaults() { AccountImportOptions opts = new AccountImportOptions(); - Assert.assertNull(opts.getTargetAccountId()); - Assert.assertEquals(IdentityStrategy.REGENERATE_IDS, opts.getIdentityStrategy()); - Assert.assertEquals(AccountExportOptions.DEFAULT_CHUNK_SIZE, opts.getChunkSize()); - Assert.assertFalse(opts.isFailOnEntityError()); + Assertions.assertNull(opts.getTargetAccountId()); + Assertions.assertEquals(IdentityStrategy.REGENERATE_IDS, opts.getIdentityStrategy()); + Assertions.assertEquals(AccountExportOptions.DEFAULT_CHUNK_SIZE, opts.getChunkSize()); + Assertions.assertFalse(opts.isFailOnEntityError()); } @Test @@ -85,10 +85,10 @@ public void importOptionsFluentBuilder() { .chunkSize(250) .failOnEntityError(true); - Assert.assertEquals(42L, (long) opts.getTargetAccountId()); - Assert.assertEquals(IdentityStrategy.KEEP_IDS, opts.getIdentityStrategy()); - Assert.assertEquals(250, opts.getChunkSize()); - Assert.assertTrue(opts.isFailOnEntityError()); + Assertions.assertEquals(42L, (long) opts.getTargetAccountId()); + Assertions.assertEquals(IdentityStrategy.KEEP_IDS, opts.getIdentityStrategy()); + Assertions.assertEquals(250, opts.getChunkSize()); + Assertions.assertTrue(opts.isFailOnEntityError()); } @Test @@ -98,13 +98,13 @@ public void importOptionsIsJsonSerializable() throws Exception { .identityStrategy(IdentityStrategy.REGENERATE_IDS); String json = objectMapper.writeValueAsString(opts); - Assert.assertNotNull(json); - Assert.assertTrue(json.contains("targetAccountId")); - Assert.assertTrue(json.contains("REGENERATE_IDS")); + Assertions.assertNotNull(json); + Assertions.assertTrue(json.contains("targetAccountId")); + Assertions.assertTrue(json.contains("REGENERATE_IDS")); AccountImportOptions roundtrip = objectMapper.readValue(json, AccountImportOptions.class); if (roundtrip.getTargetAccountId() instanceof Number id) { - Assert.assertEquals(7L, id.longValue()); + Assertions.assertEquals(7L, id.longValue()); } } @@ -117,7 +117,7 @@ public void cloneOptionsIsJsonSerializable() throws Exception { opts.setTargetAccountId(2L); String json = objectMapper.writeValueAsString(opts); - Assert.assertNotNull(json); - Assert.assertTrue(json.contains("sourceAccountId") || json.contains("1")); + Assertions.assertNotNull(json); + Assertions.assertTrue(json.contains("sourceAccountId") || json.contains("1")); } } diff --git a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/config/AccountMigrationPropertiesTest.java b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/config/AccountMigrationPropertiesTest.java index 64dfb343..a6427e1b 100644 --- a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/config/AccountMigrationPropertiesTest.java +++ b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/config/AccountMigrationPropertiesTest.java @@ -10,8 +10,8 @@ */ package tools.dynamia.modules.saas.migration.config; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.concurrent.Semaphore; @@ -19,30 +19,30 @@ public class AccountMigrationPropertiesTest { @Test public void defaultChunkSizeIs500() { - Assert.assertEquals(500, new AccountMigrationProperties().getChunkSize()); + Assertions.assertEquals(500, new AccountMigrationProperties().getChunkSize()); } @Test public void defaultCompressionIsDisabled() { - Assert.assertFalse(new AccountMigrationProperties().isCompressionEnabled()); + Assertions.assertFalse(new AccountMigrationProperties().isCompressionEnabled()); } @Test public void defaultMaxConcurrentJobsIs5() { - Assert.assertEquals(5, new AccountMigrationProperties().getMaxConcurrentJobs()); + Assertions.assertEquals(5, new AccountMigrationProperties().getMaxConcurrentJobs()); } @Test public void defaultFailOnEntityErrorIsFalse() { - Assert.assertFalse(new AccountMigrationProperties().isFailOnEntityError()); + Assertions.assertFalse(new AccountMigrationProperties().isFailOnEntityError()); } @Test public void defaultOutputDirectoryContainsTmpdir() { String dir = new AccountMigrationProperties().getOutputDirectory(); - Assert.assertNotNull(dir); - Assert.assertTrue("outputDirectory should use system tmpdir", - dir.contains(System.getProperty("java.io.tmpdir").replace("\\", "/"))); + Assertions.assertNotNull(dir); + Assertions.assertTrue(dir.contains(System.getProperty("java.io.tmpdir").replace("\\", "/")), + "outputDirectory should use system tmpdir"); } @Test @@ -52,14 +52,14 @@ public void semaphoreInitializedFromMaxConcurrentJobs() { // Simulate the service constructor logic Semaphore semaphore = new Semaphore(Math.max(1, props.getMaxConcurrentJobs())); - Assert.assertEquals(3, semaphore.availablePermits()); + Assertions.assertEquals(3, semaphore.availablePermits()); } @Test public void semaphoreFloorIsOneEvenIfMaxIsZeroOrNegative() { // The service uses Math.max(1, maxConcurrentJobs) to avoid a 0-permit semaphore - Assert.assertEquals(1, Math.max(1, 0)); - Assert.assertEquals(1, Math.max(1, -5)); - Assert.assertEquals(2, Math.max(1, 2)); + Assertions.assertEquals(1, Math.max(1, 0)); + Assertions.assertEquals(1, Math.max(1, -5)); + Assertions.assertEquals(2, Math.max(1, 2)); } } diff --git a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/graph/EntityDependencyGraphTest.java b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/graph/EntityDependencyGraphTest.java index c8ef9e2d..ca6b11ef 100644 --- a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/graph/EntityDependencyGraphTest.java +++ b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/graph/EntityDependencyGraphTest.java @@ -15,12 +15,14 @@ import jakarta.persistence.metamodel.EntityType; import jakarta.persistence.metamodel.Metamodel; import jakarta.persistence.metamodel.SingularAttribute; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import java.util.List; import java.util.Set; @@ -43,7 +45,8 @@ * {@code Set>}. */ @SuppressWarnings({"unchecked", "rawtypes"}) -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) public class EntityDependencyGraphTest { // Marker classes used as stand-ins for real JPA entities @@ -65,7 +68,7 @@ static class OrderItem {} private EntityDependencyGraph graph; - @Before + @BeforeEach public void setUp() { accountType = mock(EntityType.class); categoryType = mock(EntityType.class); @@ -114,11 +117,11 @@ public void parentsAppearBeforeChildrenInOutput() { int idxOrder = sorted.indexOf(Order.class); int idxItem = sorted.indexOf(OrderItem.class); - Assert.assertTrue("Account before Order", idxAccount < idxOrder); - Assert.assertTrue("Account before OrderItem", idxAccount < idxItem); - Assert.assertTrue("Category before Product", idxCategory < idxProduct); - Assert.assertTrue("Order before OrderItem", idxOrder < idxItem); - Assert.assertTrue("Product before OrderItem", idxProduct < idxItem); + Assertions.assertTrue(idxAccount < idxOrder, "Account before Order"); + Assertions.assertTrue(idxAccount < idxItem, "Account before OrderItem"); + Assertions.assertTrue(idxCategory < idxProduct, "Category before Product"); + Assertions.assertTrue(idxOrder < idxItem, "Order before OrderItem"); + Assertions.assertTrue(idxProduct < idxItem, "Product before OrderItem"); } @Test @@ -127,25 +130,25 @@ public void allInputClassesArePresent() { Order.class, OrderItem.class); List> sorted = graph.topologicalSort(input); - Assert.assertEquals(input.size(), sorted.size()); - Assert.assertTrue(sorted.containsAll(input)); + Assertions.assertEquals(input.size(), sorted.size()); + Assertions.assertTrue(sorted.containsAll(input)); } @Test public void emptyInputReturnsEmptyList() { - Assert.assertTrue(graph.topologicalSort(List.of()).isEmpty()); + Assertions.assertTrue(graph.topologicalSort(List.of()).isEmpty()); } @Test public void nullInputReturnsEmptyList() { - Assert.assertTrue(graph.topologicalSort(null).isEmpty()); + Assertions.assertTrue(graph.topologicalSort(null).isEmpty()); } @Test public void singleEntityWithNoDepsIsReturnedAsIs() { List> sorted = graph.topologicalSort(List.of(Account.class)); - Assert.assertEquals(1, sorted.size()); - Assert.assertEquals(Account.class, sorted.get(0)); + Assertions.assertEquals(1, sorted.size()); + Assertions.assertEquals(Account.class, sorted.get(0)); } @Test @@ -154,8 +157,8 @@ public void oneToOneRelationAlsoCreatesEdge() { doReturn(Set.of(oneToOne)).when(productType).getSingularAttributes(); List> sorted = graph.topologicalSort(List.of(Account.class, Product.class)); - Assert.assertTrue("Account before Product (ONE_TO_ONE)", - sorted.indexOf(Account.class) < sorted.indexOf(Product.class)); + Assertions.assertTrue(sorted.indexOf(Account.class) < sorted.indexOf(Product.class), + "Account before Product (ONE_TO_ONE)"); } @Test @@ -166,9 +169,9 @@ public void basicAttributeDoesNotCreateDependencyEdge() { // Both are present, no ordering constraint — both orderings are valid List> sorted = graph.topologicalSort(List.of(Account.class, Category.class)); - Assert.assertEquals(2, sorted.size()); - Assert.assertTrue(sorted.contains(Account.class)); - Assert.assertTrue(sorted.contains(Category.class)); + Assertions.assertEquals(2, sorted.size()); + Assertions.assertTrue(sorted.contains(Account.class)); + Assertions.assertTrue(sorted.contains(Category.class)); } // ─── Helper ────────────────────────────────────────────────────────────── diff --git a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/identity/KeepIdsIdentityMapperTest.java b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/identity/KeepIdsIdentityMapperTest.java index a3b0fd77..b6aea4d8 100644 --- a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/identity/KeepIdsIdentityMapperTest.java +++ b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/identity/KeepIdsIdentityMapperTest.java @@ -10,9 +10,9 @@ */ package tools.dynamia.modules.saas.migration.identity; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import tools.dynamia.modules.saas.migration.api.IdentityStrategy; import java.util.HashMap; @@ -22,25 +22,25 @@ public class KeepIdsIdentityMapperTest { private KeepIdsIdentityMapper mapper; - @Before + @BeforeEach public void setUp() { mapper = new KeepIdsIdentityMapper(); } @Test public void strategyIsKeepIds() { - Assert.assertEquals(IdentityStrategy.KEEP_IDS, mapper.getStrategy()); + Assertions.assertEquals(IdentityStrategy.KEEP_IDS, mapper.getStrategy()); } @Test public void mapIdReturnsOriginalId() { - Assert.assertEquals(42L, mapper.mapId(42L, String.class)); - Assert.assertEquals("uuid-123", mapper.mapId("uuid-123", Object.class)); + Assertions.assertEquals(42L, mapper.mapId(42L, String.class)); + Assertions.assertEquals("uuid-123", mapper.mapId("uuid-123", Object.class)); } @Test public void mapIdWithNullReturnsNull() { - Assert.assertNull(mapper.mapId(null, String.class)); + Assertions.assertNull(mapper.mapId(null, String.class)); } @Test @@ -50,11 +50,11 @@ public void resolveReferenceIdReturnsOriginalRefIdIgnoringMap() { // KEEP_IDS: the ref ID from the file is the correct ID in the target DB Object resolved = mapper.resolveReferenceId(1L, String.class, idMappings); - Assert.assertEquals(1L, resolved); + Assertions.assertEquals(1L, resolved); } @Test public void resolveReferenceIdWithNullRefIdReturnsNull() { - Assert.assertNull(mapper.resolveReferenceId(null, String.class, new HashMap<>())); + Assertions.assertNull(mapper.resolveReferenceId(null, String.class, new HashMap<>())); } } diff --git a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/identity/RegenerateIdsIdentityMapperTest.java b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/identity/RegenerateIdsIdentityMapperTest.java index 10703838..e28a2c0c 100644 --- a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/identity/RegenerateIdsIdentityMapperTest.java +++ b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/identity/RegenerateIdsIdentityMapperTest.java @@ -10,9 +10,9 @@ */ package tools.dynamia.modules.saas.migration.identity; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import tools.dynamia.modules.saas.migration.api.IdentityStrategy; import java.util.HashMap; @@ -22,21 +22,21 @@ public class RegenerateIdsIdentityMapperTest { private RegenerateIdsIdentityMapper mapper; - @Before + @BeforeEach public void setUp() { mapper = new RegenerateIdsIdentityMapper(); } @Test public void strategyIsRegenerateIds() { - Assert.assertEquals(IdentityStrategy.REGENERATE_IDS, mapper.getStrategy()); + Assertions.assertEquals(IdentityStrategy.REGENERATE_IDS, mapper.getStrategy()); } @Test public void mapIdAlwaysReturnsNull() { - Assert.assertNull(mapper.mapId(1L, String.class)); - Assert.assertNull(mapper.mapId(99999L, Object.class)); - Assert.assertNull(mapper.mapId(null, String.class)); + Assertions.assertNull(mapper.mapId(1L, String.class)); + Assertions.assertNull(mapper.mapId(99999L, Object.class)); + Assertions.assertNull(mapper.mapId(null, String.class)); } @Test @@ -45,7 +45,7 @@ public void resolveReferenceIdLookupsFromIdMappings() { idMappings.put(String.class.getName(), Map.of(10L, 501L)); Object resolved = mapper.resolveReferenceId(10L, String.class, idMappings); - Assert.assertEquals(501L, resolved); + Assertions.assertEquals(501L, resolved); } @Test @@ -54,12 +54,12 @@ public void resolveReferenceIdFallsBackToOriginalWhenNotMapped() { Map> idMappings = new HashMap<>(); Object resolved = mapper.resolveReferenceId(77L, String.class, idMappings); - Assert.assertEquals(77L, resolved); + Assertions.assertEquals(77L, resolved); } @Test public void resolveReferenceIdWithNullRefIdReturnsNull() { - Assert.assertNull(mapper.resolveReferenceId(null, String.class, new HashMap<>())); + Assertions.assertNull(mapper.resolveReferenceId(null, String.class, new HashMap<>())); } @Test @@ -72,6 +72,6 @@ public void resolveReferenceIdFallsBackWhenClassKeyExistsButIdMissing() { // originalRefId=99 not in classMap → fallback to original Object resolved = mapper.resolveReferenceId(99L, String.class, idMappings); - Assert.assertEquals(99L, resolved); + Assertions.assertEquals(99L, resolved); } } diff --git a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/identity/Uuid7IdentityMapperTest.java b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/identity/Uuid7IdentityMapperTest.java index d03acf58..b07b8dcc 100644 --- a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/identity/Uuid7IdentityMapperTest.java +++ b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/identity/Uuid7IdentityMapperTest.java @@ -10,9 +10,9 @@ */ package tools.dynamia.modules.saas.migration.identity; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import tools.dynamia.modules.saas.migration.api.IdentityStrategy; import java.util.HashMap; @@ -23,35 +23,35 @@ public class Uuid7IdentityMapperTest { private Uuid7IdentityMapper mapper; - @Before + @BeforeEach public void setUp() { mapper = new Uuid7IdentityMapper(); } @Test public void strategyIsUuid7() { - Assert.assertEquals(IdentityStrategy.UUID7, mapper.getStrategy()); + Assertions.assertEquals(IdentityStrategy.UUID7, mapper.getStrategy()); } @Test public void mapIdReturnsUuid() { Object id = mapper.mapId(1L, Object.class); - Assert.assertNotNull(id); - Assert.assertTrue(id instanceof UUID); + Assertions.assertNotNull(id); + Assertions.assertTrue(id instanceof UUID); } @Test public void mapIdReturnsDistinctValuesEachCall() { UUID a = (UUID) mapper.mapId(1L, Object.class); UUID b = (UUID) mapper.mapId(1L, Object.class); - Assert.assertNotEquals(a, b); + Assertions.assertNotEquals(a, b); } @Test public void mapIdIgnoresOriginalId() { // UUID7 strategy always generates a new ID regardless of the original - Assert.assertNotEquals(mapper.mapId(42L, Object.class), 42L); - Assert.assertNotNull(mapper.mapId(null, Object.class)); + Assertions.assertNotEquals(mapper.mapId(42L, Object.class), 42L); + Assertions.assertNotNull(mapper.mapId(null, Object.class)); } @Test @@ -61,19 +61,19 @@ public void resolveReferenceIdLookupsFromIdMappings() { idMappings.put(String.class.getName(), Map.of(10L, newId)); Object resolved = mapper.resolveReferenceId(10L, String.class, idMappings); - Assert.assertEquals(newId, resolved); + Assertions.assertEquals(newId, resolved); } @Test public void resolveReferenceIdFallsBackToOriginalWhenNotMapped() { Map> idMappings = new HashMap<>(); Object resolved = mapper.resolveReferenceId(77L, String.class, idMappings); - Assert.assertEquals(77L, resolved); + Assertions.assertEquals(77L, resolved); } @Test public void resolveReferenceIdWithNullReturnsNull() { - Assert.assertNull(mapper.resolveReferenceId(null, String.class, new HashMap<>())); + Assertions.assertNull(mapper.resolveReferenceId(null, String.class, new HashMap<>())); } // ── UUIDv7 structure tests ───────────────────────────────────────────────── @@ -81,13 +81,13 @@ public void resolveReferenceIdWithNullReturnsNull() { @Test public void generatedUuidHasVersion7() { UUID uuid = Uuid7IdentityMapper.generateUuid7(); - Assert.assertEquals(7, uuid.version()); + Assertions.assertEquals(7, uuid.version()); } @Test public void generatedUuidHasVariant2() { UUID uuid = Uuid7IdentityMapper.generateUuid7(); - Assert.assertEquals(2, uuid.variant()); + Assertions.assertEquals(2, uuid.variant()); } @Test @@ -96,7 +96,7 @@ public void generatedUuidsAreTimeOrdered() throws InterruptedException { Thread.sleep(2); UUID b = Uuid7IdentityMapper.generateUuid7(); // Higher timestamp → higher MSB → natural UUID ordering matches time order - Assert.assertTrue(a.getMostSignificantBits() < b.getMostSignificantBits() + Assertions.assertTrue(a.getMostSignificantBits() < b.getMostSignificantBits() || a.compareTo(b) < 0); } } diff --git a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/pipeline/ExportConstantsTest.java b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/pipeline/ExportConstantsTest.java index cb8131e2..2fe50087 100644 --- a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/pipeline/ExportConstantsTest.java +++ b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/pipeline/ExportConstantsTest.java @@ -12,8 +12,8 @@ import tools.jackson.databind.JsonNode; import tools.jackson.databind.ObjectMapper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -30,37 +30,37 @@ public class ExportConstantsTest { @Test public void formatVersionIsThree() { - Assert.assertEquals("3", ExportConstants.FORMAT_VERSION); + Assertions.assertEquals("3", ExportConstants.FORMAT_VERSION); } @Test public void refIdSuffixIsUnderscoredRefId() { - Assert.assertEquals("_ref_id", ExportConstants.REF_ID_SUFFIX); + Assertions.assertEquals("_ref_id", ExportConstants.REF_ID_SUFFIX); } @Test public void fieldNamesMatchArchitectureSpec() { - Assert.assertEquals("version", ExportConstants.FIELD_VERSION); - Assert.assertEquals("exportedAt", ExportConstants.FIELD_EXPORTED_AT); - Assert.assertEquals("sourceAccountId", ExportConstants.FIELD_SOURCE_ACCOUNT_ID); - Assert.assertEquals("identityStrategy", ExportConstants.FIELD_IDENTITY_STRATEGY); - Assert.assertEquals("account", ExportConstants.FIELD_ACCOUNT); - Assert.assertEquals("entities", ExportConstants.FIELD_ENTITIES); - Assert.assertEquals("fields", ExportConstants.FIELD_FIELDS); - Assert.assertEquals("rows", ExportConstants.FIELD_ROWS); + Assertions.assertEquals("version", ExportConstants.FIELD_VERSION); + Assertions.assertEquals("exportedAt", ExportConstants.FIELD_EXPORTED_AT); + Assertions.assertEquals("sourceAccountId", ExportConstants.FIELD_SOURCE_ACCOUNT_ID); + Assertions.assertEquals("identityStrategy", ExportConstants.FIELD_IDENTITY_STRATEGY); + Assertions.assertEquals("account", ExportConstants.FIELD_ACCOUNT); + Assertions.assertEquals("entities", ExportConstants.FIELD_ENTITIES); + Assertions.assertEquals("fields", ExportConstants.FIELD_FIELDS); + Assertions.assertEquals("rows", ExportConstants.FIELD_ROWS); } @Test public void v3ConstantsAreCorrect() { - Assert.assertEquals("manifest.json", ExportConstants.MANIFEST_FILE); - Assert.assertEquals("entityClass", ExportConstants.FIELD_ENTITY_CLASS); - Assert.assertEquals("file", ExportConstants.MANIFEST_ENTITY_FILE); + Assertions.assertEquals("manifest.json", ExportConstants.MANIFEST_FILE); + Assertions.assertEquals("entityClass", ExportConstants.FIELD_ENTITY_CLASS); + Assertions.assertEquals("file", ExportConstants.MANIFEST_ENTITY_FILE); } @Test public void refIdSuffixProducesCorrectFieldName() { String refField = "category" + ExportConstants.REF_ID_SUFFIX; - Assert.assertEquals("category_ref_id", refField); + Assertions.assertEquals("category_ref_id", refField); } @Test @@ -89,16 +89,16 @@ public void manifestJsonStructureIsValid() throws IOException { gen.close(); JsonNode root = mapper.readTree(out.toByteArray()); - Assert.assertEquals("3", root.get(ExportConstants.FIELD_VERSION).asText()); - Assert.assertEquals(42L, root.get(ExportConstants.FIELD_SOURCE_ACCOUNT_ID).asLong()); - Assert.assertEquals("KEEP_IDS", root.get(ExportConstants.FIELD_IDENTITY_STRATEGY).asText()); - Assert.assertTrue(root.has(ExportConstants.FIELD_ACCOUNT)); - Assert.assertTrue(root.get(ExportConstants.FIELD_ENTITIES).isArray()); - Assert.assertEquals(1, root.get(ExportConstants.FIELD_ENTITIES).size()); + Assertions.assertEquals("3", root.get(ExportConstants.FIELD_VERSION).asText()); + Assertions.assertEquals(42L, root.get(ExportConstants.FIELD_SOURCE_ACCOUNT_ID).asLong()); + Assertions.assertEquals("KEEP_IDS", root.get(ExportConstants.FIELD_IDENTITY_STRATEGY).asText()); + Assertions.assertTrue(root.has(ExportConstants.FIELD_ACCOUNT)); + Assertions.assertTrue(root.get(ExportConstants.FIELD_ENTITIES).isArray()); + Assertions.assertEquals(1, root.get(ExportConstants.FIELD_ENTITIES).size()); JsonNode entry = root.get(ExportConstants.FIELD_ENTITIES).get(0); - Assert.assertEquals("Account42_Customer.json", entry.get(ExportConstants.MANIFEST_ENTITY_FILE).asText()); - Assert.assertEquals("com.example.Customer", entry.get(ExportConstants.FIELD_ENTITY_CLASS).asText()); + Assertions.assertEquals("Account42_Customer.json", entry.get(ExportConstants.MANIFEST_ENTITY_FILE).asText()); + Assertions.assertEquals("com.example.Customer", entry.get(ExportConstants.FIELD_ENTITY_CLASS).asText()); } @Test @@ -128,11 +128,11 @@ public void entityFileJsonStructureIsValid() throws IOException { gen.close(); JsonNode root = mapper.readTree(out.toByteArray()); - Assert.assertEquals("com.example.Customer", root.get(ExportConstants.FIELD_ENTITY_CLASS).asText()); - Assert.assertTrue(root.get(ExportConstants.FIELD_FIELDS).isArray()); - Assert.assertEquals(3, root.get(ExportConstants.FIELD_FIELDS).size()); - Assert.assertTrue(root.get(ExportConstants.FIELD_ROWS).isArray()); - Assert.assertEquals(1, root.get(ExportConstants.FIELD_ROWS).size()); + Assertions.assertEquals("com.example.Customer", root.get(ExportConstants.FIELD_ENTITY_CLASS).asText()); + Assertions.assertTrue(root.get(ExportConstants.FIELD_FIELDS).isArray()); + Assertions.assertEquals(3, root.get(ExportConstants.FIELD_FIELDS).size()); + Assertions.assertTrue(root.get(ExportConstants.FIELD_ROWS).isArray()); + Assertions.assertEquals(1, root.get(ExportConstants.FIELD_ROWS).size()); } @Test @@ -151,7 +151,7 @@ public void zipContainsManifestAsFirstEntry() throws IOException { ZipInputStream zipIn = new ZipInputStream(new ByteArrayInputStream(buf.toByteArray())); ZipEntry first = zipIn.getNextEntry(); - Assert.assertNotNull(first); - Assert.assertEquals(ExportConstants.MANIFEST_FILE, first.getName()); + Assertions.assertNotNull(first); + Assertions.assertEquals(ExportConstants.MANIFEST_FILE, first.getName()); } } diff --git a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/pipeline/GzipStreamTest.java b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/pipeline/GzipStreamTest.java index c91852ff..9cb5eb0e 100644 --- a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/pipeline/GzipStreamTest.java +++ b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/pipeline/GzipStreamTest.java @@ -10,8 +10,8 @@ */ package tools.dynamia.modules.saas.migration.pipeline; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; @@ -35,20 +35,20 @@ public class GzipStreamTest { public void bufferedInputStreamSupportsMark() { var raw = new ByteArrayInputStream(new byte[]{1, 2, 3}); var buffered = new BufferedInputStream(raw); - Assert.assertTrue("BufferedInputStream must support mark()", buffered.markSupported()); + Assertions.assertTrue(buffered.markSupported(), "BufferedInputStream must support mark()"); } @Test public void byteArrayInputStreamSupportsMark() { var bais = new ByteArrayInputStream(new byte[]{1, 2, 3}); - Assert.assertTrue(bais.markSupported()); + Assertions.assertTrue(bais.markSupported()); } @Test public void zipMagicBytesAreDetectable() throws IOException { byte[] zipData = zip("manifest.json", "{}"); - Assert.assertEquals("ZIP magic byte 0", 0x50, zipData[0] & 0xFF); - Assert.assertEquals("ZIP magic byte 1", 0x4B, zipData[1] & 0xFF); + Assertions.assertEquals(0x50, zipData[0] & 0xFF, "ZIP magic byte 0"); + Assertions.assertEquals(0x4B, zipData[1] & 0xFF, "ZIP magic byte 1"); } @Test @@ -61,14 +61,14 @@ public void bufferedStreamPreservesZipAfterMagicPeek() throws IOException { int b2 = in.read(); in.reset(); - Assert.assertEquals(0x50, b1 & 0xFF); - Assert.assertEquals(0x4B, b2 & 0xFF); + Assertions.assertEquals(0x50, b1 & 0xFF); + Assertions.assertEquals(0x4B, b2 & 0xFF); // After reset the full ZIP is still readable ZipInputStream zipIn = new ZipInputStream(in); ZipEntry entry = zipIn.getNextEntry(); - Assert.assertNotNull("Entry must exist after reset", entry); - Assert.assertEquals("manifest.json", entry.getName()); + Assertions.assertNotNull(entry, "Entry must exist after reset"); + Assertions.assertEquals("manifest.json", entry.getName()); } @Test @@ -76,10 +76,10 @@ public void zipEntriesAreReadInInsertionOrder() throws IOException { byte[] zipData = zip3("manifest.json", "{}", "Account1_Customer.json", "[]", "Account1_Order.json", "[]"); ZipInputStream zipIn = new ZipInputStream(new ByteArrayInputStream(zipData)); - Assert.assertEquals("manifest.json", zipIn.getNextEntry().getName()); - Assert.assertEquals("Account1_Customer.json", zipIn.getNextEntry().getName()); - Assert.assertEquals("Account1_Order.json", zipIn.getNextEntry().getName()); - Assert.assertNull("No more entries", zipIn.getNextEntry()); + Assertions.assertEquals("manifest.json", zipIn.getNextEntry().getName()); + Assertions.assertEquals("Account1_Customer.json", zipIn.getNextEntry().getName()); + Assertions.assertEquals("Account1_Order.json", zipIn.getNextEntry().getName()); + Assertions.assertNull(zipIn.getNextEntry(), "No more entries"); } @Test @@ -98,10 +98,10 @@ public void zipEntryReportsEofAtEntryBoundary() throws IOException { ZipInputStream zipIn = new ZipInputStream(new ByteArrayInputStream(buf.toByteArray())); zipIn.getNextEntry(); byte[] read = zipIn.readAllBytes(); // reads only "a.json" content - Assert.assertArrayEquals("entry content", content, read); + Assertions.assertArrayEquals(content, read, "entry content"); // second entry is still accessible - Assert.assertNotNull("b.json must follow", zipIn.getNextEntry()); + Assertions.assertNotNull(zipIn.getNextEntry(), "b.json must follow"); } // ─── Helpers ───────────────────────────────────────────────────────────── diff --git a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/pipeline/ImportPipelineMapperResolutionTest.java b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/pipeline/ImportPipelineMapperResolutionTest.java index ffb137a7..f17d4e5c 100644 --- a/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/pipeline/ImportPipelineMapperResolutionTest.java +++ b/extensions/saas/sources/migration/src/test/java/tools/dynamia/modules/saas/migration/pipeline/ImportPipelineMapperResolutionTest.java @@ -13,12 +13,14 @@ import tools.jackson.databind.ObjectMapper; import tools.jackson.databind.json.JsonMapper; import jakarta.persistence.EntityManagerFactory; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import tools.dynamia.modules.saas.migration.api.AccountImportOptions; import tools.dynamia.modules.saas.migration.api.IdentityMapper; import tools.dynamia.modules.saas.migration.api.IdentityStrategy; @@ -50,7 +52,8 @@ * {@code importTenant} with a minimal valid ZIP stream (manifest only, no entities) * and observing behaviour. */ -@RunWith(MockitoJUnitRunner.Silent.class) +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) public class ImportPipelineMapperResolutionTest { @Mock private EntityManagerFactory emf; @@ -58,7 +61,7 @@ public class ImportPipelineMapperResolutionTest { private AccountMigrationProperties properties; private ObjectMapper objectMapper; - @Before + @BeforeEach public void setUp() { properties = new AccountMigrationProperties(); objectMapper = JsonMapper.builder() diff --git a/extensions/saas/sources/ui/pom.xml b/extensions/saas/sources/ui/pom.xml index 80361797..961ebfd9 100644 --- a/extensions/saas/sources/ui/pom.xml +++ b/extensions/saas/sources/ui/pom.xml @@ -47,8 +47,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/extensions/security/sources/pom.xml b/extensions/security/sources/pom.xml index 8e801707..2fe4a9bd 100644 --- a/extensions/security/sources/pom.xml +++ b/extensions/security/sources/pom.xml @@ -82,8 +82,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/platform/app/src/test/java/tools/dynamia/app/ApplicationInfoTest.java b/platform/app/src/test/java/tools/dynamia/app/ApplicationInfoTest.java index 6c08896f..7a0e5abf 100644 --- a/platform/app/src/test/java/tools/dynamia/app/ApplicationInfoTest.java +++ b/platform/app/src/test/java/tools/dynamia/app/ApplicationInfoTest.java @@ -16,11 +16,11 @@ */ package tools.dynamia.app; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Properties; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ApplicationInfoTest { diff --git a/platform/app/src/test/java/tools/dynamia/app/VelocityTemplateEngineTest.java b/platform/app/src/test/java/tools/dynamia/app/VelocityTemplateEngineTest.java index 21176944..0567ffac 100644 --- a/platform/app/src/test/java/tools/dynamia/app/VelocityTemplateEngineTest.java +++ b/platform/app/src/test/java/tools/dynamia/app/VelocityTemplateEngineTest.java @@ -16,8 +16,8 @@ */ package tools.dynamia.app; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import tools.dynamia.templates.TemplateEngine; import java.util.HashMap; @@ -36,7 +36,7 @@ public void initVelocityTemplate() { Map params = new HashMap<>(); params.put("nombre", "Juan"); Object obj = templateEngine.evaluate("Hola ${nombre}", params); - Assert.assertEquals("Hola Juan", obj); + Assertions.assertEquals("Hola Juan", obj); } } diff --git a/platform/app/src/test/java/tools/dynamia/app/crud/CrudServiceRestTest.java b/platform/app/src/test/java/tools/dynamia/app/crud/CrudServiceRestTest.java index 71bcc5c7..c1345d82 100644 --- a/platform/app/src/test/java/tools/dynamia/app/crud/CrudServiceRestTest.java +++ b/platform/app/src/test/java/tools/dynamia/app/crud/CrudServiceRestTest.java @@ -1,13 +1,10 @@ package tools.dynamia.app.crud; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; import tools.dynamia.domain.services.CrudService; -@RunWith(SpringRunner.class) @SpringBootTest(classes = CrudTestConfiguration.class) public class CrudServiceRestTest { diff --git a/platform/app/src/test/java/tools/dynamia/app/crud/CrudTestConfiguration.java b/platform/app/src/test/java/tools/dynamia/app/crud/CrudTestConfiguration.java index f97d67c1..edce0423 100644 --- a/platform/app/src/test/java/tools/dynamia/app/crud/CrudTestConfiguration.java +++ b/platform/app/src/test/java/tools/dynamia/app/crud/CrudTestConfiguration.java @@ -41,7 +41,7 @@ public PlatformTransactionManager transactionManager() { @Bean public EntityManagerFactory entityManagerFactory() { var emf = new LocalContainerEntityManagerFactoryBean(); - emf.setPackagesToScan("tools.dynamia.domain.jpa"); + emf.setPackagesToScan("tools.dynamia.domain.jpa", "tools.dynamia.app.crud"); emf.setDataSource(dataSource()); diff --git a/platform/core/actions/src/test/java/tools/dynamia/actions/ActionCommandTest.java b/platform/core/actions/src/test/java/tools/dynamia/actions/ActionCommandTest.java index c92be204..11d725c3 100644 --- a/platform/core/actions/src/test/java/tools/dynamia/actions/ActionCommandTest.java +++ b/platform/core/actions/src/test/java/tools/dynamia/actions/ActionCommandTest.java @@ -16,8 +16,8 @@ */ package tools.dynamia.actions; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.List; @@ -33,7 +33,7 @@ public void testSimpleActionCommand() { List actions = ActionLoader.loadActionCommands(form); for (Action action : actions) { - Assert.assertTrue(action instanceof FastAction); + Assertions.assertTrue(action instanceof FastAction); if (action.getName().equals("sum")) { FastAction fastAction = (FastAction) action; @@ -41,7 +41,7 @@ public void testSimpleActionCommand() { } } - Assert.assertEquals(expectedResult, form.getR()); + Assertions.assertEquals(expectedResult, form.getR()); } @@ -55,17 +55,17 @@ public void testComplexActionCommand() { List actions = ActionLoader.loadActionCommands(form); for (Action action : actions) { - Assert.assertTrue(action instanceof FastAction); + Assertions.assertTrue(action instanceof FastAction); if (action.getName().equals("Subtract")) { FastAction fastAction = (FastAction) action; - Assert.assertEquals("minus", fastAction.getImage()); - Assert.assertNull(fastAction.getRenderer()); + Assertions.assertEquals("minus", fastAction.getImage()); + Assertions.assertNull(fastAction.getRenderer()); fastAction.execute(); } } - Assert.assertEquals(expectedResult, form.getR()); + Assertions.assertEquals(expectedResult, form.getR()); } diff --git a/platform/core/actions/src/test/java/tools/dynamia/actions/FastActionTest.java b/platform/core/actions/src/test/java/tools/dynamia/actions/FastActionTest.java index 618e4a62..5b5fe974 100644 --- a/platform/core/actions/src/test/java/tools/dynamia/actions/FastActionTest.java +++ b/platform/core/actions/src/test/java/tools/dynamia/actions/FastActionTest.java @@ -16,8 +16,8 @@ */ package tools.dynamia.actions; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class FastActionTest { @@ -30,7 +30,7 @@ public void executeFastAction() { FastAction changeResultAction = new FastAction("ChangeResult", evt -> result = 1); changeResultAction.execute(); - Assert.assertEquals(expected, result); + Assertions.assertEquals(expected, result); } } diff --git a/platform/core/commons/src/test/java/tools/dynamia/commons/AliasBeanMapperTest.java b/platform/core/commons/src/test/java/tools/dynamia/commons/AliasBeanMapperTest.java index 787d2a15..52d4f949 100644 --- a/platform/core/commons/src/test/java/tools/dynamia/commons/AliasBeanMapperTest.java +++ b/platform/core/commons/src/test/java/tools/dynamia/commons/AliasBeanMapperTest.java @@ -2,8 +2,8 @@ import my.company.Product; import my.company.Producto; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class AliasBeanMapperTest { @@ -14,8 +14,8 @@ public void shouldMapAnnotatedToUnannotated() { AliasBeanMapper.map(producto, product, null); - Assert.assertEquals("Laptop", product.getName()); - Assert.assertEquals(1500.0, product.getPrice(), 0.0); - Assert.assertEquals("LPT001", product.getSku()); + Assertions.assertEquals("Laptop", product.getName()); + Assertions.assertEquals(1500.0, product.getPrice(), 0.0); + Assertions.assertEquals("LPT001", product.getSku()); } } diff --git a/platform/core/commons/src/test/java/tools/dynamia/commons/AliasResolverTest.java b/platform/core/commons/src/test/java/tools/dynamia/commons/AliasResolverTest.java index c49f27ca..1b505067 100644 --- a/platform/core/commons/src/test/java/tools/dynamia/commons/AliasResolverTest.java +++ b/platform/core/commons/src/test/java/tools/dynamia/commons/AliasResolverTest.java @@ -2,8 +2,8 @@ import my.company.Dummy; import my.company.PlainDummy; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class AliasResolverTest { @@ -12,36 +12,36 @@ public void shouldResolveFieldAlias() { Dummy dummy = new Dummy(); var nameAlias = AliasResolver.getFieldAlias(dummy.getClass(), "name"); - Assert.assertNotNull(nameAlias); + Assertions.assertNotNull(nameAlias); - Assert.assertEquals("nombre", nameAlias.value()[0]); + Assertions.assertEquals("nombre", nameAlias.value()[0]); } @Test public void shouldResolveClassAlias() { String alias = AliasResolver.resolve(Dummy.class, "test"); - Assert.assertEquals("dummy_entity", alias); + Assertions.assertEquals("dummy_entity", alias); } @Test public void shouldResolveClassAliasDefaultScope() { // Even if scope is "test", it falls back to it if no other match String alias = AliasResolver.resolve(Dummy.class); - Assert.assertEquals("dummy_entity", alias); + Assertions.assertEquals("dummy_entity", alias); } @Test public void shouldResolveFieldAliasWithLocale() throws NoSuchFieldException { var field = Dummy.class.getDeclaredField("age"); String alias = AliasResolver.resolve(field, "default", "es"); - Assert.assertEquals("edad", alias); + Assertions.assertEquals("edad", alias); } @Test public void shouldResolveFieldAliasWithScope() throws NoSuchFieldException { var field = Dummy.class.getDeclaredField("age"); String alias = AliasResolver.resolve(field, "dto", ""); - Assert.assertEquals("dummy_age", alias); + Assertions.assertEquals("dummy_age", alias); } @Test @@ -50,25 +50,25 @@ public void shouldResolveFieldAliasFallback() throws NoSuchFieldException { // No match for locale "en" and scope "default", so it falls back to all aliases // "edad" is first in the list String alias = AliasResolver.resolve(field, "default", "en"); - Assert.assertEquals("edad", alias); + Assertions.assertEquals("edad", alias); } @Test public void shouldResolveClassAliasForUnannotatedClass() { String alias = AliasResolver.resolve(PlainDummy.class); - Assert.assertEquals("PlainDummy", alias); + Assertions.assertEquals("PlainDummy", alias); } @Test public void shouldResolveFieldAliasForUnannotatedField() throws NoSuchFieldException { var field = PlainDummy.class.getDeclaredField("description"); String alias = AliasResolver.resolve(field, "default", ""); - Assert.assertEquals("description", alias); + Assertions.assertEquals("description", alias); } @Test public void shouldResolveClassAliasForUnannotatedClassWithScope() { String alias = AliasResolver.resolve(PlainDummy.class, "someScope"); - Assert.assertEquals("PlainDummy", alias); + Assertions.assertEquals("PlainDummy", alias); } } diff --git a/platform/core/commons/src/test/java/tools/dynamia/commons/BeanMessagesTest.java b/platform/core/commons/src/test/java/tools/dynamia/commons/BeanMessagesTest.java index 9e6e3139..9640cc44 100644 --- a/platform/core/commons/src/test/java/tools/dynamia/commons/BeanMessagesTest.java +++ b/platform/core/commons/src/test/java/tools/dynamia/commons/BeanMessagesTest.java @@ -18,8 +18,8 @@ import my.company.ChildDummy; import my.company.Dummy; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import tools.dynamia.commons.reflect.PropertyInfo; import java.util.List; @@ -31,15 +31,15 @@ public class BeanMessagesTest { @Test public void testCanFindBundles() { ResourceBundle bundle = ResourceBundle.getBundle(Dummy.class.getName()); - Assert.assertNotNull(bundle); + Assertions.assertNotNull(bundle); } @Test public void testAllProperties() { BeanMessages msg = new BeanMessages(Dummy.class, Locale.of("es")); - Assert.assertEquals("El idiota", msg.getLocalizedName()); - Assert.assertEquals("nombrecito", msg.getMessage("name")); - Assert.assertEquals("edad", msg.getMessage("age")); + Assertions.assertEquals("El idiota", msg.getLocalizedName()); + Assertions.assertEquals("nombrecito", msg.getMessage("name")); + Assertions.assertEquals("edad", msg.getMessage("age")); } @@ -51,6 +51,6 @@ public void testChild() { for (PropertyInfo propertyInfo : info) { System.out.println(propertyInfo); } - Assert.assertEquals("El idiota hijo", msg.getLocalizedName()); + Assertions.assertEquals("El idiota hijo", msg.getLocalizedName()); } } diff --git a/platform/core/commons/src/test/java/tools/dynamia/commons/BigDecimalUtilsTest.java b/platform/core/commons/src/test/java/tools/dynamia/commons/BigDecimalUtilsTest.java index d35dacb9..3facbc95 100644 --- a/platform/core/commons/src/test/java/tools/dynamia/commons/BigDecimalUtilsTest.java +++ b/platform/core/commons/src/test/java/tools/dynamia/commons/BigDecimalUtilsTest.java @@ -17,13 +17,13 @@ package tools.dynamia.commons; import my.company.Dummy; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class BigDecimalUtilsTest { diff --git a/platform/core/commons/src/test/java/tools/dynamia/commons/CollectionsUtilsTest.java b/platform/core/commons/src/test/java/tools/dynamia/commons/CollectionsUtilsTest.java index 37897fd6..cef6e7ef 100644 --- a/platform/core/commons/src/test/java/tools/dynamia/commons/CollectionsUtilsTest.java +++ b/platform/core/commons/src/test/java/tools/dynamia/commons/CollectionsUtilsTest.java @@ -16,7 +16,7 @@ */ package tools.dynamia.commons; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; import tools.dynamia.commons.collect.CollectionWrapper; import tools.dynamia.commons.collect.CollectionsUtils; @@ -24,12 +24,15 @@ import java.util.Collection; import java.util.HashSet; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * * @author Mario A. Serrano Leones */ -public class CollectionsUtilsTest extends TestCase { +public class CollectionsUtilsTest { + @Test public void testCollectionGroup() { Collection data = new ArrayList<>(); for (int i = 0; i < 75; i++) { diff --git a/platform/core/commons/src/test/java/tools/dynamia/commons/DateTimeUtilsTest.java b/platform/core/commons/src/test/java/tools/dynamia/commons/DateTimeUtilsTest.java index c0443b2b..0db88929 100644 --- a/platform/core/commons/src/test/java/tools/dynamia/commons/DateTimeUtilsTest.java +++ b/platform/core/commons/src/test/java/tools/dynamia/commons/DateTimeUtilsTest.java @@ -17,11 +17,11 @@ package tools.dynamia.commons; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Date; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static tools.dynamia.commons.DateTimeUtils.addDays; import static tools.dynamia.commons.DateTimeUtils.addMonths; import static tools.dynamia.commons.DateTimeUtils.addYears; diff --git a/platform/core/commons/src/test/java/tools/dynamia/commons/FormattersTest.java b/platform/core/commons/src/test/java/tools/dynamia/commons/FormattersTest.java index 970b654b..15c8cd6b 100644 --- a/platform/core/commons/src/test/java/tools/dynamia/commons/FormattersTest.java +++ b/platform/core/commons/src/test/java/tools/dynamia/commons/FormattersTest.java @@ -1,7 +1,7 @@ package tools.dynamia.commons; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -12,13 +12,13 @@ import java.util.Locale; import java.util.TimeZone; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class FormattersTest { - @Before + @BeforeEach public void setUp() throws Exception { Locale.setDefault(Locale.US); TimeZone.setDefault(TimeZone.getTimeZone("UTC")); diff --git a/platform/core/commons/src/test/java/tools/dynamia/commons/MapBuilderTest.java b/platform/core/commons/src/test/java/tools/dynamia/commons/MapBuilderTest.java index fbbaaa04..7418fb5b 100644 --- a/platform/core/commons/src/test/java/tools/dynamia/commons/MapBuilderTest.java +++ b/platform/core/commons/src/test/java/tools/dynamia/commons/MapBuilderTest.java @@ -16,7 +16,7 @@ */ package tools.dynamia.commons; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; import tools.dynamia.commons.collect.ArrayListMultiMap; import tools.dynamia.commons.collect.MultiMap; @@ -24,19 +24,19 @@ import java.util.Date; import java.util.Map; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * * @author Mario A. Serrano Leones */ -public class MapBuilderTest extends TestCase { - - public MapBuilderTest(String testName) { - super(testName); - } +public class MapBuilderTest { /** * Test of put method, of class MapBuilder. */ + @Test public void testPut_String_Object() { Map map = MapBuilder.put("value", 100); assertTrue(map.containsKey("value")); @@ -46,6 +46,7 @@ public void testPut_String_Object() { /** * Test of put method, of class MapBuilder. */ + @Test public void testPut_ObjectArr() { Map map = MapBuilder.put("value", 100, "name", "mario", @@ -55,6 +56,7 @@ public void testPut_ObjectArr() { assertEquals("mario", map.get("name")); } + @Test public void testMultiMap() { MultiMap mmap = new ArrayListMultiMap<>(); mmap.put("names", "Mario"); @@ -70,6 +72,7 @@ public void testMultiMap() { } + @Test @SuppressWarnings("rawtypes") public void testMultiMapGetKey() { MultiMap mm = new ArrayListMultiMap<>(); diff --git a/platform/core/commons/src/test/java/tools/dynamia/commons/ObjectOperationsTest.java b/platform/core/commons/src/test/java/tools/dynamia/commons/ObjectOperationsTest.java index 38de4ade..b496105b 100644 --- a/platform/core/commons/src/test/java/tools/dynamia/commons/ObjectOperationsTest.java +++ b/platform/core/commons/src/test/java/tools/dynamia/commons/ObjectOperationsTest.java @@ -16,7 +16,7 @@ */ package tools.dynamia.commons; -import org.junit.Test; +import org.junit.jupiter.api.Test; import tools.dynamia.commons.reflect.AccessMode; import tools.dynamia.commons.reflect.PropertyInfo; @@ -40,7 +40,7 @@ import java.util.function.Predicate; import java.util.stream.Collectors; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/platform/core/commons/src/test/java/tools/dynamia/commons/PolymorphicReflectionTest.java b/platform/core/commons/src/test/java/tools/dynamia/commons/PolymorphicReflectionTest.java index f2590e54..f43e05ba 100644 --- a/platform/core/commons/src/test/java/tools/dynamia/commons/PolymorphicReflectionTest.java +++ b/platform/core/commons/src/test/java/tools/dynamia/commons/PolymorphicReflectionTest.java @@ -16,8 +16,8 @@ */ package tools.dynamia.commons; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.beans.BeanInfo; import java.beans.IntrospectionException; @@ -32,25 +32,25 @@ public void testPolymorphicGetter() { ParentBean cBean = new ChildBean(); String result = (String) ObjectOperations.invokeGetMethod(pbean, "name"); - Assert.assertEquals("mario", result); + Assertions.assertEquals("mario", result); result = (String) ObjectOperations.invokeGetMethod(cBean, "name"); - Assert.assertEquals("alejandro", result); + Assertions.assertEquals("alejandro", result); result = (String) ObjectOperations.invokeGetMethod(cBean, "lastName"); - Assert.assertEquals("serrano", result); + Assertions.assertEquals("serrano", result); } @Test public void testPolymorphicFieldFromChildToParent() throws NoSuchFieldException { Field field = ObjectOperations.getField(ChildBean.class, "name"); - Assert.assertNotNull(field); + Assertions.assertNotNull(field); } - @Test(expected = NoSuchFieldException.class) - public void testPolymorphicFieldFromParentToChield() throws NoSuchFieldException { - ObjectOperations.getField(ParentBean.class, "age"); + @Test + public void testPolymorphicFieldFromParentToChield() { + Assertions.assertThrows(NoSuchFieldException.class, () -> ObjectOperations.getField(ParentBean.class, "age")); } @Test @@ -58,7 +58,7 @@ public void testInstropector() throws IntrospectionException { BeanInfo beanInfo = java.beans.Introspector.getBeanInfo(ParentBean.class); for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { } - Assert.assertTrue(true); + Assertions.assertTrue(true); } @Test @@ -67,7 +67,7 @@ public void testInstropectorFromChild() throws IntrospectionException { for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { } - Assert.assertTrue(true); + Assertions.assertTrue(true); } static class ParentBean { diff --git a/platform/core/commons/src/test/java/tools/dynamia/commons/ScopesTest.java b/platform/core/commons/src/test/java/tools/dynamia/commons/ScopesTest.java index d8620751..ebe2022e 100644 --- a/platform/core/commons/src/test/java/tools/dynamia/commons/ScopesTest.java +++ b/platform/core/commons/src/test/java/tools/dynamia/commons/ScopesTest.java @@ -1,13 +1,13 @@ package tools.dynamia.commons; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.List; import java.util.Set; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * Test class for {@link Scopes} utility functionality. diff --git a/platform/core/commons/src/test/java/tools/dynamia/commons/StringUtilsTest.java b/platform/core/commons/src/test/java/tools/dynamia/commons/StringUtilsTest.java index 9be152f1..e48aa61d 100644 --- a/platform/core/commons/src/test/java/tools/dynamia/commons/StringUtilsTest.java +++ b/platform/core/commons/src/test/java/tools/dynamia/commons/StringUtilsTest.java @@ -16,21 +16,20 @@ */ package tools.dynamia.commons; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; import java.util.HashSet; import java.util.Set; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * * @author Mario A. Serrano Leones */ -public class StringUtilsTest extends TestCase { - - public StringUtilsTest(String testName) { - super(testName); - } +public class StringUtilsTest { + @Test public void testGetLastCharacterMethod() { String string = "TheString"; @@ -40,6 +39,7 @@ public void testGetLastCharacterMethod() { assertEquals(expResult, result); } + @Test public void testGetFirstCharacterMethod() { String string = "TheString"; @@ -49,6 +49,7 @@ public void testGetFirstCharacterMethod() { assertEquals(expResult, result); } + @Test public void testSimpliedString() { String expected = "esta-prueba-servira-en-accion"; String input = "está pruébá SERvirá en acción"; @@ -58,6 +59,7 @@ public void testSimpliedString() { } + @Test public void testRandomString() { Set set = new HashSet<>(); for (int i = 0; i < 10; i++) { @@ -69,6 +71,7 @@ public void testRandomString() { } + @Test public void testCapatilizeAllWords() { String expected = "This Is Nice"; String text = "this is NICE"; diff --git a/platform/core/commons/src/test/java/tools/dynamia/commons/ops/PropertyAccessorTest.java b/platform/core/commons/src/test/java/tools/dynamia/commons/ops/PropertyAccessorTest.java index 93436cad..91f55829 100644 --- a/platform/core/commons/src/test/java/tools/dynamia/commons/ops/PropertyAccessorTest.java +++ b/platform/core/commons/src/test/java/tools/dynamia/commons/ops/PropertyAccessorTest.java @@ -16,9 +16,9 @@ */ package tools.dynamia.commons.ops; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * Tests for PropertyAccessor class, specifically testing overloaded setter handling. @@ -133,8 +133,8 @@ public void testInvokeSetMethodWithOverloadedSetters_StringValue() { // Set using String value PropertyAccessor.invokeSetMethod(bean, "address", "123 Main St"); - assertEquals("Address should be set correctly even with overloaded setters", - "123 Main St", bean.getAddress()); + assertEquals("123 Main St", bean.getAddress(), + "Address should be set correctly even with overloaded setters"); } @Test @@ -145,8 +145,8 @@ public void testInvokeSetMethodWithOverloadedSetters_NullValue() { // Set null value - this is where BeanWrapper might fail PropertyAccessor.invokeSetMethod(bean, "address", null); - assertNull("Address should be set to null even with overloaded setters", - bean.getAddress()); + assertNull(bean.getAddress(), + "Address should be set to null even with overloaded setters"); } @Test @@ -156,8 +156,8 @@ public void testInvokeSetMethodWithOverloadedSetters_ObjectValue() { // Set using Object value (Integer in this case) PropertyAccessor.invokeSetMethod(bean, "address", 12345); - assertEquals("Address should be converted to String even with overloaded setters", - "12345", bean.getAddress()); + assertEquals("12345", bean.getAddress(), + "Address should be converted to String even with overloaded setters"); } @Test diff --git a/platform/core/crud/src/test/java/tools/dynamia/crud/FilterConditionTest.java b/platform/core/crud/src/test/java/tools/dynamia/crud/FilterConditionTest.java index c832d998..90a79c20 100644 --- a/platform/core/crud/src/test/java/tools/dynamia/crud/FilterConditionTest.java +++ b/platform/core/crud/src/test/java/tools/dynamia/crud/FilterConditionTest.java @@ -16,8 +16,8 @@ */ package tools.dynamia.crud; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import tools.dynamia.domain.jpa.JpaParameter; import tools.dynamia.domain.query.Parameter; @@ -29,10 +29,10 @@ public void showBeApplicableCondition() { Parameter p = new JpaParameter(); FilterCondition[] ac = FilterCondition.getApplicableConditions(p.getClass()); - Assert.assertEquals(2, ac.length); + Assertions.assertEquals(2, ac.length); - Assert.assertEquals(FilterCondition.EQUALS, ac[0]); - Assert.assertEquals(FilterCondition.INLIST, ac[1]); + Assertions.assertEquals(FilterCondition.EQUALS, ac[0]); + Assertions.assertEquals(FilterCondition.INLIST, ac[1]); } } diff --git a/platform/core/crud/src/test/java/tools/dynamia/crud/QueryProjectionBuilderTest.java b/platform/core/crud/src/test/java/tools/dynamia/crud/QueryProjectionBuilderTest.java index f2fe01f1..32421e32 100644 --- a/platform/core/crud/src/test/java/tools/dynamia/crud/QueryProjectionBuilderTest.java +++ b/platform/core/crud/src/test/java/tools/dynamia/crud/QueryProjectionBuilderTest.java @@ -1,7 +1,7 @@ package tools.dynamia.crud; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import tools.dynamia.domain.query.QueryParameters; import tools.dynamia.domain.util.QueryBuilder; import tools.dynamia.viewers.ViewDescriptor; @@ -19,7 +19,7 @@ public void shouldBuildQuery() { QueryBuilder builder = QueryProjectionBuilder.buildFromViewDescriptor(TestEntity.class, descriptor, new QueryParameters()); String jpql = builder.toString(); String expected = "select e.id, e.name, e.date, e.description, e.notes, e.subentity, (sub.name) as subentity_name from tools.dynamia.crud.TestEntity as e"; - Assert.assertEquals(expected, jpql); + Assertions.assertEquals(expected, jpql); } private ViewDescriptor buildDescriptor() { diff --git a/platform/core/domain-jpa/src/test/java/tools/dynamia/domain/jpa/JPAPageListTest.java b/platform/core/domain-jpa/src/test/java/tools/dynamia/domain/jpa/JPAPageListTest.java index 7319f302..3c56365d 100644 --- a/platform/core/domain-jpa/src/test/java/tools/dynamia/domain/jpa/JPAPageListTest.java +++ b/platform/core/domain-jpa/src/test/java/tools/dynamia/domain/jpa/JPAPageListTest.java @@ -16,11 +16,11 @@ */ package tools.dynamia.domain.jpa; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.Transactional; import tools.dynamia.commons.collect.PagedList; import tools.dynamia.domain.query.DataPaginator; @@ -29,12 +29,12 @@ import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = JpaTestConfig.class) public class JPAPageListTest { diff --git a/platform/core/domain-jpa/src/test/java/tools/dynamia/domain/jpa/JpaConvertersTest.java b/platform/core/domain-jpa/src/test/java/tools/dynamia/domain/jpa/JpaConvertersTest.java index 13c5de55..9f2ab5af 100644 --- a/platform/core/domain-jpa/src/test/java/tools/dynamia/domain/jpa/JpaConvertersTest.java +++ b/platform/core/domain-jpa/src/test/java/tools/dynamia/domain/jpa/JpaConvertersTest.java @@ -17,15 +17,15 @@ package tools.dynamia.domain.jpa; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import tools.dynamia.domain.services.CrudService; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = JpaTestConfig.class) public class JpaConvertersTest { @@ -42,10 +42,10 @@ public void testMapConverter() { var other = crudService.find(DummyEntityJson.class, entity.getId()); - Assert.assertNotNull(other); - Assert.assertNotNull(other.getData()); - Assert.assertEquals("harold", other.getData().get("name")); - Assert.assertEquals(20, other.getData().get("age")); + Assertions.assertNotNull(other); + Assertions.assertNotNull(other.getData()); + Assertions.assertEquals("harold", other.getData().get("name")); + Assertions.assertEquals(20, other.getData().get("age")); } @Test @@ -58,14 +58,14 @@ public void testListConverter() { var other = crudService.find(DummyEntityJson.class, entity.getId()); - Assert.assertNotNull(other); - Assert.assertNotNull(other.getAddresses()); - Assert.assertFalse(other.getAddresses().isEmpty()); + Assertions.assertNotNull(other); + Assertions.assertNotNull(other.getAddresses()); + Assertions.assertFalse(other.getAddresses().isEmpty()); var first = other.getAddresses().stream().findFirst(); - Assert.assertTrue(first.isPresent()); + Assertions.assertTrue(first.isPresent()); - Assert.assertEquals("Main Av 123", first.get().getLine1()); + Assertions.assertEquals("Main Av 123", first.get().getLine1()); } } diff --git a/platform/core/domain-jpa/src/test/java/tools/dynamia/domain/jpa/JpaCrudServiceTest.java b/platform/core/domain-jpa/src/test/java/tools/dynamia/domain/jpa/JpaCrudServiceTest.java index 28630114..6d97a393 100644 --- a/platform/core/domain-jpa/src/test/java/tools/dynamia/domain/jpa/JpaCrudServiceTest.java +++ b/platform/core/domain-jpa/src/test/java/tools/dynamia/domain/jpa/JpaCrudServiceTest.java @@ -16,12 +16,12 @@ */ package tools.dynamia.domain.jpa; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.Transactional; import tools.dynamia.domain.query.QueryConditions; import tools.dynamia.domain.services.CrudService; @@ -34,7 +34,7 @@ import static tools.dynamia.domain.query.QueryConditions.isNotNull; import static tools.dynamia.domain.query.QueryParameters.with; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = JpaTestConfig.class) public class JpaCrudServiceTest { @@ -50,10 +50,10 @@ public void shouldUpdate4() { } int result = crudService.batchUpdate(DummyEntity.class, "name", "THE_DUMMY", with("name", isNotNull())); - Assert.assertEquals(4, result); + Assertions.assertEquals(4, result); List dummies = crudService.find(DummyEntity.class, with("name", "THE_DUMMY")); - Assert.assertEquals(4, dummies.size()); + Assertions.assertEquals(4, dummies.size()); } @@ -62,7 +62,7 @@ public void shouldUpdate4() { public void findByFieldsTestResultShouldBeEmpty() { List result = crudService.findByFields(DummyEntity.class, "xxx", with("id", gt(10L)), "name"); - Assert.assertTrue(result.isEmpty()); + Assertions.assertTrue(result.isEmpty()); } @Test @@ -74,7 +74,7 @@ public void shouldFind4UsingStaticHelperMethods() { } List result = handle(DummyEntity.class).findAll(); - Assert.assertEquals(4, result.size()); + Assertions.assertEquals(4, result.size()); } @Test @@ -86,10 +86,10 @@ public void shouldFindByNameUsingStaticHelperMethods() { } List result = DummyEntity.findByName("Dummy0"); - Assert.assertEquals(1, result.size()); + Assertions.assertEquals(1, result.size()); DummyEntity dummyEntity = result.getFirst(); - Assert.assertEquals("Dummy0", dummyEntity.getName()); + Assertions.assertEquals("Dummy0", dummyEntity.getName()); } @Test @@ -118,6 +118,6 @@ public void shouldGroupAndHavingEntities() { .having("sum(d.size)", QueryConditions.gt(10)); List result = crudService.executeQuery(query); - Assert.assertFalse(result.isEmpty()); + Assertions.assertFalse(result.isEmpty()); } } diff --git a/platform/core/domain/src/test/java/tools/dynamia/domain/CurrencyExchangeProviderTest.java b/platform/core/domain/src/test/java/tools/dynamia/domain/CurrencyExchangeProviderTest.java index 4fd4cec5..95c60d9d 100644 --- a/platform/core/domain/src/test/java/tools/dynamia/domain/CurrencyExchangeProviderTest.java +++ b/platform/core/domain/src/test/java/tools/dynamia/domain/CurrencyExchangeProviderTest.java @@ -1,6 +1,6 @@ package tools.dynamia.domain; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.math.BigDecimal; diff --git a/platform/core/domain/src/test/java/tools/dynamia/domain/DataPaginatorTest.java b/platform/core/domain/src/test/java/tools/dynamia/domain/DataPaginatorTest.java index 32529357..0e1a398c 100644 --- a/platform/core/domain/src/test/java/tools/dynamia/domain/DataPaginatorTest.java +++ b/platform/core/domain/src/test/java/tools/dynamia/domain/DataPaginatorTest.java @@ -16,10 +16,11 @@ */ package tools.dynamia.domain; -import org.junit.Test; +import org.junit.jupiter.api.Test; import tools.dynamia.domain.query.DataPaginator; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * @@ -97,10 +98,9 @@ public void testScrollToIndex() { } - @Test(expected = IndexOutOfBoundsException.class) + @Test public void testScrollToIndexSecurity() { DataPaginator dp = new DataPaginator(18, 4, 1); - dp.scrollToIndex(600); - + assertThrows(IndexOutOfBoundsException.class, () -> dp.scrollToIndex(600)); } } diff --git a/platform/core/domain/src/test/java/tools/dynamia/domain/EmailValidatorTest.java b/platform/core/domain/src/test/java/tools/dynamia/domain/EmailValidatorTest.java index 727f09a1..1652c343 100644 --- a/platform/core/domain/src/test/java/tools/dynamia/domain/EmailValidatorTest.java +++ b/platform/core/domain/src/test/java/tools/dynamia/domain/EmailValidatorTest.java @@ -1,12 +1,12 @@ package tools.dynamia.domain; -import org.junit.Test; +import org.junit.jupiter.api.Test; import tools.dynamia.domain.contraints.EmailValidator; import java.util.List; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class EmailValidatorTest { diff --git a/platform/core/domain/src/test/java/tools/dynamia/domain/IdGeneratorsTest.java b/platform/core/domain/src/test/java/tools/dynamia/domain/IdGeneratorsTest.java index 714d1c77..a6178109 100644 --- a/platform/core/domain/src/test/java/tools/dynamia/domain/IdGeneratorsTest.java +++ b/platform/core/domain/src/test/java/tools/dynamia/domain/IdGeneratorsTest.java @@ -16,15 +16,15 @@ */ package tools.dynamia.domain; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import tools.dynamia.integration.Containers; import tools.dynamia.integration.SimpleObjectContainer; public class IdGeneratorsTest { - @BeforeClass + @BeforeAll public static void init() { SimpleObjectContainer container = new SimpleObjectContainer("IdGeneratorsContainers"); container.addObject("stringIdGenerator", new StringIdGenerator()); @@ -35,17 +35,17 @@ public static void init() { @Test public void shouldGenerateStringId() { String id = IdGenerators.createId(String.class); - Assert.assertNotNull(id); + Assertions.assertNotNull(id); } @Test public void shouldGenerateLongId() { Long id = IdGenerators.createId(Long.class); - Assert.assertNotNull(id); + Assertions.assertNotNull(id); } - @Test(expected = IdGeneratorNotFoundException.class) + @Test public void shouldThrowException() { - IdGenerators.createId(Integer.class); + Assertions.assertThrows(IdGeneratorNotFoundException.class, () -> IdGenerators.createId(Integer.class)); } } diff --git a/platform/core/domain/src/test/java/tools/dynamia/domain/InMemoryCrudServiceTest.java b/platform/core/domain/src/test/java/tools/dynamia/domain/InMemoryCrudServiceTest.java index 6d7b97d4..3d1f6d69 100644 --- a/platform/core/domain/src/test/java/tools/dynamia/domain/InMemoryCrudServiceTest.java +++ b/platform/core/domain/src/test/java/tools/dynamia/domain/InMemoryCrudServiceTest.java @@ -1,7 +1,7 @@ package tools.dynamia.domain; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import tools.dynamia.domain.query.QueryConditions; import tools.dynamia.domain.query.QueryParameters; import tools.dynamia.domain.services.CrudService; @@ -20,8 +20,8 @@ public void shouldCreateEntity() { entity.setName("Test"); var r = crudService.create(entity); - Assert.assertNotNull(r.getId()); - Assert.assertFalse(crudService.findAll(SomeEntity.class).isEmpty()); + Assertions.assertNotNull(r.getId()); + Assertions.assertFalse(crudService.findAll(SomeEntity.class).isEmpty()); } @Test @@ -32,11 +32,11 @@ public void shouldCreate_10_Entities() { var entity = new SomeEntity(); entity.setName("Test " + i); var r = crudService.create(entity); - Assert.assertNotNull(r.getId()); + Assertions.assertNotNull(r.getId()); } List result = crudService.findAll(SomeEntity.class); - Assert.assertEquals(result.size(), 10); + Assertions.assertEquals(result.size(), 10); } @Test @@ -50,8 +50,8 @@ public void shouldFindFirstEntity() { } SomeEntity first = crudService.findFirst(SomeEntity.class); - Assert.assertNotNull(first); - Assert.assertEquals(first.getName(), "Test 0"); + Assertions.assertNotNull(first); + Assertions.assertEquals(first.getName(), "Test 0"); } @Test @@ -62,9 +62,9 @@ public void shouldFilterByParamters() { .add("active", true)); - Assert.assertEquals(filtered.size(), 5); + Assertions.assertEquals(filtered.size(), 5); filtered = crudService.find(SomeEntity.class, QueryParameters.with("age", 41)); - Assert.assertEquals(filtered.size(), 1); + Assertions.assertEquals(filtered.size(), 1); } @Test @@ -88,7 +88,7 @@ public void shouldFilterByParamtersWithPathProperties() { .add("otherEntity.name", "Other") .add("otherEntity.active", true)); - Assert.assertEquals(result.size(), 1); + Assertions.assertEquals(result.size(), 1); } @Test @@ -96,20 +96,20 @@ public void shouldDeleteAll() { CrudService crudService = new InMemoryCrudService(); createSamples(crudService); crudService.deleteAll(SomeEntity.class); - Assert.assertTrue(crudService.findAll(SomeEntity.class).isEmpty()); + Assertions.assertTrue(crudService.findAll(SomeEntity.class).isEmpty()); } @Test public void shouldUpdateEntity() { CrudService crudService = new InMemoryCrudService(); var entity = crudService.create(new SomeEntity()); - Assert.assertNotNull(entity.getId()); + Assertions.assertNotNull(entity.getId()); entity.setName("Test Entity"); entity.setAge(100); var result = crudService.update(entity); - Assert.assertEquals(result.getAge(), 100); + Assertions.assertEquals(result.getAge(), 100); } @Test @@ -118,19 +118,19 @@ public void shoudListEntityProperties() { createSamples(crudService); List names = crudService.getPropertyValues(SomeEntity.class, "name"); System.out.println(names); - Assert.assertEquals(names.size(), 10); + Assertions.assertEquals(names.size(), 10); } - @Test(expected = ValidationError.class) + @Test public void shouldValidatePersonName() { CrudService crudService = new InMemoryCrudService(); - crudService.create(new Person(null, 19)); + Assertions.assertThrows(ValidationError.class, () -> crudService.create(new Person(null, 19))); } - @Test(expected = ValidationError.class) + @Test public void shouldValidatePersonAge() { CrudService crudService = new InMemoryCrudService(); - crudService.create(new Person("Jhon", 15)); + Assertions.assertThrows(ValidationError.class, () -> crudService.create(new Person("Jhon", 15))); } @Test @@ -157,9 +157,9 @@ public void afterCreate(Person entity) { CrudService crudService = new InMemoryCrudService(List.of(fixAgeListener)); Person young = new Person("Mario", 15); crudService.create(young); - Assert.assertEquals(young.getAge(), 20); - Assert.assertTrue(beforeCreateFired.get()); - Assert.assertTrue(afterCreateFired.get()); + Assertions.assertEquals(young.getAge(), 20); + Assertions.assertTrue(beforeCreateFired.get()); + Assertions.assertTrue(afterCreateFired.get()); } @@ -171,27 +171,27 @@ public void shouldUpdateCounters() { crudService.increaseCounter(entity, "counter"); crudService.increaseCounter(entity, "counter"); crudService.increaseCounter(entity, "counter"); - Assert.assertEquals(entity.getCounter(), 3); + Assertions.assertEquals(entity.getCounter(), 3); crudService.deacreaseCounter(entity, "counter"); - Assert.assertEquals(entity.getCounter(), 2); + Assertions.assertEquals(entity.getCounter(), 2); crudService.increaseCounter(entity, "otherCounter"); crudService.increaseCounter(entity, "otherCounter"); crudService.increaseCounter(entity, "otherCounter"); - Assert.assertEquals(entity.getOtherCounter(), 3); + Assertions.assertEquals(entity.getOtherCounter(), 3); crudService.deacreaseCounter(entity, "otherCounter"); - Assert.assertEquals(entity.getOtherCounter(), 2); + Assertions.assertEquals(entity.getOtherCounter(), 2); crudService.increaseCounter(entity, "anotherCounter"); crudService.increaseCounter(entity, "anotherCounter"); crudService.increaseCounter(entity, "anotherCounter"); - Assert.assertEquals(entity.getAnotherCounter().longValue(), 3L); + Assertions.assertEquals(entity.getAnotherCounter().longValue(), 3L); crudService.deacreaseCounter(entity, "anotherCounter"); - Assert.assertEquals(entity.getAnotherCounter().longValue(), 2L); + Assertions.assertEquals(entity.getAnotherCounter().longValue(), 2L); } diff --git a/platform/core/domain/src/test/java/tools/dynamia/domain/JDBCHelperTest.java b/platform/core/domain/src/test/java/tools/dynamia/domain/JDBCHelperTest.java index 3f9d5908..db6d4adb 100644 --- a/platform/core/domain/src/test/java/tools/dynamia/domain/JDBCHelperTest.java +++ b/platform/core/domain/src/test/java/tools/dynamia/domain/JDBCHelperTest.java @@ -16,15 +16,18 @@ */ package tools.dynamia.domain; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; import tools.dynamia.domain.jdbc.JdbcHelper; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * * @author Mario A. Serrano Leones */ -public class JDBCHelperTest extends TestCase { +public class JDBCHelperTest { + @Test public void testCreateInParameters() { String expected = "(?,?,?,?,?)"; String result = JdbcHelper.createInParameters(5); diff --git a/platform/core/domain/src/test/java/tools/dynamia/domain/QueryBuilderTest.java b/platform/core/domain/src/test/java/tools/dynamia/domain/QueryBuilderTest.java index ecaacb98..49664086 100644 --- a/platform/core/domain/src/test/java/tools/dynamia/domain/QueryBuilderTest.java +++ b/platform/core/domain/src/test/java/tools/dynamia/domain/QueryBuilderTest.java @@ -16,7 +16,7 @@ */ package tools.dynamia.domain; -import org.junit.Test; +import org.junit.jupiter.api.Test; import tools.dynamia.domain.query.BooleanOp; import tools.dynamia.domain.query.Parameter; import tools.dynamia.domain.query.QueryConditions; @@ -25,7 +25,7 @@ import java.util.TreeMap; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static tools.dynamia.domain.query.QueryConditions.eq; import static tools.dynamia.domain.query.QueryConditions.in; import static tools.dynamia.domain.query.QueryParameters.with; diff --git a/platform/core/domain/src/test/java/tools/dynamia/domain/QueryConditionsTest.java b/platform/core/domain/src/test/java/tools/dynamia/domain/QueryConditionsTest.java index 794dbfdd..4c310802 100644 --- a/platform/core/domain/src/test/java/tools/dynamia/domain/QueryConditionsTest.java +++ b/platform/core/domain/src/test/java/tools/dynamia/domain/QueryConditionsTest.java @@ -16,7 +16,7 @@ */ package tools.dynamia.domain; -import org.junit.Test; +import org.junit.jupiter.api.Test; import tools.dynamia.commons.MapBuilder; import tools.dynamia.domain.query.BooleanOp; import tools.dynamia.domain.query.QueryCondition; @@ -26,7 +26,7 @@ import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/platform/core/domain/src/test/java/tools/dynamia/domain/TransferableTest.java b/platform/core/domain/src/test/java/tools/dynamia/domain/TransferableTest.java index c2e726d6..462290a0 100644 --- a/platform/core/domain/src/test/java/tools/dynamia/domain/TransferableTest.java +++ b/platform/core/domain/src/test/java/tools/dynamia/domain/TransferableTest.java @@ -17,8 +17,8 @@ package tools.dynamia.domain; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import tools.dynamia.commons.ObjectOperations; import tools.dynamia.domain.query.Parameter; import tools.dynamia.integration.Containers; @@ -27,7 +27,7 @@ import java.io.Serializable; import java.lang.reflect.Field; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class TransferableTest { @@ -53,7 +53,7 @@ public void shouldAutoCreateDTO() { SomeEntityDTO dto = entity.toDTO(); - Assert.assertNotNull(dto); + Assertions.assertNotNull(dto); assertEquals(entity.getId(), dto.getId()); assertEquals(entity.getAccountId(), dto.getAccountId()); assertEquals(entity.getName(), dto.getName()); diff --git a/platform/core/domain/src/test/java/tools/dynamia/domain/util/DataTransferObjectBuilderTest.java b/platform/core/domain/src/test/java/tools/dynamia/domain/util/DataTransferObjectBuilderTest.java index 5878f17e..fb4f11b3 100644 --- a/platform/core/domain/src/test/java/tools/dynamia/domain/util/DataTransferObjectBuilderTest.java +++ b/platform/core/domain/src/test/java/tools/dynamia/domain/util/DataTransferObjectBuilderTest.java @@ -16,10 +16,10 @@ */ package tools.dynamia.domain.util; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * Unit tests for DataTransferObjectBuilder. @@ -34,7 +34,7 @@ public class DataTransferObjectBuilderTest { private TestEntity testEntity; - @Before + @BeforeEach public void setUp() { // Setup test entity with standard properties testEntity = new TestEntity(); @@ -53,11 +53,11 @@ public void setUp() { public void testBuildDTOBasicProperties() { TestEntityDTO dto = DataTransferObjectBuilder.buildDTO(testEntity, TestEntityDTO.class); - assertNotNull("DTO should not be null", dto); - assertEquals("Name should be copied", testEntity.getName(), dto.getName()); - assertEquals("Description should be copied", testEntity.getDescription(), dto.getDescription()); - assertEquals("Price should be copied", testEntity.getPrice(), dto.getPrice(), 0.001); - assertEquals("Active flag should be copied", testEntity.isActive(), dto.isActive()); + assertNotNull(dto, "DTO should not be null"); + assertEquals(testEntity.getName(), dto.getName(), "Name should be copied"); + assertEquals(testEntity.getDescription(), dto.getDescription(), "Description should be copied"); + assertEquals(testEntity.getPrice(), dto.getPrice(), 0.001, "Price should be copied"); + assertEquals(testEntity.isActive(), dto.isActive(), "Active flag should be copied"); } /** @@ -67,12 +67,12 @@ public void testBuildDTOBasicProperties() { public void testBuildDTOCopiesAllMatchingProperties() { TestEntityDTOComplete dto = DataTransferObjectBuilder.buildDTO(testEntity, TestEntityDTOComplete.class); - assertNotNull("DTO should not be null", dto); - assertEquals("ID should be copied", testEntity.getId(), dto.getId()); - assertEquals("Name should be copied", testEntity.getName(), dto.getName()); - assertEquals("Description should be copied", testEntity.getDescription(), dto.getDescription()); - assertEquals("Price should be copied", testEntity.getPrice(), dto.getPrice(), 0.001); - assertEquals("Quantity should be copied", testEntity.getQuantity(), dto.getQuantity()); + assertNotNull(dto, "DTO should not be null"); + assertEquals(testEntity.getId(), dto.getId(), "ID should be copied"); + assertEquals(testEntity.getName(), dto.getName(), "Name should be copied"); + assertEquals(testEntity.getDescription(), dto.getDescription(), "Description should be copied"); + assertEquals(testEntity.getPrice(), dto.getPrice(), 0.001, "Price should be copied"); + assertEquals(testEntity.getQuantity(), dto.getQuantity(), "Quantity should be copied"); } /** @@ -82,9 +82,9 @@ public void testBuildDTOCopiesAllMatchingProperties() { public void testBuildDTOPartialProperties() { TestEntityDTOPartial dto = DataTransferObjectBuilder.buildDTO(testEntity, TestEntityDTOPartial.class); - assertNotNull("DTO should not be null", dto); - assertEquals("Name should be copied", testEntity.getName(), dto.getName()); - assertEquals("Price should be copied", testEntity.getPrice(), dto.getPrice(), 0.001); + assertNotNull(dto, "DTO should not be null"); + assertEquals(testEntity.getName(), dto.getName(), "Name should be copied"); + assertEquals(testEntity.getPrice(), dto.getPrice(), 0.001, "Price should be copied"); // Description is not in DTO, so it should be ignored without error } @@ -98,10 +98,10 @@ public void testBuildDTOWithNullProperties() { TestEntityDTO dto = DataTransferObjectBuilder.buildDTO(testEntity, TestEntityDTO.class); - assertNotNull("DTO should not be null", dto); - assertNull("Null name should remain null", dto.getName()); - assertNull("Null description should remain null", dto.getDescription()); - assertEquals("Non-null price should be copied", testEntity.getPrice(), dto.getPrice(), 0.001); + assertNotNull(dto, "DTO should not be null"); + assertNull(dto.getName(), "Null name should remain null"); + assertNull(dto.getDescription(), "Null description should remain null"); + assertEquals(testEntity.getPrice(), dto.getPrice(), 0.001, "Non-null price should be copied"); } /** @@ -113,10 +113,10 @@ public void testBuildDTOWithAllNullProperties() { TestEntityDTO dto = DataTransferObjectBuilder.buildDTO(emptyEntity, TestEntityDTO.class); - assertNotNull("DTO should not be null even for empty entity", dto); - assertNull("Name should be null", dto.getName()); - assertNull("Description should be null", dto.getDescription()); - assertNull("Price should be null", dto.getPrice()); + assertNotNull(dto, "DTO should not be null even for empty entity"); + assertNull(dto.getName(), "Name should be null"); + assertNull(dto.getDescription(), "Description should be null"); + assertNull(dto.getPrice(), "Price should be null"); } /** @@ -126,9 +126,9 @@ public void testBuildDTOWithAllNullProperties() { public void testBuildDTOPreservesPrimitives() { TestEntityDTOWithPrimitives dto = DataTransferObjectBuilder.buildDTO(testEntity, TestEntityDTOWithPrimitives.class); - assertNotNull("DTO should not be null", dto); - assertEquals("Active boolean should be copied", testEntity.isActive(), dto.isActive()); - assertEquals("Quantity int should be copied", testEntity.getQuantity().intValue(), dto.getQuantity()); + assertNotNull(dto, "DTO should not be null"); + assertEquals(testEntity.isActive(), dto.isActive(), "Active boolean should be copied"); + assertEquals(testEntity.getQuantity().intValue(), dto.getQuantity(), "Quantity int should be copied"); } /** @@ -138,11 +138,11 @@ public void testBuildDTOPreservesPrimitives() { public void testBuildDTOWithAdditionalProperties() { TestEntityDTOWithExtra dto = DataTransferObjectBuilder.buildDTO(testEntity, TestEntityDTOWithExtra.class); - assertNotNull("DTO should not be null", dto); - assertEquals("Name should be copied", testEntity.getName(), dto.getName()); + assertNotNull(dto, "DTO should not be null"); + assertEquals(testEntity.getName(), dto.getName(), "Name should be copied"); // Additional property not in source should remain at default value - assertNull("Extra property should be null (default)", dto.getExtraField()); + assertNull(dto.getExtraField(), "Extra property should be null (default)"); } /** @@ -152,16 +152,16 @@ public void testBuildDTOWithAdditionalProperties() { public void testBuildDTOWithTypeConversion() { TestEntityDTOWithConversion dto = DataTransferObjectBuilder.buildDTO(testEntity, TestEntityDTOWithConversion.class); - assertNotNull("DTO should not be null", dto); + assertNotNull(dto, "DTO should not be null"); // Spring BeanUtils should handle compatible type conversions - assertEquals("Name should be copied", testEntity.getName(), dto.getName()); + assertEquals(testEntity.getName(), dto.getName(), "Name should be copied"); // Note: Integer to Long conversion may not happen automatically with BeanUtils // This is expected behavior - BeanUtils only copies matching types // For type conversion, use custom converters or transform methods if (dto.getQuantity() != null) { - assertEquals("Quantity should be converted if Spring supports it", - testEntity.getQuantity().longValue(), dto.getQuantity().longValue()); + assertEquals(testEntity.getQuantity().longValue(), dto.getQuantity().longValue(), + "Quantity should be converted if Spring supports it"); } } @@ -172,15 +172,15 @@ public void testBuildDTOWithTypeConversion() { public void testBuildDTOCreatesNewInstance() { TestEntityDTO dto = DataTransferObjectBuilder.buildDTO(testEntity, TestEntityDTO.class); - assertNotNull("DTO should not be null", dto); + assertNotNull(dto, "DTO should not be null"); // Modify DTO dto.setName("Modified Name"); dto.setPrice(199.99); // Original should remain unchanged - assertEquals("Original name should not change", "Test Product", testEntity.getName()); - assertEquals("Original price should not change", 99.99, testEntity.getPrice(), 0.001); + assertEquals("Test Product", testEntity.getName(), "Original name should not change"); + assertEquals(99.99, testEntity.getPrice(), 0.001, "Original price should not change"); } /** @@ -192,12 +192,12 @@ public void testBuildDTOWithBooleans() { TestEntityDTO dto = DataTransferObjectBuilder.buildDTO(testEntity, TestEntityDTO.class); - assertNotNull("DTO should not be null", dto); - assertFalse("False boolean should be copied correctly", dto.isActive()); + assertNotNull(dto, "DTO should not be null"); + assertFalse(dto.isActive(), "False boolean should be copied correctly"); testEntity.setActive(true); dto = DataTransferObjectBuilder.buildDTO(testEntity, TestEntityDTO.class); - assertTrue("True boolean should be copied correctly", dto.isActive()); + assertTrue(dto.isActive(), "True boolean should be copied correctly"); } // ============================================================================ diff --git a/platform/core/integration/src/test/java/tools/dynamia/integration/ContainersTest.java b/platform/core/integration/src/test/java/tools/dynamia/integration/ContainersTest.java index 1a905e0e..4af64bbc 100644 --- a/platform/core/integration/src/test/java/tools/dynamia/integration/ContainersTest.java +++ b/platform/core/integration/src/test/java/tools/dynamia/integration/ContainersTest.java @@ -16,21 +16,21 @@ */ package tools.dynamia.integration; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.math.BigDecimal; import java.util.Collection; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class ContainersTest { private SimpleObjectContainer soc; - @Before + @BeforeEach public void init() { soc = new SimpleObjectContainer(); soc.addObject("nombre", "mario"); diff --git a/platform/core/integration/src/test/java/tools/dynamia/integration/ProgressMonitorTest.java b/platform/core/integration/src/test/java/tools/dynamia/integration/ProgressMonitorTest.java index be057904..b6caa270 100644 --- a/platform/core/integration/src/test/java/tools/dynamia/integration/ProgressMonitorTest.java +++ b/platform/core/integration/src/test/java/tools/dynamia/integration/ProgressMonitorTest.java @@ -16,8 +16,8 @@ */ package tools.dynamia.integration; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class ProgressMonitorTest { @@ -31,7 +31,7 @@ public void testPercent() { int result = monitor.getPercent(); - Assert.assertEquals(expected, result); + Assertions.assertEquals(expected, result); } } diff --git a/platform/core/integration/src/test/java/tools/dynamia/integration/SchedulerUtilTests.java b/platform/core/integration/src/test/java/tools/dynamia/integration/SchedulerUtilTests.java index 9a2f7c0d..ad10d25c 100644 --- a/platform/core/integration/src/test/java/tools/dynamia/integration/SchedulerUtilTests.java +++ b/platform/core/integration/src/test/java/tools/dynamia/integration/SchedulerUtilTests.java @@ -1,7 +1,7 @@ package tools.dynamia.integration; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import tools.dynamia.integration.scheduling.SchedulerUtil; import java.time.Duration; @@ -33,7 +33,7 @@ public void testAsyncTaskWithResult() throws Exception { return "Task Result"; }).get(); // Wait for the result - Assert.assertEquals("Task Result", result); + Assertions.assertEquals("Task Result", result); } @Test @@ -62,6 +62,6 @@ public void shouldSubmitMultipleTasksInOrder() throws Exception { ); sequence.get(); // Wait for all tasks to complete - Assert.assertEquals(3, counter.get()); + Assertions.assertEquals(3, counter.get()); } } diff --git a/platform/core/integration/src/test/java/tools/dynamia/integration/ms/MessageCallbakTest.java b/platform/core/integration/src/test/java/tools/dynamia/integration/ms/MessageCallbakTest.java index 04933104..a2c52553 100644 --- a/platform/core/integration/src/test/java/tools/dynamia/integration/ms/MessageCallbakTest.java +++ b/platform/core/integration/src/test/java/tools/dynamia/integration/ms/MessageCallbakTest.java @@ -16,9 +16,9 @@ */ package tools.dynamia.integration.ms; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import tools.dynamia.commons.MapBuilder; import tools.dynamia.commons.StringUtils; import tools.dynamia.integration.Containers; @@ -32,7 +32,7 @@ public class MessageCallbakTest { private static final String CALLBACK_CHANNEL = "calcClient"; private static final String HEADER_EXPECTED_RESULT = "expectedResult"; - @Before + @BeforeEach public void init() { SimpleObjectContainer soc = new SimpleObjectContainer(); ResultMessageListener resultListener = new ResultMessageListener(); @@ -121,7 +121,7 @@ public void onMessage(MessageEvent evt) { int result = (int) evt.message().getContent(); String description = (String) evt.message().getHeader(Message.HEADER_DESCRIPTION); - Assert.assertEquals(expectedResult, result); + Assertions.assertEquals(expectedResult, result); messagesWithoutResult.remove(correlationId); } } diff --git a/platform/core/integration/src/test/java/tools/dynamia/integration/ms/MessageChannelTest.java b/platform/core/integration/src/test/java/tools/dynamia/integration/ms/MessageChannelTest.java index 2aa9fea2..7308fd10 100644 --- a/platform/core/integration/src/test/java/tools/dynamia/integration/ms/MessageChannelTest.java +++ b/platform/core/integration/src/test/java/tools/dynamia/integration/ms/MessageChannelTest.java @@ -16,9 +16,9 @@ */ package tools.dynamia.integration.ms; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import tools.dynamia.integration.Containers; import tools.dynamia.integration.SimpleObjectContainer; import tools.dynamia.integration.ms.listeners.AllMessageListener; @@ -32,7 +32,7 @@ public class MessageChannelTest { - @Before + @BeforeEach public void init() { SimpleObjectContainer soc = new SimpleObjectContainer(); soc.addObject("ml1", new DummyMessageListener()); @@ -50,7 +50,7 @@ public void sendSimpleMessage() { channel.publish(msg); int listenerCount = (Integer) msg.getHeader(Message.HEADER_LISTENER_COUNT); - Assert.assertEquals(2, listenerCount); + Assertions.assertEquals(2, listenerCount); } @Test @@ -60,7 +60,7 @@ public void sendSimpleMessageToOtherChannel() { channel.publish(msg); int listenerCount = (Integer) msg.getHeader(Message.HEADER_LISTENER_COUNT); - Assert.assertEquals(1, listenerCount); + Assertions.assertEquals(1, listenerCount); } @@ -72,7 +72,7 @@ public void shouldCaptureAnExceptionAndBeReceivedByOneListenerOnly() { int listenerCount = (Integer) msg.getHeader(Message.HEADER_LISTENER_COUNT); - Assert.assertEquals(1, listenerCount); + Assertions.assertEquals(1, listenerCount); } @Test @@ -95,20 +95,20 @@ public void shouldSubscribeToChannel() { }); service.publish("sales", "Some cool stuff"); - Assert.assertEquals("Some cool stuff", result.get()); + Assertions.assertEquals("Some cool stuff", result.get()); service.publish("sales", 10, "promotions"); service.publish("sales", 20, "promotions"); service.publish("sales", 30, "promotions"); - Assert.assertEquals(3, promotionsCount.get()); //all messages with topic - Assert.assertEquals(1, salesCount.get()); //only the first message without topic + Assertions.assertEquals(3, promotionsCount.get()); //all messages with topic + Assertions.assertEquals(1, salesCount.get()); //only the first message without topic //cancel subscription sub.unsubscribe(); service.publish("sales", "Another sale"); - Assert.assertEquals("Some cool stuff", result.get()); //should not change + Assertions.assertEquals("Some cool stuff", result.get()); //should not change } @Test @@ -119,9 +119,9 @@ public void shouldSubscribeToTextMessagesOnly() { service.subscribeText("mixedChannel", content -> textMessageReceived.set(true)); service.publish("mixedChannel", new NumberMessage(123)); - Assert.assertFalse(textMessageReceived.get()); + Assertions.assertFalse(textMessageReceived.get()); service.publish("mixedChannel", new TextMessage("Hello")); - Assert.assertTrue(textMessageReceived.get()); + Assertions.assertTrue(textMessageReceived.get()); } } diff --git a/platform/core/integration/src/test/java/tools/dynamia/integration/ms/MessagesTopicsTest.java b/platform/core/integration/src/test/java/tools/dynamia/integration/ms/MessagesTopicsTest.java index cdaa4160..c19857de 100644 --- a/platform/core/integration/src/test/java/tools/dynamia/integration/ms/MessagesTopicsTest.java +++ b/platform/core/integration/src/test/java/tools/dynamia/integration/ms/MessagesTopicsTest.java @@ -16,9 +16,9 @@ */ package tools.dynamia.integration.ms; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import tools.dynamia.integration.Containers; import tools.dynamia.integration.SimpleObjectContainer; import tools.dynamia.integration.ms.listeners.AllErrorTopicMessageListener; @@ -28,7 +28,7 @@ public class MessagesTopicsTest { - @Before + @BeforeEach public void init() { SimpleObjectContainer soc = new SimpleObjectContainer(); soc.addObject("ml1", new ErrorWarnLogMessageListener()); @@ -48,7 +48,7 @@ public void shouldBeAllThreeListener() { TextMessage message = new TextMessage("Hello World!!"); channel.publish(message, "error"); - Assert.assertEquals(3, message.getHeader(Message.HEADER_LISTENER_COUNT)); + Assertions.assertEquals(3, message.getHeader(Message.HEADER_LISTENER_COUNT)); } @Test @@ -59,7 +59,7 @@ public void shouldBeTwoListener() { TextMessage message = new TextMessage("Hello World!!"); channel.publish(message, "warning"); - Assert.assertEquals(2, message.getHeader(Message.HEADER_LISTENER_COUNT)); + Assertions.assertEquals(2, message.getHeader(Message.HEADER_LISTENER_COUNT)); } @Test @@ -69,7 +69,7 @@ public void shouldBeOneListener() { TextMessage message = new TextMessage("Something fail"); channel.publish(message, "error"); - Assert.assertEquals(1, message.getHeader(Message.HEADER_LISTENER_COUNT)); + Assertions.assertEquals(1, message.getHeader(Message.HEADER_LISTENER_COUNT)); } @Test @@ -83,6 +83,6 @@ public void shouldBeOneListenerButArraySizeTimes() { times += (int) message.getHeader(Message.HEADER_LISTENER_COUNT); } - Assert.assertEquals(topics.length, times); + Assertions.assertEquals(topics.length, times); } } diff --git a/platform/core/integration/src/test/java/tools/dynamia/integration/reactive/ReactiveTest.java b/platform/core/integration/src/test/java/tools/dynamia/integration/reactive/ReactiveTest.java index 28a5d581..0be76df0 100644 --- a/platform/core/integration/src/test/java/tools/dynamia/integration/reactive/ReactiveTest.java +++ b/platform/core/integration/src/test/java/tools/dynamia/integration/reactive/ReactiveTest.java @@ -1,14 +1,14 @@ package tools.dynamia.integration.reactive; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import static java.lang.Integer.valueOf; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import static tools.dynamia.integration.reactive.Reactive.*; /** @@ -147,16 +147,16 @@ public void testComputedCaching() { // Initial computation (runs twice: once for initialization, once for effect setup) assertEquals(valueOf(0), doubled.get()); int initialComputes = computeCount.get(); - assertTrue("Expected at least 1 computation", initialComputes >= 1); + assertTrue(initialComputes >= 1, "Expected at least 1 computation"); // Getting again without changes should use cached value assertEquals(valueOf(0), doubled.get()); - assertEquals("Should not recompute when getting cached value", initialComputes, computeCount.get()); + assertEquals(initialComputes, computeCount.get(), "Should not recompute when getting cached value"); // Changing the ref should trigger recomputation count.set(5); assertEquals(valueOf(10), doubled.get()); - assertTrue("Should have recomputed after change", computeCount.get() > initialComputes); + assertTrue(computeCount.get() > initialComputes, "Should have recomputed after change"); } @Test @@ -234,13 +234,13 @@ public void testComputedToString() { @Test public void testRefWithNullValue() { Ref nullable = ref(null); - Assert.assertNull(nullable.get()); + Assertions.assertNull(nullable.get()); nullable.set("value"); assertEquals("value", nullable.get()); nullable.set(null); - Assert.assertNull(nullable.get()); + Assertions.assertNull(nullable.get()); } @Test @@ -290,19 +290,19 @@ public void testConditionalDependency() { }); // Initially uses 'a' - assertFalse("Effect should run at least once", captured.isEmpty()); + assertFalse(captured.isEmpty(), "Effect should run at least once"); assertEquals("A", captured.getLast()); // Changing 'a' should trigger since it's the active branch int sizeBefore = captured.size(); a.set("A2"); - assertTrue("Effect should have been triggered", captured.size() > sizeBefore); + assertTrue(captured.size() > sizeBefore, "Effect should have been triggered"); assertEquals("A2", captured.getLast()); // Switch condition to use 'b' sizeBefore = captured.size(); condition.set(false); - assertTrue("Effect should have been triggered", captured.size() > sizeBefore); + assertTrue(captured.size() > sizeBefore, "Effect should have been triggered"); assertEquals("B", captured.getLast()); } diff --git a/platform/core/io/src/test/java/tools/dynamia/io/IOUtilsBase64Test.java b/platform/core/io/src/test/java/tools/dynamia/io/IOUtilsBase64Test.java index db363ab7..d0a454c2 100644 --- a/platform/core/io/src/test/java/tools/dynamia/io/IOUtilsBase64Test.java +++ b/platform/core/io/src/test/java/tools/dynamia/io/IOUtilsBase64Test.java @@ -17,7 +17,7 @@ package tools.dynamia.io; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import java.io.File; import java.io.IOException; @@ -30,7 +30,7 @@ public void shouldEncodeFile() throws IOException { String expected = "JVBERi0xLjMNCiXi48/TDQoNCjEgMCBvYmoNCjw8DQovVHlwZSAvQ2F0YWxvZw0KL091dGxpbmVzIDIgMCBSDQovUGFnZXMgMyAwIFINCj4+DQplbmRvYmoNCg0KMiAwIG9iag0KPDwNCi9UeXBlIC9PdXRsaW5lcw0KL0NvdW50IDANCj4+DQplbmRvYmoNCg0KMyAwIG9iag0KPDwNCi9UeXBlIC9QYWdlcw0KL0NvdW50IDINCi9LaWRzIFsgNCAwIFIgNiAwIFIgXSANCj4+DQplbmRvYmoNCg0KNCAwIG9iag0KPDwNCi9UeXBlIC9QYWdlDQovUGFyZW50IDMgMCBSDQovUmVzb3VyY2VzIDw8DQovRm9udCA8PA0KL0YxIDkgMCBSIA0KPj4NCi9Qcm9jU2V0IDggMCBSDQo+Pg0KL01lZGlhQm94IFswIDAgNjEyLjAwMDAgNzkyLjAwMDBdDQovQ29udGVudHMgNSAwIFINCj4+DQplbmRvYmoNCg0KNSAwIG9iag0KPDwgL0xlbmd0aCAxMDc0ID4+DQpzdHJlYW0NCjIgSg0KQlQNCjAgMCAwIHJnDQovRjEgMDAyNyBUZg0KNTcuMzc1MCA3MjIuMjgwMCBUZA0KKCBBIFNpbXBsZSBQREYgRmlsZSApIFRqDQpFVA0KQlQNCi9GMSAwMDEwIFRmDQo2OS4yNTAwIDY4OC42MDgwIFRkDQooIFRoaXMgaXMgYSBzbWFsbCBkZW1vbnN0cmF0aW9uIC5wZGYgZmlsZSAtICkgVGoNCkVUDQpCVA0KL0YxIDAwMTAgVGYNCjY5LjI1MDAgNjY0LjcwNDAgVGQNCigganVzdCBmb3IgdXNlIGluIHRoZSBWaXJ0dWFsIE1lY2hhbmljcyB0dXRvcmlhbHMuIE1vcmUgdGV4dC4gQW5kIG1vcmUgKSBUag0KRVQNCkJUDQovRjEgMDAxMCBUZg0KNjkuMjUwMCA2NTIuNzUyMCBUZA0KKCB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiApIFRqDQpFVA0KQlQNCi9GMSAwMDEwIFRmDQo2OS4yNTAwIDYyOC44NDgwIFRkDQooIEFuZCBtb3JlIHRleHQuIEFuZCBtb3JlIHRleHQuIEFuZCBtb3JlIHRleHQuIEFuZCBtb3JlIHRleHQuIEFuZCBtb3JlICkgVGoNCkVUDQpCVA0KL0YxIDAwMTAgVGYNCjY5LjI1MDAgNjE2Ljg5NjAgVGQNCiggdGV4dC4gQW5kIG1vcmUgdGV4dC4gQm9yaW5nLCB6enp6ei4gQW5kIG1vcmUgdGV4dC4gQW5kIG1vcmUgdGV4dC4gQW5kICkgVGoNCkVUDQpCVA0KL0YxIDAwMTAgVGYNCjY5LjI1MDAgNjA0Ljk0NDAgVGQNCiggbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiApIFRqDQpFVA0KQlQNCi9GMSAwMDEwIFRmDQo2OS4yNTAwIDU5Mi45OTIwIFRkDQooIEFuZCBtb3JlIHRleHQuIEFuZCBtb3JlIHRleHQuICkgVGoNCkVUDQpCVA0KL0YxIDAwMTAgVGYNCjY5LjI1MDAgNTY5LjA4ODAgVGQNCiggQW5kIG1vcmUgdGV4dC4gQW5kIG1vcmUgdGV4dC4gQW5kIG1vcmUgdGV4dC4gQW5kIG1vcmUgdGV4dC4gQW5kIG1vcmUgKSBUag0KRVQNCkJUDQovRjEgMDAxMCBUZg0KNjkuMjUwMCA1NTcuMTM2MCBUZA0KKCB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBFdmVuIG1vcmUuIENvbnRpbnVlZCBvbiBwYWdlIDIgLi4uKSBUag0KRVQNCmVuZHN0cmVhbQ0KZW5kb2JqDQoNCjYgMCBvYmoNCjw8DQovVHlwZSAvUGFnZQ0KL1BhcmVudCAzIDAgUg0KL1Jlc291cmNlcyA8PA0KL0ZvbnQgPDwNCi9GMSA5IDAgUiANCj4+DQovUHJvY1NldCA4IDAgUg0KPj4NCi9NZWRpYUJveCBbMCAwIDYxMi4wMDAwIDc5Mi4wMDAwXQ0KL0NvbnRlbnRzIDcgMCBSDQo+Pg0KZW5kb2JqDQoNCjcgMCBvYmoNCjw8IC9MZW5ndGggNjc2ID4+DQpzdHJlYW0NCjIgSg0KQlQNCjAgMCAwIHJnDQovRjEgMDAyNyBUZg0KNTcuMzc1MCA3MjIuMjgwMCBUZA0KKCBTaW1wbGUgUERGIEZpbGUgMiApIFRqDQpFVA0KQlQNCi9GMSAwMDEwIFRmDQo2OS4yNTAwIDY4OC42MDgwIFRkDQooIC4uLmNvbnRpbnVlZCBmcm9tIHBhZ2UgMS4gWWV0IG1vcmUgdGV4dC4gQW5kIG1vcmUgdGV4dC4gQW5kIG1vcmUgdGV4dC4gKSBUag0KRVQNCkJUDQovRjEgMDAxMCBUZg0KNjkuMjUwMCA2NzYuNjU2MCBUZA0KKCBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSApIFRqDQpFVA0KQlQNCi9GMSAwMDEwIFRmDQo2OS4yNTAwIDY2NC43MDQwIFRkDQooIHRleHQuIE9oLCBob3cgYm9yaW5nIHR5cGluZyB0aGlzIHN0dWZmLiBCdXQgbm90IGFzIGJvcmluZyBhcyB3YXRjaGluZyApIFRqDQpFVA0KQlQNCi9GMSAwMDEwIFRmDQo2OS4yNTAwIDY1Mi43NTIwIFRkDQooIHBhaW50IGRyeS4gQW5kIG1vcmUgdGV4dC4gQW5kIG1vcmUgdGV4dC4gQW5kIG1vcmUgdGV4dC4gQW5kIG1vcmUgdGV4dC4gKSBUag0KRVQNCkJUDQovRjEgMDAxMCBUZg0KNjkuMjUwMCA2NDAuODAwMCBUZA0KKCBCb3JpbmcuICBNb3JlLCBhIGxpdHRsZSBtb3JlIHRleHQuIFRoZSBlbmQsIGFuZCBqdXN0IGFzIHdlbGwuICkgVGoNCkVUDQplbmRzdHJlYW0NCmVuZG9iag0KDQo4IDAgb2JqDQpbL1BERiAvVGV4dF0NCmVuZG9iag0KDQo5IDAgb2JqDQo8PA0KL1R5cGUgL0ZvbnQNCi9TdWJ0eXBlIC9UeXBlMQ0KL05hbWUgL0YxDQovQmFzZUZvbnQgL0hlbHZldGljYQ0KL0VuY29kaW5nIC9XaW5BbnNpRW5jb2RpbmcNCj4+DQplbmRvYmoNCg0KMTAgMCBvYmoNCjw8DQovQ3JlYXRvciAoUmF2ZSBcKGh0dHA6Ly93d3cubmV2cm9uYS5jb20vcmF2ZVwpKQ0KL1Byb2R1Y2VyIChOZXZyb25hIERlc2lnbnMpDQovQ3JlYXRpb25EYXRlIChEOjIwMDYwMzAxMDcyODI2KQ0KPj4NCmVuZG9iag0KDQp4cmVmDQowIDExDQowMDAwMDAwMDAwIDY1NTM1IGYNCjAwMDAwMDAwMTkgMDAwMDAgbg0KMDAwMDAwMDA5MyAwMDAwMCBuDQowMDAwMDAwMTQ3IDAwMDAwIG4NCjAwMDAwMDAyMjIgMDAwMDAgbg0KMDAwMDAwMDM5MCAwMDAwMCBuDQowMDAwMDAxNTIyIDAwMDAwIG4NCjAwMDAwMDE2OTAgMDAwMDAgbg0KMDAwMDAwMjQyMyAwMDAwMCBuDQowMDAwMDAyNDU2IDAwMDAwIG4NCjAwMDAwMDI1NzQgMDAwMDAgbg0KDQp0cmFpbGVyDQo8PA0KL1NpemUgMTENCi9Sb290IDEgMCBSDQovSW5mbyAxMCAwIFINCj4+DQoNCnN0YXJ0eHJlZg0KMjcxNA0KJSVFT0YNCg=="; String result = IOUtils.encodeBase64(IOUtils.getResource("classpath:sample.pdf").getFile()); - Assert.assertEquals(expected, result); + Assertions.assertEquals(expected, result); } //@Test @@ -39,10 +39,10 @@ public void shouldDecodeFile() throws IOException { File output = File.createTempFile("sample", ".pdf"); IOUtils.decodeBase64(input, output); - Assert.assertTrue(output.exists()); + Assertions.assertTrue(output.exists()); String test = IOUtils.encodeBase64(output); - Assert.assertEquals(input, test); + Assertions.assertEquals(input, test); } } diff --git a/platform/core/io/src/test/java/tools/dynamia/io/IOUtilsTest.java b/platform/core/io/src/test/java/tools/dynamia/io/IOUtilsTest.java index 4baf0476..152bcd75 100644 --- a/platform/core/io/src/test/java/tools/dynamia/io/IOUtilsTest.java +++ b/platform/core/io/src/test/java/tools/dynamia/io/IOUtilsTest.java @@ -16,36 +16,36 @@ */ package tools.dynamia.io; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import java.io.File; import java.io.IOException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * * @author Mario A. Serrano Leones */ -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(locations = {"/appContext.xml"}) public class IOUtilsTest { public IOUtilsTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() { } - @AfterClass + @AfterAll public static void tearDownClass() { } diff --git a/platform/core/io/src/test/java/tools/dynamia/io/converters/ConvertersTest.java b/platform/core/io/src/test/java/tools/dynamia/io/converters/ConvertersTest.java index 1940ccbd..f8b4086a 100644 --- a/platform/core/io/src/test/java/tools/dynamia/io/converters/ConvertersTest.java +++ b/platform/core/io/src/test/java/tools/dynamia/io/converters/ConvertersTest.java @@ -16,13 +16,13 @@ */ package tools.dynamia.io.converters; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import tools.dynamia.integration.Containers; import tools.dynamia.integration.SimpleObjectContainer; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Mario A. Serrano Leones @@ -32,7 +32,7 @@ public class ConvertersTest { public ConvertersTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() { var container = new SimpleObjectContainer(); container.addObject("int", new IntegerConverter()); @@ -41,7 +41,7 @@ public static void setUpClass() { Containers.get().installObjectContainer(container); } - @AfterClass + @AfterAll public static void tearDownClass() { } diff --git a/platform/core/navigation/src/test/java/tools/dynamia/navigation/AppTest.java b/platform/core/navigation/src/test/java/tools/dynamia/navigation/AppTest.java index 4ca0a518..efb1f9ac 100644 --- a/platform/core/navigation/src/test/java/tools/dynamia/navigation/AppTest.java +++ b/platform/core/navigation/src/test/java/tools/dynamia/navigation/AppTest.java @@ -16,35 +16,19 @@ */ package tools.dynamia.navigation; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Unit test for simple App. */ -public class AppTest - extends TestCase { - - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest(String testName) { - super(testName); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() { - return new TestSuite(AppTest.class); - } +public class AppTest { /** * Rigourous Test :-) */ + @Test public void testApp() { assertTrue(true); } diff --git a/platform/core/navigation/src/test/java/tools/dynamia/navigation/JavaModuleBuilderTest.java b/platform/core/navigation/src/test/java/tools/dynamia/navigation/JavaModuleBuilderTest.java index f8ace602..1086a8bd 100644 --- a/platform/core/navigation/src/test/java/tools/dynamia/navigation/JavaModuleBuilderTest.java +++ b/platform/core/navigation/src/test/java/tools/dynamia/navigation/JavaModuleBuilderTest.java @@ -16,9 +16,9 @@ */ package tools.dynamia.navigation; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/platform/core/navigation/src/test/java/tools/dynamia/navigation/ModuleInstallerTest.java b/platform/core/navigation/src/test/java/tools/dynamia/navigation/ModuleInstallerTest.java index c005f2f4..0f6870f2 100644 --- a/platform/core/navigation/src/test/java/tools/dynamia/navigation/ModuleInstallerTest.java +++ b/platform/core/navigation/src/test/java/tools/dynamia/navigation/ModuleInstallerTest.java @@ -16,9 +16,9 @@ */ package tools.dynamia.navigation; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Mario A. Serrano Leones diff --git a/platform/core/navigation/src/test/java/tools/dynamia/navigation/TreeSetImplTest.java b/platform/core/navigation/src/test/java/tools/dynamia/navigation/TreeSetImplTest.java index ea39c297..b4e106e8 100644 --- a/platform/core/navigation/src/test/java/tools/dynamia/navigation/TreeSetImplTest.java +++ b/platform/core/navigation/src/test/java/tools/dynamia/navigation/TreeSetImplTest.java @@ -16,10 +16,10 @@ */ package tools.dynamia.navigation; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; /** * diff --git a/platform/core/reports/src/test/java/tools/dynamia/reports/excel/ExcelPagedListDatasourceTest.java b/platform/core/reports/src/test/java/tools/dynamia/reports/excel/ExcelPagedListDatasourceTest.java index 9b797b5a..a856cc7d 100644 --- a/platform/core/reports/src/test/java/tools/dynamia/reports/excel/ExcelPagedListDatasourceTest.java +++ b/platform/core/reports/src/test/java/tools/dynamia/reports/excel/ExcelPagedListDatasourceTest.java @@ -20,13 +20,13 @@ import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import tools.dynamia.commons.collect.PagedList; import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ExcelPagedListDatasourceTest { diff --git a/platform/core/viewers/src/test/java/tools/dynamia/viewers/ViewDescriptorBuilderTest.java b/platform/core/viewers/src/test/java/tools/dynamia/viewers/ViewDescriptorBuilderTest.java index 263a6859..a717a358 100644 --- a/platform/core/viewers/src/test/java/tools/dynamia/viewers/ViewDescriptorBuilderTest.java +++ b/platform/core/viewers/src/test/java/tools/dynamia/viewers/ViewDescriptorBuilderTest.java @@ -16,9 +16,9 @@ */ package tools.dynamia.viewers; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static tools.dynamia.viewers.ViewDescriptorBuilder.field; import static tools.dynamia.viewers.ViewDescriptorBuilder.viewDescriptor; diff --git a/platform/core/web/src/test/java/tools/dynamia/web/util/HttpUtilsTest.java b/platform/core/web/src/test/java/tools/dynamia/web/util/HttpUtilsTest.java index 3fb07eab..77fd319b 100644 --- a/platform/core/web/src/test/java/tools/dynamia/web/util/HttpUtilsTest.java +++ b/platform/core/web/src/test/java/tools/dynamia/web/util/HttpUtilsTest.java @@ -16,8 +16,8 @@ */ package tools.dynamia.web.util; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.Map; @@ -33,7 +33,7 @@ public void shouldFormatHttpParams() { String result = HttpUtils.formatRequestParams(params); - Assert.assertTrue(result.contains("id=123")); - Assert.assertTrue(result.contains("name=mario")); + Assertions.assertTrue(result.contains("id=123")); + Assertions.assertTrue(result.contains("name=mario")); } } diff --git a/platform/ui/ui-shared/src/test/java/tools/dynamia/ui/IconTest.java b/platform/ui/ui-shared/src/test/java/tools/dynamia/ui/IconTest.java index 001e6345..99fca9b8 100644 --- a/platform/ui/ui-shared/src/test/java/tools/dynamia/ui/IconTest.java +++ b/platform/ui/ui-shared/src/test/java/tools/dynamia/ui/IconTest.java @@ -1,6 +1,6 @@ package tools.dynamia.ui; -import org.junit.Test; +import org.junit.jupiter.api.Test; import tools.dynamia.ui.icons.IconName; import tools.dynamia.ui.icons.Icons; diff --git a/platform/ui/zk/src/test/java/tools/dynamia/zk/ComponentAliasTest.java b/platform/ui/zk/src/test/java/tools/dynamia/zk/ComponentAliasTest.java index a604cdc1..72497402 100644 --- a/platform/ui/zk/src/test/java/tools/dynamia/zk/ComponentAliasTest.java +++ b/platform/ui/zk/src/test/java/tools/dynamia/zk/ComponentAliasTest.java @@ -16,11 +16,11 @@ */ package tools.dynamia.zk; -import org.junit.Test; +import org.junit.jupiter.api.Test; import tools.dynamia.zk.ui.Colorbox; import tools.dynamia.zk.ui.Iconbox; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/platform/ui/zk/src/test/java/tools/dynamia/zk/ui/ProviderPickerBoxTest.java b/platform/ui/zk/src/test/java/tools/dynamia/zk/ui/ProviderPickerBoxTest.java index 6c54b3b5..db4cf936 100644 --- a/platform/ui/zk/src/test/java/tools/dynamia/zk/ui/ProviderPickerBoxTest.java +++ b/platform/ui/zk/src/test/java/tools/dynamia/zk/ui/ProviderPickerBoxTest.java @@ -16,7 +16,7 @@ */ package tools.dynamia.zk.ui; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.zkoss.zul.ListModelList; import tools.dynamia.integration.Containers; import tools.dynamia.integration.SimpleObjectContainer; @@ -36,7 +36,7 @@ public void shouldHas2Providers() { ProviderPickerBox box = new ProviderPickerBox(); box.setClassName(MyProvider.class.getName()); - Assert.assertEquals(2, box.getModel().getSize()); + Assertions.assertEquals(2, box.getModel().getSize()); } public void shouldSelectProvider() { @@ -47,9 +47,9 @@ public void shouldSelectProvider() { box.setSelected(DefaultProvider.ID); ListModelList model = (ListModelList) box.getModel(); - Assert.assertFalse(model.getSelection().isEmpty()); + Assertions.assertFalse(model.getSelection().isEmpty()); //noinspection unchecked - model.getSelection().forEach(p -> Assert.assertEquals(DefaultProvider.class, p.getClass())); + model.getSelection().forEach(p -> Assertions.assertEquals(DefaultProvider.class, p.getClass())); } static class DefaultProvider implements MyProvider { diff --git a/platform/ui/zk/src/test/java/tools/dynamia/zk/viewers/DefaultFieldCustomizerTest.java b/platform/ui/zk/src/test/java/tools/dynamia/zk/viewers/DefaultFieldCustomizerTest.java index 5165861b..b7087efa 100644 --- a/platform/ui/zk/src/test/java/tools/dynamia/zk/viewers/DefaultFieldCustomizerTest.java +++ b/platform/ui/zk/src/test/java/tools/dynamia/zk/viewers/DefaultFieldCustomizerTest.java @@ -18,7 +18,7 @@ package tools.dynamia.zk.viewers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.zkoss.zul.Combobox; import org.zkoss.zul.Datebox; import org.zkoss.zul.Intbox; @@ -34,8 +34,8 @@ import java.time.LocalDate; import java.util.Date; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * @author Mario A. Serrano Leones diff --git a/platform/ui/zk/src/test/java/tools/dynamia/zk/viewers/TableViewDescriptorBuilderTest.java b/platform/ui/zk/src/test/java/tools/dynamia/zk/viewers/TableViewDescriptorBuilderTest.java index f3c20327..9b2c23c0 100644 --- a/platform/ui/zk/src/test/java/tools/dynamia/zk/viewers/TableViewDescriptorBuilderTest.java +++ b/platform/ui/zk/src/test/java/tools/dynamia/zk/viewers/TableViewDescriptorBuilderTest.java @@ -16,8 +16,8 @@ */ package tools.dynamia.zk.viewers; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import tools.dynamia.integration.Containers; import tools.dynamia.integration.SimpleObjectContainer; import tools.dynamia.io.converters.ClassConverter; @@ -29,7 +29,7 @@ import java.util.Map; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static tools.dynamia.zk.viewers.table.TableViewDescriptorBuilder.column; import static tools.dynamia.zk.viewers.table.TableViewDescriptorBuilder.f; import static tools.dynamia.zk.viewers.table.TableViewDescriptorBuilder.h; @@ -42,7 +42,7 @@ public class TableViewDescriptorBuilderTest { private ViewDescriptorFactory factory; - @Before + @BeforeEach public void initFactory() { factory = new DefaultViewDescriptorFactory(); var container = new SimpleObjectContainer(); diff --git a/platform/ui/zk/src/test/java/tools/dynamia/zk/viewers/ViewDescriptorReaderTest.java b/platform/ui/zk/src/test/java/tools/dynamia/zk/viewers/ViewDescriptorReaderTest.java index 7cf52bf8..7a444ba2 100644 --- a/platform/ui/zk/src/test/java/tools/dynamia/zk/viewers/ViewDescriptorReaderTest.java +++ b/platform/ui/zk/src/test/java/tools/dynamia/zk/viewers/ViewDescriptorReaderTest.java @@ -17,8 +17,8 @@ package tools.dynamia.zk.viewers; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.zkoss.zul.Intbox; import org.zkoss.zul.Textbox; import tools.dynamia.integration.Containers; @@ -38,17 +38,17 @@ import java.io.InputStreamReader; import java.io.Reader; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Mario A. Serrano Leones */ public class ViewDescriptorReaderTest { - @Before + @BeforeEach public void configContainer() { var container = new SimpleObjectContainer(); container.addObject("yml", new YamlViewDescriptorReader()); diff --git a/platform/ui/zk/src/test/java/tools/dynamia/zk/viewers/ViewDescriptorTest.java b/platform/ui/zk/src/test/java/tools/dynamia/zk/viewers/ViewDescriptorTest.java index 93e50673..c2c5ad83 100644 --- a/platform/ui/zk/src/test/java/tools/dynamia/zk/viewers/ViewDescriptorTest.java +++ b/platform/ui/zk/src/test/java/tools/dynamia/zk/viewers/ViewDescriptorTest.java @@ -20,8 +20,8 @@ package tools.dynamia.zk.viewers; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import tools.dynamia.integration.Containers; import tools.dynamia.integration.SimpleObjectContainer; import tools.dynamia.io.converters.ClassConverter; @@ -31,9 +31,9 @@ import tools.dynamia.viewers.impl.DefaultViewDescriptorFactory; import tools.dynamia.viewers.impl.YamlViewDescriptorReader; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @@ -41,7 +41,7 @@ */ public class ViewDescriptorTest { - @Before + @BeforeEach public void configContainer(){ var container = new SimpleObjectContainer(); container.addObject("yml", new YamlViewDescriptorReader()); diff --git a/pom.xml b/pom.xml index 5e4d2fc8..e07d76c0 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,6 @@ 2.0.17 - 4.13.2 1.8.0.10 6.5.0 5.14.0 @@ -180,8 +179,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test