From 27bd8bc57093abe4a94204c045ebaf9f2be189a1 Mon Sep 17 00:00:00 2001 From: Yash Ramani Date: Thu, 9 Jan 2025 16:10:10 -0500 Subject: [PATCH] Replace junit4 with junit5.jupiter.api for tests (#500) --- .../artifacts/repository/TestRepository.java | 54 ++-- .../handlers/entities/TestEntityProvider.java | 28 +- .../generations/TestGenerationsProvider.java | 94 +++--- .../purge/TestArtifactsPurgeService.java | 124 ++++---- .../TestVersionsMismatchService.java | 66 ++--- .../refresh/TestArtifactsRefreshService.java | 278 +++++++++--------- ...actsRefreshServiceExceptionEscenarios.java | 28 +- .../TestArtifactsRefreshServiceWithMocks.java | 16 +- .../artifacts/refresh/TestManifestLoader.java | 10 +- .../TestProjectVersionRefreshHandler.java | 76 ++--- .../TestRefreshDependenciesService.java | 64 ++-- .../mongo/artifacts/TestArtifactMongo.java | 26 +- .../mongo/artifacts/TestMongoAdminStore.java | 12 +- .../TestBasicAuthorisationProvider.java | 14 +- .../domain/project/TestProjectUtilities.java | 38 +-- .../resources/TestProjectsResource.java | 12 +- .../TestProjectsVersionsResource.java | 32 +- .../depot/services/TestBaseServices.java | 4 +- .../projects/TestProjectsService.java | 262 ++++++++--------- .../store/mongo/CoreDataMongoStoreTests.java | 22 +- .../migrations/TestDependenciesMigration.java | 46 +-- .../TestProjectVersionMigrations.java | 56 ++-- .../mongo/projects/TestQueryProjectApi.java | 24 +- .../projects/TestQueryProjectVersionApi.java | 40 +-- .../mongo/projects/TestUpdateProjectApi.java | 72 ++--- .../projects/TestUpdateProjectVersionApi.java | 34 +-- .../services/schedules/TestSchedules.java | 38 +-- .../metrics/TestPrometheusHandler.java | 52 ++-- .../metrics/TestResourceApiTracing.java | 6 +- .../resources/TestEntitiesResource.java | 62 ++-- .../entities/TestEntitiesService.java | 124 ++++---- .../mongo/admin/TestMongoAdminStore.java | 18 +- .../migrations/TestEntitiesMigration.java | 36 +-- .../entities/TestQueryClassifierPath.java | 50 ++-- .../mongo/entities/TestQueryRevisions.java | 48 +-- .../mongo/entities/TestQueryVersions.java | 58 ++-- .../mongo/entities/TestUpdateVersions.java | 88 +++--- .../entities/test/EntitiesMongoTestUtils.java | 12 +- .../loader/TestFileGenerationLoader.java | 10 +- .../TestFileGenerationsService.java | 90 +++--- .../generations/TestFileGenerationsStore.java | 38 +-- .../TestGenerationsStoreMongo.java | 12 +- .../metrics/query/TestMetricsServices.java | 78 ++--- .../legend/depot/domain/DatesHandlerTest.java | 6 +- .../domain/version/TestVersionValidator.java | 12 +- .../notifications/queue/TestQueueMongo.java | 68 ++--- .../TestNotificationQueueManager.java | 70 ++--- .../TestNotificationsResource.java | 28 +- .../notifications/TestNotificationsMongo.java | 52 ++-- .../TestPureModelContextDataResource.java | 20 +- .../context/TestPureModelContextService.java | 76 ++--- .../depot/store/mongo/TestStoreMongo.java | 4 +- pom.xml | 11 +- 53 files changed, 1353 insertions(+), 1346 deletions(-) diff --git a/legend-depot-artifacts-repository-maven-impl/src/test/java/org/finos/legend/depot/services/artifacts/repository/TestRepository.java b/legend-depot-artifacts-repository-maven-impl/src/test/java/org/finos/legend/depot/services/artifacts/repository/TestRepository.java index 9574c7340..dd9c70952 100644 --- a/legend-depot-artifacts-repository-maven-impl/src/test/java/org/finos/legend/depot/services/artifacts/repository/TestRepository.java +++ b/legend-depot-artifacts-repository-maven-impl/src/test/java/org/finos/legend/depot/services/artifacts/repository/TestRepository.java @@ -21,8 +21,8 @@ import org.finos.legend.depot.domain.artifacts.repository.ArtifactType; import org.finos.legend.depot.services.artifacts.repository.maven.TestMavenArtifactsRepository; import org.finos.legend.sdlc.domain.model.version.VersionId; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.File; import java.util.List; @@ -43,11 +43,11 @@ public void canResolveVersionsRanges() } catch (Exception e) { - Assert.fail(); + Assertions.fail(); } - Assert.assertNotNull(versions); - Assert.assertEquals(2, versions.size()); + Assertions.assertNotNull(versions); + Assertions.assertEquals(2, versions.size()); } @Test @@ -60,11 +60,11 @@ public void canResolveVersionsRangesForProjectsWithBranches() } catch (Exception e) { - Assert.fail(); + Assertions.fail(); } - Assert.assertNotNull(versions); - Assert.assertEquals(2, versions.size()); + Assertions.assertNotNull(versions); + Assertions.assertEquals(2, versions.size()); } @Test @@ -76,7 +76,7 @@ public void returnsNoVersionsIfTheyDontExists() } catch (Exception e) { - Assert.assertTrue(e instanceof ArtifactNotFoundException); + Assertions.assertTrue(e instanceof ArtifactNotFoundException); } } @@ -85,39 +85,39 @@ public void returnsNoVersionsIfTheyDontExists() public void canGetDependencies() { Set dependencies = repository.findDependencies(GROUP_ID, "test", "1.0.0"); - Assert.assertEquals(1, dependencies.size()); - Assert.assertEquals(GROUP_ID, dependencies.stream().findFirst().get().getGroupId()); - Assert.assertEquals("test-dependencies", dependencies.stream().findFirst().get().getArtifactId()); - Assert.assertEquals("1.0.0", dependencies.stream().findFirst().get().getVersion()); + Assertions.assertEquals(1, dependencies.size()); + Assertions.assertEquals(GROUP_ID, dependencies.stream().findFirst().get().getGroupId()); + Assertions.assertEquals("test-dependencies", dependencies.stream().findFirst().get().getArtifactId()); + Assertions.assertEquals("1.0.0", dependencies.stream().findFirst().get().getVersion()); } @Test public void canGetFileDependenciesByType() { Set dependencies = repository.findDependenciesByArtifactType(ArtifactType.ENTITIES,GROUP_ID, "test", "1.0.0"); - Assert.assertEquals(1, dependencies.size()); - Assert.assertEquals(GROUP_ID, dependencies.stream().findFirst().get().getGroupId()); - Assert.assertEquals("test-dependencies-entities", dependencies.stream().findFirst().get().getArtifactId()); - Assert.assertEquals("1.0.0", dependencies.stream().findFirst().get().getVersion()); + Assertions.assertEquals(1, dependencies.size()); + Assertions.assertEquals(GROUP_ID, dependencies.stream().findFirst().get().getGroupId()); + Assertions.assertEquals("test-dependencies-entities", dependencies.stream().findFirst().get().getArtifactId()); + Assertions.assertEquals("1.0.0", dependencies.stream().findFirst().get().getVersion()); Set dependencySet = repository.findDependenciesByArtifactType(ArtifactType.VERSIONED_ENTITIES,GROUP_ID, "test", "1.0.0"); - Assert.assertEquals(1, dependencySet.size()); - Assert.assertEquals(GROUP_ID, dependencySet.stream().findFirst().get().getGroupId()); - Assert.assertEquals("test-dependencies-versioned-entities", dependencySet.stream().findFirst().get().getArtifactId()); - Assert.assertEquals("1.0.0", dependencySet.stream().findFirst().get().getVersion()); + Assertions.assertEquals(1, dependencySet.size()); + Assertions.assertEquals(GROUP_ID, dependencySet.stream().findFirst().get().getGroupId()); + Assertions.assertEquals("test-dependencies-versioned-entities", dependencySet.stream().findFirst().get().getArtifactId()); + Assertions.assertEquals("1.0.0", dependencySet.stream().findFirst().get().getVersion()); } @Test public void canFindFilesByTpe() { List files = repository.findFiles(ArtifactType.ENTITIES,GROUP_ID,"test","1.0.0"); - Assert.assertNotNull(files); - Assert.assertEquals(1,files.size()); - Assert.assertEquals("test-entities-1.0.0.jar",files.get(0).getName()); + Assertions.assertNotNull(files); + Assertions.assertEquals(1,files.size()); + Assertions.assertEquals("test-entities-1.0.0.jar",files.get(0).getName()); List filesForVersionedEntities = repository.findFiles(ArtifactType.VERSIONED_ENTITIES,GROUP_ID,"test","1.0.0"); - Assert.assertNotNull(filesForVersionedEntities); - Assert.assertEquals(1,filesForVersionedEntities.size()); - Assert.assertEquals("test-versioned-entities-1.0.0.jar",filesForVersionedEntities.get(0).getName()); + Assertions.assertNotNull(filesForVersionedEntities); + Assertions.assertEquals(1,filesForVersionedEntities.size()); + Assertions.assertEquals("test-versioned-entities-1.0.0.jar",filesForVersionedEntities.get(0).getName()); } } diff --git a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/handlers/entities/TestEntityProvider.java b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/handlers/entities/TestEntityProvider.java index 3d832a79f..396e26965 100644 --- a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/handlers/entities/TestEntityProvider.java +++ b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/handlers/entities/TestEntityProvider.java @@ -23,8 +23,8 @@ import org.finos.legend.depot.services.artifacts.repository.maven.TestMavenArtifactsRepository; import org.finos.legend.depot.services.api.artifacts.handlers.entties.EntityArtifactsProvider; import org.finos.legend.sdlc.domain.model.entity.Entity; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.File; import java.util.List; @@ -47,8 +47,8 @@ List getFiles(String group, String artifact, String version) public void canResolvePOM() { Model pom = repository.getPOM(TEST_GROUP_ID, "test-dependencies-entities", "1.0.0"); - Assert.assertNotNull(pom); - Assert.assertNotNull(pom.getParent()); + Assertions.assertNotNull(pom); + Assertions.assertNotNull(pom.getParent()); } @@ -57,8 +57,8 @@ public void canResolveEntitiesInJar() { List entities = artifactProvider.extractArtifacts(getFiles(TEST_GROUP_ID, "test", "2.0.0")); - Assert.assertNotNull(entities); - Assert.assertEquals(9, entities.size()); + Assertions.assertNotNull(entities); + Assertions.assertEquals(9, entities.size()); } @@ -67,16 +67,16 @@ public void canResolveEntitiesInJar() public void canResolveDependencies() { Set dependencies = repository.findDependenciesByArtifactType(ArtifactType.ENTITIES, TEST_GROUP_ID, "test", "2.0.0"); - Assert.assertEquals(1, dependencies.size()); + Assertions.assertEquals(1, dependencies.size()); List files = repository.findDependenciesFiles(ArtifactType.ENTITIES, TEST_GROUP_ID, "test", "2.0.0"); - Assert.assertNotNull(files); - Assert.assertEquals(1, files.size()); + Assertions.assertNotNull(files); + Assertions.assertEquals(1, files.size()); Set dependenciesForVersionedEntities = repository.findDependenciesByArtifactType(ArtifactType.VERSIONED_ENTITIES, TEST_GROUP_ID, "test", "2.0.0"); - Assert.assertEquals(1, dependenciesForVersionedEntities.size()); + Assertions.assertEquals(1, dependenciesForVersionedEntities.size()); List versionedEntitiesFiles = repository.findDependenciesFiles(ArtifactType.ENTITIES, TEST_GROUP_ID, "test", "2.0.0"); - Assert.assertNotNull(versionedEntitiesFiles); - Assert.assertEquals(1, versionedEntitiesFiles.size()); + Assertions.assertNotNull(versionedEntitiesFiles); + Assertions.assertEquals(1, versionedEntitiesFiles.size()); } @@ -85,13 +85,13 @@ public void canResolveDependencies() public void canResolveJar() { File jarFile = repository.getJarFile(TEST_GROUP_ID, "test-dependencies-entities", "1.0.0"); - Assert.assertNotNull(jarFile); + Assertions.assertNotNull(jarFile); } @Test public void canHandleJarNotPresent() { File jarFile = repository.getJarFile(TEST_GROUP_ID, "test-non-existing-entities", "1.0.0"); - Assert.assertNull(jarFile); + Assertions.assertNull(jarFile); } } diff --git a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/handlers/generations/TestGenerationsProvider.java b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/handlers/generations/TestGenerationsProvider.java index 059982d9e..966b9e2f8 100644 --- a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/handlers/generations/TestGenerationsProvider.java +++ b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/handlers/generations/TestGenerationsProvider.java @@ -37,9 +37,9 @@ import org.finos.legend.depot.store.mongo.generations.FileGenerationsMongo; import org.finos.legend.depot.services.api.notifications.queue.Queue; import org.finos.legend.sdlc.domain.model.entity.Entity; -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 java.io.File; import java.net.URL; @@ -73,7 +73,7 @@ public class TestGenerationsProvider extends TestStoreMongo private final ManageFileGenerationsService generations = new ManageFileGenerationsServiceImpl(new FileGenerationsMongo(mongoProvider), new ProjectsServiceImpl(projectsVersions,projects,metrics,queue,new ProjectsConfiguration("master"))); private final FileGenerationHandlerImpl handler = spy(new FileGenerationHandlerImpl(repository, provider, generations)); - @Before + @BeforeEach public void setup() { when(projects.find(TEST_GROUP_ID, TEST_ARTIFACT_ID)).thenReturn(Optional.of(new StoreProjectData(PRODUCT_A, TEST_GROUP_ID, TEST_ARTIFACT_ID))); @@ -95,29 +95,29 @@ private List getDependenciesFiles(String versionId) public void canResolveGenerationsInJar() { List files = getFiles("2.0.0"); - Assert.assertNotNull(files); + Assertions.assertNotNull(files); - Assert.assertEquals(1, files.size()); + Assertions.assertEquals(1, files.size()); - Assert.assertEquals(0, getDependenciesFiles("2.0.0").size()); + Assertions.assertEquals(0, getDependenciesFiles("2.0.0").size()); List gens = fileGenerationsProvider.extractArtifacts(files); - Assert.assertFalse(gens.isEmpty()); + Assertions.assertFalse(gens.isEmpty()); } @Test public void canRefreshRevisions() { - Assert.assertTrue(generations.getAll().isEmpty()); + Assertions.assertTrue(generations.getAll().isEmpty()); FileGenerationHandlerImpl handler = new FileGenerationHandlerImpl(repository, fileGenerationsProvider, generations); StoreProjectData projectData = projects.find(TEST_GROUP_ID, TEST_ARTIFACT_ID).get(); MetadataNotificationResponse response = handler.refreshProjectVersionArtifacts(projectData.getGroupId(),projectData.getArtifactId(), BRANCH_SNAPSHOT("master"), getFiles(BRANCH_SNAPSHOT("master"))); - Assert.assertNotNull(response); - Assert.assertFalse(response.hasErrors()); + Assertions.assertNotNull(response); + Assertions.assertFalse(response.hasErrors()); List fileGenerations = generations.getAll(); - Assert.assertNotNull(fileGenerations); - Assert.assertEquals(14, fileGenerations.size()); + Assertions.assertNotNull(fileGenerations); + Assertions.assertEquals(14, fileGenerations.size()); } @@ -125,23 +125,23 @@ public void canRefreshRevisions() public void canRefreshRevisionWithChangeInGenerations() { URL filePath = this.getClass().getClassLoader().getResource("repository/examples/metadata/test-file-generation/master-SNAPSHOT/test-file-generation-new-master-SNAPSHOT.jar"); - Assert.assertTrue(generations.getAll().isEmpty()); + Assertions.assertTrue(generations.getAll().isEmpty()); FileGenerationHandlerImpl handler = new FileGenerationHandlerImpl(repository, fileGenerationsProvider, generations); StoreProjectData projectData = projects.find(TEST_GROUP_ID, TEST_ARTIFACT_ID).get(); //deleted one generation as part of new master snapshot version MetadataNotificationResponse response = handler.refreshProjectVersionArtifacts(projectData.getGroupId(),projectData.getArtifactId(), BRANCH_SNAPSHOT("master"),Arrays.asList(new File(filePath.getFile()))); - Assert.assertNotNull(response); - Assert.assertFalse(response.hasErrors()); + Assertions.assertNotNull(response); + Assertions.assertFalse(response.hasErrors()); List fileGenerations = generations.getAll(); - Assert.assertNotNull(fileGenerations); - Assert.assertEquals(13, fileGenerations.size()); + Assertions.assertNotNull(fileGenerations); + Assertions.assertEquals(13, fileGenerations.size()); } @Test public void canGetTheRightElementPathFromGeneratedFile() { - Assert.assertTrue(generations.getAll().isEmpty()); + Assertions.assertTrue(generations.getAll().isEmpty()); List projectEntities = new ArrayList<>(Arrays.asList(new EntityDefinition("examples::metadata::snowFlakeApp", "", Collections.emptyMap()), new EntityDefinition("examples::metadata::snowFlakeApp2", "", Collections.emptyMap()))); List generatedFiles = new ArrayList<>(Arrays.asList(new DepotGeneration("/examples/metadata/snowFlakeApp/searchDocuments/SearchDocumentResult.json", ""), new DepotGeneration("/examples/metadata/snowFlakeApp2/searchDocuments/SearchDocumentResult.json", ""))); StoreProjectData projectData = projects.find(TEST_GROUP_ID, TEST_ARTIFACT_ID).get(); @@ -150,40 +150,40 @@ public void canGetTheRightElementPathFromGeneratedFile() doReturn(projectEntities).when(this.handler).getAllNonVersionedEntities(projectData.getGroupId(), projectData.getArtifactId(), "2.0.0"); MetadataNotificationResponse response = this.handler.refreshProjectVersionArtifacts(projectData.getGroupId(),projectData.getArtifactId(), "2.0.0", files); - Assert.assertNotNull(response); - Assert.assertFalse(response.hasErrors()); + Assertions.assertNotNull(response); + Assertions.assertFalse(response.hasErrors()); List fileGenerations = generations.getAll(); - Assert.assertNotNull(fileGenerations); - Assert.assertEquals(2, fileGenerations.size()); - Assert.assertEquals(1, fileGenerations.stream().filter(f -> f.getPath().equals("examples::metadata::snowFlakeApp")).count()); - Assert.assertEquals(1, fileGenerations.stream().filter(f -> f.getPath().equals("examples::metadata::snowFlakeApp2")).count()); + Assertions.assertNotNull(fileGenerations); + Assertions.assertEquals(2, fileGenerations.size()); + Assertions.assertEquals(1, fileGenerations.stream().filter(f -> f.getPath().equals("examples::metadata::snowFlakeApp")).count()); + Assertions.assertEquals(1, fileGenerations.stream().filter(f -> f.getPath().equals("examples::metadata::snowFlakeApp2")).count()); StoredFileGeneration storedFileGeneration = fileGenerations.stream().filter(f -> f.getPath().equals("examples::metadata::snowFlakeApp")).findFirst().get(); StoredFileGeneration storedFileGeneration2 = fileGenerations.stream().filter(f -> f.getPath().equals("examples::metadata::snowFlakeApp2")).findFirst().get(); - Assert.assertEquals(generatedFiles.get(0).getPath(), storedFileGeneration.getFile().getPath()); - Assert.assertEquals(generatedFiles.get(1).getPath(), storedFileGeneration2.getFile().getPath()); + Assertions.assertEquals(generatedFiles.get(0).getPath(), storedFileGeneration.getFile().getPath()); + Assertions.assertEquals(generatedFiles.get(1).getPath(), storedFileGeneration2.getFile().getPath()); List searchDocuments = generations.findByType(TEST_GROUP_ID,TEST_ARTIFACT_ID, "2.0.0", "searchDocuments"); - Assert.assertEquals(2, searchDocuments.size()); + Assertions.assertEquals(2, searchDocuments.size()); List snowFlakeAppSearchDocuments = generations.findByTypeAndElementPath(TEST_GROUP_ID,TEST_ARTIFACT_ID, "2.0.0", "searchDocuments", "examples::metadata::snowFlakeApp"); - Assert.assertEquals(1, snowFlakeAppSearchDocuments.size()); + Assertions.assertEquals(1, snowFlakeAppSearchDocuments.size()); StoredFileGeneration storedFileGeneration1 = snowFlakeAppSearchDocuments.get(0); - Assert.assertEquals(storedFileGeneration1.getPath(),"examples::metadata::snowFlakeApp"); - Assert.assertEquals(storedFileGeneration1.getType(),"searchDocuments"); + Assertions.assertEquals(storedFileGeneration1.getPath(),"examples::metadata::snowFlakeApp"); + Assertions.assertEquals(storedFileGeneration1.getType(),"searchDocuments"); } @Test public void canRefreshVersions() { - Assert.assertTrue(generations.getAll().isEmpty()); + Assertions.assertTrue(generations.getAll().isEmpty()); FileGenerationHandlerImpl handler = new FileGenerationHandlerImpl(repository, fileGenerationsProvider, generations); StoreProjectData projectData = projects.find(TEST_GROUP_ID, TEST_ARTIFACT_ID).get(); MetadataNotificationResponse response = handler.refreshProjectVersionArtifacts(projectData.getGroupId(),projectData.getArtifactId(), "2.0.0", getFiles("2.0.0")); - Assert.assertNotNull(response); - Assert.assertFalse(response.hasErrors()); + Assertions.assertNotNull(response); + Assertions.assertFalse(response.hasErrors()); List fileGenerations = generations.getAll(); - Assert.assertNotNull(fileGenerations); - Assert.assertEquals(12, fileGenerations.size()); + Assertions.assertNotNull(fileGenerations); + Assertions.assertEquals(12, fileGenerations.size()); } @@ -191,34 +191,34 @@ public void canRefreshVersions() @Test public void canReadFileGenerationArtifactsWithMultipleGenerations() { - Assert.assertTrue(generations.getAll().isEmpty()); + Assertions.assertTrue(generations.getAll().isEmpty()); FileGenerationHandlerImpl handler = new FileGenerationHandlerImpl(repository, fileGenerationsProvider, generations); StoreProjectData projectData = projects.find(TEST_GROUP_ID, TEST_ARTIFACT_ID).get(); MetadataNotificationResponse response = handler.refreshProjectVersionArtifacts(projectData.getGroupId(),projectData.getArtifactId(), "2.0.0", getFiles("2.0.0")); - Assert.assertNotNull(response); + Assertions.assertNotNull(response); - Assert.assertFalse(response.hasErrors()); + Assertions.assertFalse(response.hasErrors()); List fileGenerations = generations.getAll(); - Assert.assertNotNull(fileGenerations); - Assert.assertEquals(12, fileGenerations.size()); + Assertions.assertNotNull(fileGenerations); + Assertions.assertEquals(12, fileGenerations.size()); - Assert.assertEquals(4, generations.findByType(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0", "java").size()); - Assert.assertEquals(2, generations.findByType(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0", "my-ext").size()); + Assertions.assertEquals(4, generations.findByType(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0", "java").size()); + Assertions.assertEquals(2, generations.findByType(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0", "my-ext").size()); } - @Test(expected = IllegalArgumentException.class) + @Test public void canGetGenerationsForNonExistentVersion() { - generations.getFileGenerations(TEST_GROUP_ID,TEST_ARTIFACT_ID,"10.0.0"); + Assertions.assertThrows(IllegalArgumentException.class, () -> generations.getFileGenerations(TEST_GROUP_ID,TEST_ARTIFACT_ID,"10.0.0")); } - @Test(expected = IllegalArgumentException.class) + @Test public void cannotGetGenerationsForExcludedVersions() { String versionId = "3.0.0"; StoreProjectVersionData storeProjectVersion = new StoreProjectVersionData(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId); storeProjectVersion.getVersionData().setExcluded(true); when(projectsVersions.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId)).thenReturn(Optional.of(storeProjectVersion)); - generations.getFileGenerations(TEST_GROUP_ID,TEST_ARTIFACT_ID,versionId); + Assertions.assertThrows(IllegalArgumentException.class, () -> generations.getFileGenerations(TEST_GROUP_ID,TEST_ARTIFACT_ID, versionId)); } } diff --git a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/purge/TestArtifactsPurgeService.java b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/purge/TestArtifactsPurgeService.java index 40f6667fb..3403cf2f7 100644 --- a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/purge/TestArtifactsPurgeService.java +++ b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/purge/TestArtifactsPurgeService.java @@ -53,9 +53,9 @@ import org.finos.legend.depot.store.mongo.projects.ProjectsVersionsMongo; import org.finos.legend.depot.services.api.notifications.queue.Queue; import org.finos.legend.depot.store.mongo.generations.TestGenerationsStoreMongo; -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 java.time.LocalDateTime; import java.util.Arrays; @@ -91,7 +91,7 @@ public class TestArtifactsPurgeService extends TestBaseServices - @Before + @BeforeEach public void setUpData() { ProjectArtifactHandlerFactory.registerArtifactHandler(ArtifactType.ENTITIES, new EntitiesHandlerImpl(entitiesService, mock(EntityProvider.class))); @@ -99,7 +99,7 @@ public void setUpData() setUpProjectsFromFile(TestArtifactsPurgeService.class.getClassLoader().getResource("data/projects.json")); setUpProjectsVersionsFromFile(TestArtifactsPurgeService.class.getClassLoader().getResource("data/projectsVersions.json")); - Assert.assertEquals(3, projectsStore.getAll().size()); + Assertions.assertEquals(3, projectsStore.getAll().size()); new EntitiesMongoTestUtils(mongoProvider).loadEntities(TestArtifactsPurgeService.class.getClassLoader().getResource("data/entities.json")); TestGenerationsStoreMongo.setUpFileGenerationFromFile(TestArtifactsPurgeService.class.getClassLoader().getResource("data/generations.json"),mongoProvider); @@ -111,23 +111,23 @@ public void canEvictOldVersions() { StoreProjectData project = projectsStore.find(TEST_GROUP_ID,TEST_ARTIFACT_ID).get(); - Assert.assertNotNull(project); + Assertions.assertNotNull(project); List projectVersions = projectsService.getVersions(TEST_GROUP_ID, TEST_ARTIFACT_ID); - Assert.assertEquals(3, projectVersions.size()); - Assert.assertEquals("2.0.0", projectVersions.get(0)); - Assert.assertEquals("2.3.0", project.getLatestVersion()); + Assertions.assertEquals(3, projectVersions.size()); + Assertions.assertEquals("2.0.0", projectVersions.get(0)); + Assertions.assertEquals("2.3.0", project.getLatestVersion()); - Assert.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").size()); + Assertions.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").size()); purgeService.evictOldestProjectVersions(TEST_GROUP_ID,TEST_ARTIFACT_ID,1); List afterVersionsOrdered = projectsService.getVersions(TEST_GROUP_ID, TEST_ARTIFACT_ID); - Assert.assertEquals(3, afterVersionsOrdered.size()); - Assert.assertTrue(projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").get().isEvicted()); - Assert.assertTrue(projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.2.0").get().isEvicted()); - Assert.assertTrue(afterVersionsOrdered.contains("2.3.0")); - Assert.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").size()); - Assert.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.2.0").size()); - Assert.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.3.0").size()); + Assertions.assertEquals(3, afterVersionsOrdered.size()); + Assertions.assertTrue(projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").get().isEvicted()); + Assertions.assertTrue(projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.2.0").get().isEvicted()); + Assertions.assertTrue(afterVersionsOrdered.contains("2.3.0")); + Assertions.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").size()); + Assertions.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.2.0").size()); + Assertions.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.3.0").size()); } @Test @@ -135,20 +135,20 @@ public void canEvictOldVersionsKeepMoreThanExists() { StoreProjectData project = projectsStore.find(TEST_GROUP_ID,TEST_ARTIFACT_ID).get(); - Assert.assertNotNull(project); + Assertions.assertNotNull(project); List projectVersions = projectsService.getVersions(TEST_GROUP_ID, TEST_ARTIFACT_ID); - Assert.assertEquals(3, projectVersions.size()); + Assertions.assertEquals(3, projectVersions.size()); MetadataNotificationResponse response = purgeService.evictOldestProjectVersions(TEST_GROUP_ID,TEST_ARTIFACT_ID,5); - Assert.assertNotNull(response); + Assertions.assertNotNull(response); List afterVersionsOrdered = projectsService.getVersions(TEST_GROUP_ID, TEST_ARTIFACT_ID); - Assert.assertEquals(3, afterVersionsOrdered.size()); - Assert.assertTrue(!projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").get().isEvicted()); - Assert.assertTrue(!projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.2.0").get().isEvicted()); - Assert.assertTrue(!projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.3.0").get().isEvicted()); - Assert.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").size()); - Assert.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.2.0").size()); - Assert.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.3.0").size()); + Assertions.assertEquals(3, afterVersionsOrdered.size()); + Assertions.assertTrue(!projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").get().isEvicted()); + Assertions.assertTrue(!projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.2.0").get().isEvicted()); + Assertions.assertTrue(!projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.3.0").get().isEvicted()); + Assertions.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").size()); + Assertions.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.2.0").size()); + Assertions.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.3.0").size()); } @Test @@ -156,18 +156,18 @@ public void canEvictOldVersionsNotEnoughVersionsToKeep() { StoreProjectData project = projectsStore.find(TEST_GROUP_ID,"test1").get(); - Assert.assertNotNull(project); + Assertions.assertNotNull(project); List projectVersions = projectsService.getVersions(TEST_GROUP_ID, "test1"); - Assert.assertEquals(0, projectVersions.size()); - Assert.assertEquals(1, entitiesStore.getAllEntities(TEST_GROUP_ID, "test1", BRANCH_SNAPSHOT("master")).size()); + Assertions.assertEquals(0, projectVersions.size()); + Assertions.assertEquals(1, entitiesStore.getAllEntities(TEST_GROUP_ID, "test1", BRANCH_SNAPSHOT("master")).size()); MetadataNotificationResponse response = purgeService.evictOldestProjectVersions(TEST_GROUP_ID,"test1",1); - Assert.assertNotNull(response); + Assertions.assertNotNull(response); List afterVersionsOrdered = projectsService.getVersions(TEST_GROUP_ID, "test1"); - Assert.assertEquals(0, afterVersionsOrdered.size()); + Assertions.assertEquals(0, afterVersionsOrdered.size()); - Assert.assertEquals(1, entitiesStore.getAllEntities(TEST_GROUP_ID, "test1", BRANCH_SNAPSHOT("master")).size()); + Assertions.assertEquals(1, entitiesStore.getAllEntities(TEST_GROUP_ID, "test1", BRANCH_SNAPSHOT("master")).size()); } @Test @@ -175,15 +175,15 @@ public void canEvictVersion() { String versionId = "2.0.0"; - Assert.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); - Assert.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); - Assert.assertEquals(3, fileGenerationsStore.getAll().size()); + Assertions.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); + Assertions.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); + Assertions.assertEquals(3, fileGenerationsStore.getAll().size()); purgeService.evict(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId); - Assert.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); - Assert.assertEquals(0, fileGenerationsStore.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); - Assert.assertTrue(projectsService.getVersions(TEST_GROUP_ID,TEST_ARTIFACT_ID).contains(versionId)); - Assert.assertTrue(projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).get().isEvicted()); + Assertions.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); + Assertions.assertEquals(0, fileGenerationsStore.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); + Assertions.assertTrue(projectsService.getVersions(TEST_GROUP_ID,TEST_ARTIFACT_ID).contains(versionId)); + Assertions.assertTrue(projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).get().isEvicted()); } @Test @@ -191,15 +191,15 @@ public void canDeleteVersion() { String versionId = "2.0.0"; - Assert.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); - Assert.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); - Assert.assertEquals(3, fileGenerationsStore.getAll().size()); + Assertions.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); + Assertions.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); + Assertions.assertEquals(3, fileGenerationsStore.getAll().size()); purgeService.delete(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId); - Assert.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); - Assert.assertEquals(0, fileGenerationsStore.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); - Assert.assertFalse(projectsService.getVersions(TEST_GROUP_ID,TEST_ARTIFACT_ID).contains(versionId)); - Assert.assertFalse(projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).isPresent()); + Assertions.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); + Assertions.assertEquals(0, fileGenerationsStore.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); + Assertions.assertFalse(projectsService.getVersions(TEST_GROUP_ID,TEST_ARTIFACT_ID).contains(versionId)); + Assertions.assertFalse(projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).isPresent()); } @Test @@ -207,17 +207,17 @@ public void canDeprecateVersion() { String versionId = "2.0.0"; List versions = projectsService.getVersions(TEST_GROUP_ID,TEST_ARTIFACT_ID); - Assert.assertEquals(versions.size(), 3); - Assert.assertEquals(1, fileGenerationsStore.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); + Assertions.assertEquals(versions.size(), 3); + Assertions.assertEquals(1, fileGenerationsStore.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); //deprecating version purgeService.deprecate(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId); versions = projectsService.getVersions(TEST_GROUP_ID,TEST_ARTIFACT_ID); //no versions deleted - Assert.assertEquals(versions, Arrays.asList("2.0.0", "2.2.0", "2.3.0")); + Assertions.assertEquals(versions, Arrays.asList("2.0.0", "2.2.0", "2.3.0")); //no artifacts deleted - Assert.assertEquals(1, fileGenerationsStore.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); + Assertions.assertEquals(1, fileGenerationsStore.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).size()); Optional storeProjectData = projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId); - Assert.assertTrue(storeProjectData.get().getVersionData().isDeprecated()); + Assertions.assertTrue(storeProjectData.get().getVersionData().isDeprecated()); } @Test @@ -226,16 +226,16 @@ public void canDeprecateVersionIfNotInRepository() String versionId = "2.0.0"; VersionMismatch versionMismatch = new VersionMismatch("PROD-A", TEST_GROUP_ID, TEST_ARTIFACT_ID, Collections.EMPTY_LIST, Collections.singletonList(versionId), Collections.EMPTY_LIST); List versions = projectsService.getVersions(TEST_GROUP_ID,TEST_ARTIFACT_ID); - Assert.assertEquals(versions.size(), 3); - Assert.assertEquals(3, fileGenerationsStore.getAll().size()); + Assertions.assertEquals(versions.size(), 3); + Assertions.assertEquals(3, fileGenerationsStore.getAll().size()); when(versionsMismatchService.findVersionsMismatches()).thenReturn(Collections.singletonList(versionMismatch)); //deleting the version not present in the repository purgeService.deprecateVersionsNotInRepository(); versions = projectsService.getVersions(TEST_GROUP_ID,TEST_ARTIFACT_ID); - Assert.assertEquals(versions.size(), 3); + Assertions.assertEquals(versions.size(), 3); //checking if version data shows deprecation StoreProjectVersionData projectVersionData = projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).get(); - Assert.assertTrue(projectVersionData.getVersionData().isDeprecated()); + Assertions.assertTrue(projectVersionData.getVersionData().isDeprecated()); } @Test @@ -248,11 +248,11 @@ public void canEvictLeastRecentlyUsed() purgeService.evictLeastRecentlyUsed(365, 30); StoreProjectVersionData version1 = projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").get(); - Assert.assertTrue(version1.isEvicted()); + Assertions.assertTrue(version1.isEvicted()); StoreProjectVersionData version2 = projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "branch1-SNAPSHOT").get(); - Assert.assertTrue(version2.isEvicted()); + Assertions.assertTrue(version2.isEvicted()); StoreProjectVersionData version3 = projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "master-SNAPSHOT").get(); - Assert.assertFalse(version3.isEvicted()); + Assertions.assertFalse(version3.isEvicted()); } @Test @@ -263,11 +263,11 @@ public void canEvictVersionsNotUsed() purgeService.evictVersionsNotUsed(); StoreProjectVersionData version1 = projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").get(); - Assert.assertTrue(version1.isEvicted()); + Assertions.assertTrue(version1.isEvicted()); StoreProjectVersionData version2 = projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "branch1-SNAPSHOT").get(); - Assert.assertTrue(version2.isEvicted()); + Assertions.assertTrue(version2.isEvicted()); StoreProjectVersionData version3 = projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "master-SNAPSHOT").get(); - Assert.assertFalse(version3.isEvicted()); + Assertions.assertFalse(version3.isEvicted()); } } diff --git a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/reconciliation/TestVersionsMismatchService.java b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/reconciliation/TestVersionsMismatchService.java index 60bef7c65..892eb9cdd 100644 --- a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/reconciliation/TestVersionsMismatchService.java +++ b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/reconciliation/TestVersionsMismatchService.java @@ -23,9 +23,9 @@ import org.finos.legend.depot.store.model.projects.StoreProjectVersionData; import org.finos.legend.depot.domain.version.VersionMismatch; import org.finos.legend.sdlc.domain.model.version.VersionId; -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 java.util.ArrayList; import java.util.Arrays; @@ -41,7 +41,7 @@ public class TestVersionsMismatchService protected ManageProjectsService projects = mock(ManageProjectsService.class); protected VersionsReconciliationService repositoryServices = new VersionsReconciliationServiceImpl(repository, projects); - @Before + @BeforeEach public void setup() throws ArtifactRepositoryException { List coordinates = new ArrayList<>(); @@ -70,20 +70,20 @@ public void getVersionsMismatch() { List counts = repositoryServices.findVersionsMismatches(); - Assert.assertNotNull(counts); - Assert.assertEquals(3, counts.size()); - Assert.assertEquals(1, counts.stream().filter(p -> p.projectId.equals("PROD-A")).count()); - Assert.assertEquals(1, counts.stream().filter(p -> p.projectId.equals("PROD-B")).count()); - Assert.assertEquals(1, counts.stream().filter(p -> p.projectId.equals("PROD-C")).count()); + Assertions.assertNotNull(counts); + Assertions.assertEquals(3, counts.size()); + Assertions.assertEquals(1, counts.stream().filter(p -> p.projectId.equals("PROD-A")).count()); + Assertions.assertEquals(1, counts.stream().filter(p -> p.projectId.equals("PROD-B")).count()); + Assertions.assertEquals(1, counts.stream().filter(p -> p.projectId.equals("PROD-C")).count()); VersionMismatch prodA = counts.stream().filter(p -> p.projectId.equals("PROD-A")).findFirst().get(); - Assert.assertEquals(1, prodA.versionsNotInStore.size()); - Assert.assertEquals("2.3.1", prodA.versionsNotInStore.get(0)); + Assertions.assertEquals(1, prodA.versionsNotInStore.size()); + Assertions.assertEquals("2.3.1", prodA.versionsNotInStore.get(0)); VersionMismatch prodB = counts.stream().filter(p -> p.projectId.equals("PROD-B")).findFirst().get(); - Assert.assertEquals("1.0.1", prodB.versionsNotInStore.get(0)); - Assert.assertEquals("1.0.0", prodB.versionsNotInRepository.get(0)); + Assertions.assertEquals("1.0.1", prodB.versionsNotInStore.get(0)); + Assertions.assertEquals("1.0.0", prodB.versionsNotInRepository.get(0)); VersionMismatch prodC = counts.stream().filter(p -> p.projectId.equals("PROD-C")).findFirst().get(); - Assert.assertEquals("2.0.1", prodC.versionsNotInRepository.get(0)); + Assertions.assertEquals("2.0.1", prodC.versionsNotInRepository.get(0)); } @@ -94,15 +94,15 @@ public void getVersionsMismatchWithExceptions() throws ArtifactRepositoryExcepti when(repository.findVersions("examples.metadata", "test4")).thenThrow(new ArtifactRepositoryException("not found")); List counts = repositoryServices.findVersionsMismatches(); - Assert.assertNotNull(counts); - Assert.assertEquals(4, counts.size()); - Assert.assertEquals(1, counts.stream().filter(p -> p.projectId.equals("PROD-A")).count()); - Assert.assertEquals(1, counts.stream().filter(p -> p.projectId.equals("PROD-B")).count()); - Assert.assertEquals(1, counts.stream().filter(p -> p.projectId.equals("PROD-C")).count()); - Assert.assertEquals(1, counts.stream().filter(p -> p.projectId.equals("PROD-D")).count()); + Assertions.assertNotNull(counts); + Assertions.assertEquals(4, counts.size()); + Assertions.assertEquals(1, counts.stream().filter(p -> p.projectId.equals("PROD-A")).count()); + Assertions.assertEquals(1, counts.stream().filter(p -> p.projectId.equals("PROD-B")).count()); + Assertions.assertEquals(1, counts.stream().filter(p -> p.projectId.equals("PROD-C")).count()); + Assertions.assertEquals(1, counts.stream().filter(p -> p.projectId.equals("PROD-D")).count()); VersionMismatch prodD = counts.stream().filter(p -> p.projectId.equals("PROD-D")).findFirst().get(); - Assert.assertFalse(prodD.errors.isEmpty()); + Assertions.assertFalse(prodD.errors.isEmpty()); @@ -117,9 +117,9 @@ public void getVersionsMismatchIfExcludedVersionsPresent() throws ArtifactReposi when(projects.find("examples.metadata", "test5")).thenReturn(Arrays.asList(p1v1)); when(repository.findVersions("examples.metadata", "test5")).thenReturn(Arrays.asList(VersionId.parseVersionId("1.0.0"))); List counts = repositoryServices.findVersionsMismatches(); - Assert.assertNotNull(counts); - Assert.assertEquals(3, counts.size()); - Assert.assertEquals(0, counts.stream().filter(p -> p.artifactId.equals("test5")).count()); + Assertions.assertNotNull(counts); + Assertions.assertEquals(3, counts.size()); + Assertions.assertEquals(0, counts.stream().filter(p -> p.artifactId.equals("test5")).count()); } @@ -127,13 +127,13 @@ public void getVersionsMismatchIfExcludedVersionsPresent() throws ArtifactReposi public void getProjectsWithUpdatedLatestVersions() { List projectsWithUpdatedLatestVersions = repositoryServices.syncLatestProjectVersions(); - Assert.assertEquals(2, projectsWithUpdatedLatestVersions.size()); - Assert.assertEquals(1, projectsWithUpdatedLatestVersions.stream().filter(p -> p.getProjectId().equals("PROD-A")).count()); - Assert.assertEquals(1, projectsWithUpdatedLatestVersions.stream().filter(p -> p.getProjectId().equals("PROD-D")).count()); + Assertions.assertEquals(2, projectsWithUpdatedLatestVersions.size()); + Assertions.assertEquals(1, projectsWithUpdatedLatestVersions.stream().filter(p -> p.getProjectId().equals("PROD-A")).count()); + Assertions.assertEquals(1, projectsWithUpdatedLatestVersions.stream().filter(p -> p.getProjectId().equals("PROD-D")).count()); StoreProjectData prodA = projectsWithUpdatedLatestVersions.stream().filter(p -> p.getProjectId().equals("PROD-A")).findFirst().get(); StoreProjectData prodD = projectsWithUpdatedLatestVersions.stream().filter(p -> p.getProjectId().equals("PROD-D")).findFirst().get(); - Assert.assertEquals("2.3.0", prodA.getLatestVersion()); - Assert.assertEquals("0.0.1", prodD.getLatestVersion()); + Assertions.assertEquals("2.3.0", prodA.getLatestVersion()); + Assertions.assertEquals("0.0.1", prodD.getLatestVersion()); } @Test @@ -156,11 +156,11 @@ public void getProjectsWithUpdatedLatestVersionsIfExcludedAndEvictedVersionsPres when(projects.find("examples.metadata", "test3")).thenReturn(Arrays.asList(p3v1)); List projectsWithUpdatedLatestVersions = repositoryServices.syncLatestProjectVersions(); - Assert.assertEquals(1, projectsWithUpdatedLatestVersions.stream().filter(p -> p.getProjectId().equals("PROD-A")).count()); - Assert.assertEquals(1, projectsWithUpdatedLatestVersions.stream().filter(p -> p.getProjectId().equals("PROD-C")).count()); + Assertions.assertEquals(1, projectsWithUpdatedLatestVersions.stream().filter(p -> p.getProjectId().equals("PROD-A")).count()); + Assertions.assertEquals(1, projectsWithUpdatedLatestVersions.stream().filter(p -> p.getProjectId().equals("PROD-C")).count()); StoreProjectData prodA = projectsWithUpdatedLatestVersions.stream().filter(p -> p.getProjectId().equals("PROD-A")).findFirst().get(); StoreProjectData prodC = projectsWithUpdatedLatestVersions.stream().filter(p -> p.getProjectId().equals("PROD-C")).findFirst().get(); - Assert.assertEquals("2.2.0", prodA.getLatestVersion()); - Assert.assertEquals("2.0.3", prodC.getLatestVersion()); + Assertions.assertEquals("2.2.0", prodA.getLatestVersion()); + Assertions.assertEquals("2.0.3", prodC.getLatestVersion()); } } diff --git a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshService.java b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshService.java index aabbda541..19a5ce890 100644 --- a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshService.java +++ b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshService.java @@ -62,10 +62,10 @@ import org.finos.legend.depot.services.api.artifacts.handlers.entties.EntityArtifactsProvider; import org.finos.legend.depot.services.api.artifacts.handlers.generations.FileGenerationsArtifactsProvider; import org.finos.legend.sdlc.domain.model.entity.Entity; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.File; import java.util.Arrays; @@ -110,7 +110,7 @@ public class TestArtifactsRefreshService extends TestStoreMongo protected NotificationsQueueManager notificationsQueueManager = new NotificationsQueueManager(notifications,queue, versionHandler); - @Before + @BeforeEach public void setUpData() { ProjectArtifactHandlerFactory.registerArtifactHandler(ArtifactType.ENTITIES, new EntitiesHandlerImpl(entitiesService, entitiesProvider)); @@ -124,34 +124,34 @@ public void setUpData() projectsStore.createOrUpdate(new StoreProjectData(PROJECT_B, TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID)); projectsStore.createOrUpdate(new StoreProjectData(PROJECT_A, TEST_GROUP_ID, TEST_ARTIFACT_ID)); projectsStore.createOrUpdate(new StoreProjectData("PROD-101", TEST_GROUP_ID, "art101")); - Assert.assertEquals(3, projectsStore.getAll().size()); + Assertions.assertEquals(3, projectsStore.getAll().size()); } - @After + @AfterEach public void afterTest() { - Assert.assertTrue("should not have events in queue",queue.getAll().isEmpty()); + Assertions.assertTrue(queue.getAll().isEmpty(), "should not have events in queue"); } @Test public void canUpdateCreateVersion() { - Assert.assertTrue(entitiesStore.getAllEntities(TEST_GROUP_ID, "art101", BRANCH_SNAPSHOT("master")).isEmpty()); - Assert.assertEquals(0, projectsVersionsStore.find(TEST_GROUP_ID, "art101").size()); + Assertions.assertTrue(entitiesStore.getAllEntities(TEST_GROUP_ID, "art101", BRANCH_SNAPSHOT("master")).isEmpty()); + Assertions.assertEquals(0, projectsVersionsStore.find(TEST_GROUP_ID, "art101").size()); StoreProjectData projectData = projectsStore.find(TEST_GROUP_ID, "art101").get(); List files = repository.findFiles(ArtifactType.ENTITIES, projectData.getGroupId(), projectData.getArtifactId(), BRANCH_SNAPSHOT("master")); - Assert.assertNotNull(files); - Assert.assertEquals(1,files.size()); + Assertions.assertNotNull(files); + Assertions.assertEquals(1,files.size()); MetadataNotificationResponse response = artifactsRefreshService.refreshVersionForProject(TEST_GROUP_ID, "art101",BRANCH_SNAPSHOT("master"),true,true,PARENT_EVENT_ID); - Assert.assertNotNull(response); + Assertions.assertNotNull(response); notificationsQueueManager.handleAll(); - Assert.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); - Assert.assertEquals(0, projectsVersionsStore.find(TEST_GROUP_ID, "art101").stream().filter(x -> !x.getVersionId().equals(BRANCH_SNAPSHOT("master"))).collect(Collectors.toList()).size()); + Assertions.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); + Assertions.assertEquals(0, projectsVersionsStore.find(TEST_GROUP_ID, "art101").stream().filter(x -> !x.getVersionId().equals(BRANCH_SNAPSHOT("master"))).collect(Collectors.toList()).size()); List entities = entitiesStore.getAllEntities(TEST_GROUP_ID, "art101", BRANCH_SNAPSHOT("master")); - Assert.assertNotNull(entities); - Assert.assertEquals(9, entities.size()); - Assert.assertEquals(0,queue.size()); + Assertions.assertNotNull(entities); + Assertions.assertEquals(9, entities.size()); + Assertions.assertEquals(0,queue.size()); } @Test @@ -161,8 +161,8 @@ public void canUpdateVersionForNewDLCProjectStyle() repository.findFiles(ArtifactType.ENTITIES, projectData.getGroupId(), projectData.getArtifactId(), BRANCH_SNAPSHOT("master")); MetadataNotificationResponse response = artifactsRefreshService.refreshVersionForProject(TEST_GROUP_ID, "art101",BRANCH_SNAPSHOT("master"),false,true,PARENT_EVENT_ID); notificationsQueueManager.handleAll(); - Assert.assertNotNull(response); - Assert.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); + Assertions.assertNotNull(response); + Assertions.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); } @Test @@ -172,16 +172,16 @@ public void canRefreshArtifactWithProjectProperties() repository.findFiles(ArtifactType.ENTITIES, projectData.getGroupId(), projectData.getArtifactId(), BRANCH_SNAPSHOT("master")); MetadataNotificationResponse response = artifactsRefreshService.refreshVersionForProject(projectData.getGroupId(), projectData.getArtifactId(), BRANCH_SNAPSHOT("master"),false,true,PARENT_EVENT_ID); notificationsQueueManager.handleAll(); - Assert.assertNotNull(response); - Assert.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); + Assertions.assertNotNull(response); + Assertions.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); Optional updatedProjectData = projectsVersionsStore.find(TEST_GROUP_ID, "art101", BRANCH_SNAPSHOT("master")); - Assert.assertTrue(updatedProjectData.isPresent()); - Assert.assertEquals("0.0.0", updatedProjectData.get().getVersionData().getProperties().get(0).getValue()); + Assertions.assertTrue(updatedProjectData.isPresent()); + Assertions.assertEquals("0.0.0", updatedProjectData.get().getVersionData().getProperties().get(0).getValue()); Map manifestProperties = updatedProjectData.get().getVersionData().getManifestProperties(); - Assert.assertNotNull(manifestProperties); - Assert.assertEquals(manifestProperties.get("commit-author"), "test-author"); - Assert.assertEquals(manifestProperties.get("commit-timestamp"), "2023-04-11T14:48:27+00:00"); + Assertions.assertNotNull(manifestProperties); + Assertions.assertEquals(manifestProperties.get("commit-author"), "test-author"); + Assertions.assertEquals(manifestProperties.get("commit-timestamp"), "2023-04-11T14:48:27+00:00"); } @Test @@ -189,59 +189,59 @@ public void canUpdateCreateMasterRevision() { StoreProjectData projectData = projectsStore.find(TEST_GROUP_ID, "art101").get(); List files = repository.findFiles(ArtifactType.ENTITIES, projectData.getGroupId(), projectData.getArtifactId(), BRANCH_SNAPSHOT("master")); - Assert.assertNotNull(files); + Assertions.assertNotNull(files); MetadataNotificationResponse response = artifactsRefreshService.refreshVersionForProject(projectData.getGroupId(), projectData.getArtifactId(), BRANCH_SNAPSHOT("master"),true,true,PARENT_EVENT_ID); - Assert.assertNotNull(response); - Assert.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); - Assert.assertEquals(1,queue.size()); + Assertions.assertNotNull(response); + Assertions.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); + Assertions.assertEquals(1,queue.size()); notificationsQueueManager.handleAll(); - Assert.assertTrue(queue.getAll().isEmpty()); - Assert.assertEquals(2,notifications.find(null,null,null,null,PARENT_EVENT_ID,null,null,null).size()); + Assertions.assertTrue(queue.getAll().isEmpty()); + Assertions.assertEquals(2,notifications.find(null,null,null,null,PARENT_EVENT_ID,null,null,null).size()); } @Test public void canRefreshProjectVersion() { - Assert.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").size()); + Assertions.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").size()); MetadataNotificationResponse response = artifactsRefreshService.refreshVersionForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0",true,PARENT_EVENT_ID); - Assert.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); - Assert.assertEquals(1,queue.size()); + Assertions.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); + Assertions.assertEquals(1,queue.size()); notificationsQueueManager.handleAll(); - Assert.assertEquals(9, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").size()); + Assertions.assertEquals(9, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").size()); - Assert.assertEquals(1, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").size()); + Assertions.assertEquals(1, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").size()); - Assert.assertEquals(12, fileGenerationsStore.getAll().size()); - Assert.assertEquals(3, fileGenerationsStore.findByElementPath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0", "examples::avrogen").size()); - Assert.assertEquals(2, fileGenerationsStore.findByElementPath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0", "examples::metadata::test::ClientBasic").size()); - Assert.assertTrue(fileGenerationsStore.findByFilePath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0", "/examples/metadata/test/ClientBasic/my-ext/Output1.txt").isPresent()); - Assert.assertEquals("My Output1", fileGenerationsStore.findByFilePath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0", "/examples/metadata/test/ClientBasic/my-ext/Output1.txt").get().getFile().getContent()); + Assertions.assertEquals(12, fileGenerationsStore.getAll().size()); + Assertions.assertEquals(3, fileGenerationsStore.findByElementPath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0", "examples::avrogen").size()); + Assertions.assertEquals(2, fileGenerationsStore.findByElementPath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0", "examples::metadata::test::ClientBasic").size()); + Assertions.assertTrue(fileGenerationsStore.findByFilePath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0", "/examples/metadata/test/ClientBasic/my-ext/Output1.txt").isPresent()); + Assertions.assertEquals("My Output1", fileGenerationsStore.findByFilePath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0", "/examples/metadata/test/ClientBasic/my-ext/Output1.txt").get().getFile().getContent()); } @Test public void canRefreshExcludedProjectVersionIfLoadable() { StoreProjectVersionData storeProjectVersionData = projectsService.excludeProjectVersion(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0", "unknown error"); - Assert.assertTrue(storeProjectVersionData.getVersionData().isExcluded()); - Assert.assertEquals(storeProjectVersionData.getVersionData().getDependencies().size(), 0); + Assertions.assertTrue(storeProjectVersionData.getVersionData().isExcluded()); + Assertions.assertEquals(storeProjectVersionData.getVersionData().getDependencies().size(), 0); MetadataNotificationResponse response = artifactsRefreshService.refreshVersionForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0",false,PARENT_EVENT_ID); - Assert.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); - Assert.assertEquals(1,queue.size()); + Assertions.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); + Assertions.assertEquals(1,queue.size()); notificationsQueueManager.handleAll(); storeProjectVersionData = projectsVersionsStore.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").get(); - Assert.assertFalse(storeProjectVersionData.getVersionData().isExcluded()); - Assert.assertNull(storeProjectVersionData.getVersionData().getExclusionReason()); - Assert.assertEquals(storeProjectVersionData.getVersionData().getDependencies().size(), 1); + Assertions.assertFalse(storeProjectVersionData.getVersionData().isExcluded()); + Assertions.assertNull(storeProjectVersionData.getVersionData().getExclusionReason()); + Assertions.assertEquals(storeProjectVersionData.getVersionData().getDependencies().size(), 1); Map manifestProperties = storeProjectVersionData.getVersionData().getManifestProperties(); - Assert.assertNotNull(manifestProperties); - Assert.assertEquals(manifestProperties.get("commit-author"), "test-author"); - Assert.assertEquals(manifestProperties.get("commit-timestamp"), "2023-04-11T14:48:27+00:00"); + Assertions.assertNotNull(manifestProperties); + Assertions.assertEquals(manifestProperties.get("commit-author"), "test-author"); + Assertions.assertEquals(manifestProperties.get("commit-timestamp"), "2023-04-11T14:48:27+00:00"); } @Test @@ -250,34 +250,34 @@ public void canRefreshEvictedProjectVersion() StoreProjectVersionData storeProjectVersionData = new StoreProjectVersionData(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0"); storeProjectVersionData.setEvicted(true); projectsService.createOrUpdate(storeProjectVersionData); - Assert.assertTrue(storeProjectVersionData.isEvicted()); + Assertions.assertTrue(storeProjectVersionData.isEvicted()); - Assert.assertThrows("Project version: examples.metadata-test-2.0.0 is being restored, please retry in 5 minutes", IllegalStateException.class, () -> projectsService.resolveAliasesAndCheckVersionExists(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0")); - Assert.assertEquals(1, queue.size()); + Assertions.assertThrows(IllegalStateException.class, () -> projectsService.resolveAliasesAndCheckVersionExists(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0"), "Project version: examples.metadata-test-2.0.0 is being restored, please retry in 5 minutes"); + Assertions.assertEquals(1, queue.size()); notificationsQueueManager.handleAll(); storeProjectVersionData = projectsVersionsStore.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").get(); - Assert.assertFalse(storeProjectVersionData.isEvicted()); + Assertions.assertFalse(storeProjectVersionData.isEvicted()); } @Test public void canRefreshAllVersionForProject() { - Assert.assertTrue(entitiesStore.getAllStoredEntities().isEmpty()); - Assert.assertTrue(entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").isEmpty()); - Assert.assertTrue(entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").isEmpty()); + Assertions.assertTrue(entitiesStore.getAllStoredEntities().isEmpty()); + Assertions.assertTrue(entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").isEmpty()); + Assertions.assertTrue(entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").isEmpty()); MetadataNotificationResponse response = artifactsRefreshService.refreshAllVersionsForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, true, true,true,PARENT_EVENT_ID); - Assert.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); + Assertions.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); - Assert.assertEquals(3,queue.size()); + Assertions.assertEquals(3,queue.size()); notificationsQueueManager.handleAll(); - Assert.assertEquals(3,projectsStore.getAll().size()); - Assert.assertEquals(9, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "1.0.0").size()); - Assert.assertEquals(9, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").size()); + Assertions.assertEquals(3,projectsStore.getAll().size()); + Assertions.assertEquals(9, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "1.0.0").size()); + Assertions.assertEquals(9, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").size()); - Assert.assertEquals(1, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").size()); + Assertions.assertEquals(1, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").size()); } @@ -285,15 +285,15 @@ public void canRefreshAllVersionForProject() public void canRefreshOnlyDefaultSnapshotVersions() { MetadataNotificationResponse response = artifactsRefreshService.refreshDefaultSnapshotsForAllProjects(false, false, PARENT_EVENT_ID); - Assert.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); - Assert.assertEquals(2,queue.size()); + Assertions.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); + Assertions.assertEquals(2,queue.size()); notificationsQueueManager.handleAll(); projectsService.createOrUpdate(new StoreProjectVersionData(TEST_GROUP_ID, TEST_ARTIFACT_ID, "branch1-SNAPSHOT")); response = artifactsRefreshService.refreshDefaultSnapshotsForAllProjects(false, false, PARENT_EVENT_ID); - Assert.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); - Assert.assertEquals(2,queue.size()); + Assertions.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); + Assertions.assertEquals(2,queue.size()); notificationsQueueManager.handleAll(); } @@ -301,9 +301,9 @@ public void canRefreshOnlyDefaultSnapshotVersions() public void canRefreshAllVersionExceptForEvictedSnapshot() { MetadataNotificationResponse response = artifactsRefreshService.refreshAllVersionsForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, true, true,true,PARENT_EVENT_ID); - Assert.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); + Assertions.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); - Assert.assertEquals(3,queue.size()); + Assertions.assertEquals(3,queue.size()); notificationsQueueManager.handleAll(); StoreProjectVersionData pv = new StoreProjectVersionData(TEST_GROUP_ID, TEST_ARTIFACT_ID, "dummy-SNAPSHOT"); @@ -311,26 +311,26 @@ public void canRefreshAllVersionExceptForEvictedSnapshot() projectsService.createOrUpdate(pv); response = artifactsRefreshService.refreshAllVersionsForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, true, true,true,PARENT_EVENT_ID); - Assert.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); + Assertions.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); - Assert.assertEquals(3,queue.size()); + Assertions.assertEquals(3,queue.size()); notificationsQueueManager.handleAll(); } @Test public void canRefreshAllVersionForProjectWithExcludedVersion() { - Assert.assertTrue(entitiesStore.getAllStoredEntities().isEmpty()); - Assert.assertTrue(entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").isEmpty()); - Assert.assertTrue(entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").isEmpty()); + Assertions.assertTrue(entitiesStore.getAllStoredEntities().isEmpty()); + Assertions.assertTrue(entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").isEmpty()); + Assertions.assertTrue(entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").isEmpty()); projectsService.excludeProjectVersion(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0","test"); MetadataNotificationResponse response = artifactsRefreshService.refreshAllVersionsForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, false, false,true,PARENT_EVENT_ID); - Assert.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); + Assertions.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); - Assert.assertEquals(1,queue.size()); + Assertions.assertEquals(1,queue.size()); - Assert.assertEquals(BRANCH_SNAPSHOT("master"), queue.getAll().get(0).getVersionId()); + Assertions.assertEquals(BRANCH_SNAPSHOT("master"), queue.getAll().get(0).getVersionId()); notificationsQueueManager.handleAll(); } @@ -339,27 +339,27 @@ public void canRefreshAllVersionForProjectWithExcludedVersion() public void partialRefreshAllVersionForProjectOnlyRefreshLatest() { artifactsRefreshService.refreshAllVersionsForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, true, true, true,PARENT_EVENT_ID); - Assert.assertEquals(3,queue.size()); + Assertions.assertEquals(3,queue.size()); notificationsQueueManager.handleAll(); List versions = projectsService.getVersions(TEST_GROUP_ID, TEST_ARTIFACT_ID); - Assert.assertEquals(2, versions.size()); - Assert.assertEquals("2.0.0",projectsService.findCoordinates(TEST_GROUP_ID, TEST_ARTIFACT_ID).get().getLatestVersion()); + Assertions.assertEquals(2, versions.size()); + Assertions.assertEquals("2.0.0",projectsService.findCoordinates(TEST_GROUP_ID, TEST_ARTIFACT_ID).get().getLatestVersion()); projectsService.delete(TEST_GROUP_ID, TEST_ARTIFACT_ID, "1.0.0"); - Assert.assertEquals("2.0.0",projectsService.findCoordinates(TEST_GROUP_ID,TEST_ARTIFACT_ID).get().getLatestVersion()); + Assertions.assertEquals("2.0.0",projectsService.findCoordinates(TEST_GROUP_ID,TEST_ARTIFACT_ID).get().getLatestVersion()); artifactsRefreshService.refreshAllVersionsForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, false, false, false,PARENT_EVENT_ID); - Assert.assertEquals("2.0.0",projectsService.findCoordinates(TEST_GROUP_ID,TEST_ARTIFACT_ID).get().getLatestVersion()); - Assert.assertEquals(2,queue.size()); - Assert.assertEquals("1.0.0",queue.getAll().get(1).getVersionId()); + Assertions.assertEquals("2.0.0",projectsService.findCoordinates(TEST_GROUP_ID,TEST_ARTIFACT_ID).get().getLatestVersion()); + Assertions.assertEquals(2,queue.size()); + Assertions.assertEquals("1.0.0",queue.getAll().get(1).getVersionId()); notificationsQueueManager.handleAll(); projectsService.delete(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0"); artifactsRefreshService.refreshAllVersionsForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, false, false, false,PARENT_EVENT_ID); - Assert.assertEquals(2,queue.size()); - Assert.assertEquals("2.0.0",queue.getAll().get(1).getVersionId()); + Assertions.assertEquals(2,queue.size()); + Assertions.assertEquals("2.0.0",queue.getAll().get(1).getVersionId()); notificationsQueueManager.handleAll(); } @@ -367,20 +367,20 @@ public void partialRefreshAllVersionForProjectOnlyRefreshLatest() @Test public void canRefreshAllVersionsAllProjects() { - Assert.assertEquals(3,projectsService.getAllProjectCoordinates().size()); + Assertions.assertEquals(3,projectsService.getAllProjectCoordinates().size()); MetadataNotificationResponse response = artifactsRefreshService.refreshAllVersionsForAllProjects(true,true,true,PARENT_EVENT_ID); - Assert.assertEquals(5,queue.size()); + Assertions.assertEquals(5,queue.size()); notificationsQueueManager.handleAll(); - Assert.assertNotNull(response); - Assert.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); + Assertions.assertNotNull(response); + Assertions.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); List entityList2 = entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0"); - Assert.assertNotNull(entityList2); - Assert.assertEquals(9, entityList2.size()); + Assertions.assertNotNull(entityList2); + Assertions.assertEquals(9, entityList2.size()); MetadataNotificationResponse partialUpdate = artifactsRefreshService.refreshAllVersionsForAllProjects(false,false,true,PARENT_EVENT_ID); - Assert.assertEquals(3,queue.size()); + Assertions.assertEquals(3,queue.size()); queue.getAll().stream().allMatch(notification -> BRANCH_SNAPSHOT("master").equals(notification.getVersionId())); notificationsQueueManager.handleAll(); } @@ -389,27 +389,27 @@ public void canRefreshAllVersionsAllProjects() public void canRefreshProjectMasterVersion() { - Assert.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master")).size()); + Assertions.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master")).size()); - Assert.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").size()); + Assertions.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").size()); MetadataNotificationResponse response = artifactsRefreshService.refreshVersionForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master"),true,PARENT_EVENT_ID); - Assert.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); - Assert.assertEquals(1,queue.size()); + Assertions.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); + Assertions.assertEquals(1,queue.size()); notificationsQueueManager.handleAll(); - Assert.assertEquals(9, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master")).size()); + Assertions.assertEquals(9, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master")).size()); - Assert.assertEquals(1, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").size()); + Assertions.assertEquals(1, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").size()); ProjectVersionData projectVersionData = projectsVersionsStore.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master")).get().getVersionData(); List dependencies = projectVersionData.getDependencies(); - Assert.assertEquals(2, dependencies.size()); + Assertions.assertEquals(2, dependencies.size()); Map manifestProperties = projectVersionData.getManifestProperties(); - Assert.assertNotNull(manifestProperties); - Assert.assertEquals(manifestProperties.get("commit-author"), "test-author"); - Assert.assertEquals(manifestProperties.get("commit-timestamp"), "2023-04-11T14:48:27+00:00"); + Assertions.assertNotNull(manifestProperties); + Assertions.assertEquals(manifestProperties.get("commit-author"), "test-author"); + Assertions.assertEquals(manifestProperties.get("commit-timestamp"), "2023-04-11T14:48:27+00:00"); } @@ -418,37 +418,37 @@ public void canRefreshProjectMasterVersion() public void canRefreshProjectMasterVersionWithAllDependenciesTransitively() { - Assert.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master")).size()); - Assert.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").size()); - Assert.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, "art101", "2.0.0").size()); + Assertions.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master")).size()); + Assertions.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").size()); + Assertions.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, "art101", "2.0.0").size()); MetadataNotificationResponse response = artifactsRefreshService.refreshVersionForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master"),true,PARENT_EVENT_ID); - Assert.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); - Assert.assertEquals(1,queue.size()); + Assertions.assertEquals(MetadataNotificationStatus.SUCCESS, response.getStatus()); + Assertions.assertEquals(1,queue.size()); notificationsQueueManager.handle(); List dependencies = projectsVersionsStore.find(TEST_GROUP_ID,TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master")).get().getVersionData().getDependencies(); - Assert.assertEquals(2, dependencies.size()); + Assertions.assertEquals(2, dependencies.size()); - Assert.assertEquals(2,queue.size()); + Assertions.assertEquals(2,queue.size()); notificationsQueueManager.handleAll(); - Assert.assertEquals(0,queue.size()); + Assertions.assertEquals(0,queue.size()); } @Test public void dependenciesAreLoadedCorrectly() { - Assert.assertEquals(1, repository.findDependenciesByArtifactType(ArtifactType.ENTITIES, TEST_GROUP_ID, "test", "2.0.0").size()); - Assert.assertEquals(0, entitiesStore.getStoredEntities(PROJECT_A, TEST_GROUP_ID, TEST_ARTIFACT_ID).size()); - Assert.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "2.0.0").size()); - Assert.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "1.0.0").size()); + Assertions.assertEquals(1, repository.findDependenciesByArtifactType(ArtifactType.ENTITIES, TEST_GROUP_ID, "test", "2.0.0").size()); + Assertions.assertEquals(0, entitiesStore.getStoredEntities(PROJECT_A, TEST_GROUP_ID, TEST_ARTIFACT_ID).size()); + Assertions.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "2.0.0").size()); + Assertions.assertEquals(0, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "1.0.0").size()); artifactsRefreshService.refreshVersionForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0", true,PARENT_EVENT_ID); notificationsQueueManager.handleAll(); - Assert.assertEquals(1,projectsVersionsStore.find(TEST_GROUP_ID,TEST_ARTIFACT_ID,"2.0.0").get().getVersionData().getDependencies().size()); - Assert.assertEquals(0,queue.size()); - Assert.assertEquals(9, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").size()); - Assert.assertEquals(1, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").size()); + Assertions.assertEquals(1,projectsVersionsStore.find(TEST_GROUP_ID,TEST_ARTIFACT_ID,"2.0.0").get().getVersionData().getDependencies().size()); + Assertions.assertEquals(0,queue.size()); + Assertions.assertEquals(9, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.0.0").size()); + Assertions.assertEquals(1, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, "1.0.0").size()); } @@ -456,14 +456,14 @@ public void dependenciesAreLoadedCorrectly() public void canLoadEntitiesWithVersionInPackageName() { MetadataNotificationResponse partialUpdate = versionHandler.handleNotification(new MetadataNotification("prod-1",TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID,BRANCH_SNAPSHOT("master"),false,false,PARENT_EVENT_ID)); - Assert.assertNotNull(partialUpdate); - Assert.assertEquals(2, entitiesStore.getStoredEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, BRANCH_SNAPSHOT("master")).size()); + Assertions.assertNotNull(partialUpdate); + Assertions.assertEquals(2, entitiesStore.getStoredEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, BRANCH_SNAPSHOT("master")).size()); MetadataNotificationResponse fullUpdate = versionHandler.handleNotification(new MetadataNotification("prod-1",TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID,BRANCH_SNAPSHOT("master"),true,false,PARENT_EVENT_ID)); - Assert.assertNotNull(fullUpdate); + Assertions.assertNotNull(fullUpdate); - Assert.assertEquals(2, entitiesStore.getStoredEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, BRANCH_SNAPSHOT("master")).size()); - Assert.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, BRANCH_SNAPSHOT("master")).size()); + Assertions.assertEquals(2, entitiesStore.getStoredEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, BRANCH_SNAPSHOT("master")).size()); + Assertions.assertEquals(2, entitiesStore.getAllEntities(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, BRANCH_SNAPSHOT("master")).size()); } @@ -475,34 +475,34 @@ public void canRefreshExistingVersion() String versionId = "2.0.0"; MetadataNotificationResponse response = artifactsRefreshService.refreshVersionForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId,true,PARENT_EVENT_ID); notificationsQueueManager.handleAll(); - Assert.assertNotNull(response); - Assert.assertFalse(response.hasErrors()); + Assertions.assertNotNull(response); + Assertions.assertFalse(response.hasErrors()); } - @Test(expected = IllegalArgumentException.class) + @Test public void cantRefreshNonExistingProjectInRepo() { String versionId = "2.111.0"; - artifactsRefreshService.refreshVersionForProject("i.dont.exist", "in-repo", versionId,false,PARENT_EVENT_ID); + Assertions.assertThrows(IllegalArgumentException.class, () -> artifactsRefreshService.refreshVersionForProject("i.dont.exist", "in-repo", versionId,false,PARENT_EVENT_ID)); } @Test public void cantRefreshSameVersionTwice() { String versionId = "2.0.0"; - Assert.assertFalse(projectsVersionsStore.find(TEST_GROUP_ID,TEST_ARTIFACT_ID,versionId).isPresent()); - Assert.assertFalse(artifactsRefreshService.refreshVersionForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId,true,PARENT_EVENT_ID).hasErrors()); + Assertions.assertFalse(projectsVersionsStore.find(TEST_GROUP_ID,TEST_ARTIFACT_ID,versionId).isPresent()); + Assertions.assertFalse(artifactsRefreshService.refreshVersionForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId,true,PARENT_EVENT_ID).hasErrors()); notificationsQueueManager.handleAll(); - Assert.assertTrue(projectsVersionsStore.find(TEST_GROUP_ID,TEST_ARTIFACT_ID,versionId).isPresent()); + Assertions.assertTrue(projectsVersionsStore.find(TEST_GROUP_ID,TEST_ARTIFACT_ID,versionId).isPresent()); int docsBefore = this.entitiesStore.getAllStoredEntities().size(); - Assert.assertFalse(artifactsRefreshService.refreshVersionForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId,true,PARENT_EVENT_ID).hasErrors()); + Assertions.assertFalse(artifactsRefreshService.refreshVersionForProject(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId,true,PARENT_EVENT_ID).hasErrors()); notificationsQueueManager.handleAll(); - Assert.assertEquals(docsBefore,entitiesStore.getAllStoredEntities().size()); - Assert.assertTrue(projectsVersionsStore.find(TEST_GROUP_ID,TEST_ARTIFACT_ID,versionId).isPresent()); - Assert.assertEquals(2,projectsVersionsStore.find(TEST_GROUP_ID,TEST_ARTIFACT_ID).stream().filter(x -> !x.getVersionId().equals(BRANCH_SNAPSHOT("master"))).collect(Collectors.toList()).size()); - Assert.assertEquals(0,queue.size()); + Assertions.assertEquals(docsBefore,entitiesStore.getAllStoredEntities().size()); + Assertions.assertTrue(projectsVersionsStore.find(TEST_GROUP_ID,TEST_ARTIFACT_ID,versionId).isPresent()); + Assertions.assertEquals(2,projectsVersionsStore.find(TEST_GROUP_ID,TEST_ARTIFACT_ID).stream().filter(x -> !x.getVersionId().equals(BRANCH_SNAPSHOT("master"))).collect(Collectors.toList()).size()); + Assertions.assertEquals(0,queue.size()); } diff --git a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshServiceExceptionEscenarios.java b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshServiceExceptionEscenarios.java index 97ddaae88..67bd2f090 100644 --- a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshServiceExceptionEscenarios.java +++ b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshServiceExceptionEscenarios.java @@ -46,11 +46,11 @@ import org.finos.legend.depot.services.api.artifacts.handlers.generations.FileGenerationsArtifactsProvider; import org.finos.legend.depot.store.mongo.notifications.queue.NotificationsQueueMongo; import org.finos.legend.sdlc.domain.model.version.VersionId; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; @@ -87,7 +87,7 @@ public class TestArtifactsRefreshServiceExceptionEscenarios extends TestStoreMon protected ArtifactsRefreshService artifactsRefreshService = new ArtifactsRefreshServiceImpl(projectsService, repository, queue); - @Before + @BeforeEach public void setUpData() throws ArtifactRepositoryException { ProjectArtifactHandlerFactory.registerArtifactHandler(ArtifactType.ENTITIES, new EntitiesHandlerImpl(entitiesService, entitiesProvider)); @@ -104,30 +104,30 @@ public void setUpData() throws ArtifactRepositoryException when(repository.findVersions(TEST_GROUP_ID,"c")).thenReturn(Arrays.asList(VersionId.parseVersionId("1.0.0"))); } - @After + @AfterEach public void afterTest() { - Assert.assertTrue("should not have events in queue",queue.getAll().isEmpty()); + Assertions.assertTrue(queue.getAll().isEmpty(), "should not have events in queue"); } - @Test(expected = IllegalArgumentException.class) + @Test public void cannotFindProject() { - artifactsRefreshService.refreshVersionForProject("test.test","missing.project","1.0.0",true, PARENT_EVENT_ID); + Assertions.assertThrows(IllegalArgumentException.class, () -> artifactsRefreshService.refreshVersionForProject("test.test","missing.project","1.0.0",true, PARENT_EVENT_ID)); } @Test - @Ignore + @Disabled public void projectFailsToPersistEntities() { when(mongoProjects.find(TEST_GROUP_ID,TEST_DEPENDENCIES_ARTIFACT_ID)).thenReturn(Optional.of(new StoreProjectData(PROJECT_B, TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID))); MetadataNotificationResponse response = artifactsRefreshService.refreshVersionForProject(TEST_GROUP_ID,TEST_DEPENDENCIES_ARTIFACT_ID,"1.0.0",true,PARENT_EVENT_ID); - Assert.assertNotNull(response); - Assert.assertEquals(MetadataNotificationStatus.FAILED,response.getStatus()); - Assert.assertEquals("Could not find dependent project: [examples.metadata-test-dependencies-1.0.0]", response.getErrors().get(0)); + Assertions.assertNotNull(response); + Assertions.assertEquals(MetadataNotificationStatus.FAILED,response.getStatus()); + Assertions.assertEquals("Could not find dependent project: [examples.metadata-test-dependencies-1.0.0]", response.getErrors().get(0)); } } diff --git a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshServiceWithMocks.java b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshServiceWithMocks.java index 666db5105..13900731b 100644 --- a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshServiceWithMocks.java +++ b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshServiceWithMocks.java @@ -44,10 +44,10 @@ import org.finos.legend.depot.services.api.artifacts.handlers.generations.FileGenerationsArtifactsProvider; import org.finos.legend.depot.store.mongo.notifications.queue.NotificationsQueueMongo; import org.finos.legend.sdlc.domain.model.version.VersionId; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; @@ -84,7 +84,7 @@ public class TestArtifactsRefreshServiceWithMocks extends TestStoreMongo protected ArtifactsRefreshServiceImpl artifactsRefreshService = new ArtifactsRefreshServiceImpl(projectsService, repository,queue); - @Before + @BeforeEach public void setUpData() throws ArtifactRepositoryException { ProjectArtifactHandlerFactory.registerArtifactHandler(ArtifactType.ENTITIES, new EntitiesHandlerImpl(entitiesService, entitiesProvider)); @@ -103,10 +103,10 @@ public void setUpData() throws ArtifactRepositoryException when(repository.findVersions(TEST_GROUP_ID,"c")).thenReturn(Arrays.asList(VersionId.parseVersionId("1.0.0"))); } - @After + @AfterEach public void afterTest() { - Assert.assertTrue("should not have events in queue",queue.getAll().isEmpty()); + Assertions.assertTrue(queue.getAll().isEmpty(), "should not have events in queue"); } @@ -116,6 +116,6 @@ public void canCalculateCandidateVersionsToUpdate() List repoVersions = Arrays.asList(VersionId.parseVersionId("1.0.0"),VersionId.parseVersionId("2.0.0")); List versions = Arrays.asList("1.0.0"); List candidates = artifactsRefreshService.calculateCandidateVersions(repoVersions,versions); - Assert.assertEquals("2.0.0",candidates.get(0).toVersionIdString()); + Assertions.assertEquals("2.0.0",candidates.get(0).toVersionIdString()); } } diff --git a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestManifestLoader.java b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestManifestLoader.java index a694e4318..67a71e3e3 100644 --- a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestManifestLoader.java +++ b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestManifestLoader.java @@ -16,8 +16,8 @@ package org.finos.legend.depot.services.artifacts.refresh; import org.finos.legend.depot.services.artifacts.handlers.ManifestLoader; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.File; import java.util.jar.Manifest; @@ -30,7 +30,7 @@ public void canReadManifest() String jarFilePath = TestManifestLoader.class.getClassLoader().getResource("repository/examples/metadata/test-entities/1.0.0/test-entities-1.0.0.jar").getFile(); File jarFile = new File(jarFilePath); Manifest manifest = ManifestLoader.readManifest(jarFile); - Assert.assertNotNull(manifest); + Assertions.assertNotNull(manifest); } @Test @@ -39,13 +39,13 @@ public void canHandleInvalidFile() String pomFilePath = TestManifestLoader.class.getClassLoader().getResource("repository/examples/metadata/test-entities/1.0.0/test-entities-1.0.0.pom").getFile(); File pomFile = new File(pomFilePath); Manifest manifest = ManifestLoader.readManifest(pomFile); - Assert.assertNull(manifest); + Assertions.assertNull(manifest); } @Test public void canHandleNullFile() { Manifest manifest = ManifestLoader.readManifest(null); - Assert.assertNull(manifest); + Assertions.assertNull(manifest); } } diff --git a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestProjectVersionRefreshHandler.java b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestProjectVersionRefreshHandler.java index 8670742d4..bff835218 100644 --- a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestProjectVersionRefreshHandler.java +++ b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestProjectVersionRefreshHandler.java @@ -48,9 +48,9 @@ import org.finos.legend.depot.services.api.artifacts.handlers.ProjectArtifactHandlerFactory; import org.finos.legend.depot.services.api.artifacts.handlers.entties.EntityArtifactsProvider; import org.finos.legend.sdlc.domain.model.version.VersionId; -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 java.util.Arrays; import java.util.Collections; @@ -90,7 +90,7 @@ public class TestProjectVersionRefreshHandler extends TestStoreMongo protected ProjectVersionRefreshHandler versionHandler = new ProjectVersionRefreshHandler(projectsService, repositoryServices, queue, artifactsStore, new IncludeProjectPropertiesConfiguration(properties, manifestProperties), refreshDependenciesService, 3); - @Before + @BeforeEach public void setUpData() { ProjectArtifactHandlerFactory.registerArtifactHandler(ArtifactType.ENTITIES, new EntitiesHandlerImpl(entitiesService, entitiesProvider)); @@ -111,8 +111,8 @@ public void cantRefreshANonExistingVersion() { String versionId = "4.0.0"; MetadataNotificationResponse response = versionHandler.handleNotification(new MetadataNotification("prod-1",TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId,false,false,PARENT_EVENT_ID)); - Assert.assertNotNull(response); - Assert.assertTrue(response.hasErrors()); + Assertions.assertNotNull(response); + Assertions.assertTrue(response.hasErrors()); } @Test @@ -121,11 +121,11 @@ public void cantRefreshAVersionProjectHasNoVersionsInRepo() throws ArtifactRepos projectsStore.createOrUpdate(new StoreProjectData("PROD-1011", TEST_GROUP_ID, "art1011")); String versionId = "4.0.0"; List versionsInRepo = repositoryServices.findVersions(TEST_GROUP_ID, "art1011"); - Assert.assertNotNull(versionsInRepo); - Assert.assertTrue(versionsInRepo.isEmpty()); + Assertions.assertNotNull(versionsInRepo); + Assertions.assertTrue(versionsInRepo.isEmpty()); MetadataNotificationResponse response = versionHandler.handleNotification(new MetadataNotification("prod-1",TEST_GROUP_ID, "art1011", versionId,true,false,PARENT_EVENT_ID)); - Assert.assertNotNull(response); - Assert.assertEquals(MetadataNotificationStatus.FAILED,response.getStatus()); + Assertions.assertNotNull(response); + Assertions.assertEquals(MetadataNotificationStatus.FAILED,response.getStatus()); } @Test @@ -133,8 +133,8 @@ public void cantRefreshNonExistingVersionInRepo() { String versionId = "2.111.0"; MetadataNotificationResponse response = versionHandler.handleNotification(new MetadataNotification("prod-1",TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId,false,false,PARENT_EVENT_ID)); - Assert.assertNotNull(response); - Assert.assertTrue(response.hasErrors()); + Assertions.assertNotNull(response); + Assertions.assertTrue(response.hasErrors()); } @Test @@ -143,15 +143,15 @@ public void cannotRefreshExcludedVersion() String versionId = "2.111.0"; final String EXCLUSION_REASON = "version missing in repository"; StoreProjectVersionData storeProjectVersionData = projectsService.excludeProjectVersion(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId, EXCLUSION_REASON); - Assert.assertTrue(storeProjectVersionData.getVersionData().isExcluded()); + Assertions.assertTrue(storeProjectVersionData.getVersionData().isExcluded()); MetadataNotificationResponse response = versionHandler.handleNotification(new MetadataNotification("prod-1",TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId,false,false,PARENT_EVENT_ID)); - Assert.assertNotNull(response); - Assert.assertTrue(response.hasErrors()); + Assertions.assertNotNull(response); + Assertions.assertTrue(response.hasErrors()); storeProjectVersionData = projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, versionId).get(); - Assert.assertTrue(storeProjectVersionData.getVersionData().isExcluded()); - Assert.assertEquals(storeProjectVersionData.getVersionData().getExclusionReason(), EXCLUSION_REASON); + Assertions.assertTrue(storeProjectVersionData.getVersionData().isExcluded()); + Assertions.assertEquals(storeProjectVersionData.getVersionData().getExclusionReason(), EXCLUSION_REASON); } @Test @@ -166,27 +166,27 @@ public void cannotFindDependentProject() throws ArtifactRepositoryException when(repositoryServices.findVersion(TEST_GROUP_ID,TEST_ARTIFACT_ID,BRANCH_SNAPSHOT("master"))).thenReturn(Optional.of(BRANCH_SNAPSHOT("master"))); projectsService.createOrUpdate(new StoreProjectVersionData(TEST_GROUP_ID,TEST_ARTIFACT_ID,"1.0.0")); MetadataNotificationResponse response = versionHandler.handleNotification(new MetadataNotification("prod-1",TEST_GROUP_ID,TEST_ARTIFACT_ID,"1.0.0",true,false,PARENT_EVENT_ID)); - Assert.assertNotNull(response); - Assert.assertEquals(MetadataNotificationStatus.FAILED,response.getStatus()); - Assert.assertTrue(response.getErrors().contains("Dependency examples.metadata-c-1.0.0 not found in store")); + Assertions.assertNotNull(response); + Assertions.assertEquals(MetadataNotificationStatus.FAILED,response.getStatus()); + Assertions.assertTrue(response.getErrors().contains("Dependency examples.metadata-c-1.0.0 not found in store")); } @Test public void cannotUpdateUnknownProjectVersion() { MetadataNotificationResponse response = versionHandler.handleNotification(new MetadataNotification("prod-1",TEST_GROUP_ID,TEST_ARTIFACT_ID,"1.0.0",true,false,PARENT_EVENT_ID)); - Assert.assertNotNull(response); - Assert.assertEquals(MetadataNotificationStatus.FAILED,response.getStatus()); - Assert.assertEquals("Version 1.0.0 does not exist for examples.metadata-test in repository", response.getErrors().get(0)); + Assertions.assertNotNull(response); + Assertions.assertEquals(MetadataNotificationStatus.FAILED,response.getStatus()); + Assertions.assertEquals("Version 1.0.0 does not exist for examples.metadata-test in repository", response.getErrors().get(0)); } @Test public void cannotUpdateUnknownProject() { MetadataNotificationResponse response = versionHandler.handleNotification(new MetadataNotification("prod-1","i.am.not.in",TEST_ARTIFACT_ID,"1.0.0",true,false,PARENT_EVENT_ID)); - Assert.assertNotNull(response); - Assert.assertEquals(MetadataNotificationStatus.FAILED,response.getStatus()); - Assert.assertEquals("No Project with coordinates i.am.not.in-test found", response.getErrors().get(0)); + Assertions.assertNotNull(response); + Assertions.assertEquals(MetadataNotificationStatus.FAILED,response.getStatus()); + Assertions.assertEquals("No Project with coordinates i.am.not.in-test found", response.getErrors().get(0)); } @Test @@ -194,10 +194,10 @@ public void cannotUpdateProjectWithDuplicateCoordinates() throws ArtifactReposit { when(repositoryServices.findVersion(TEST_GROUP_ID,TEST_ARTIFACT_ID,BRANCH_SNAPSHOT("master"))).thenReturn(Optional.of(BRANCH_SNAPSHOT("master"))); List response = versionHandler.validate(new MetadataNotification("prod-d",TEST_GROUP_ID,TEST_ARTIFACT_ID,BRANCH_SNAPSHOT("master"),true,false,PARENT_EVENT_ID)); - Assert.assertNotNull(response); - Assert.assertEquals("Invalid projectId [prod-d]. Existing project [PROD-1] has same [examples.metadata-test] coordinates", response.get(0)); - Assert.assertEquals("Invalid projectId [null]. Existing project [PROD-1] has same [examples.metadata-test] coordinates", versionHandler.validate(new MetadataNotification(null,TEST_GROUP_ID,TEST_ARTIFACT_ID,BRANCH_SNAPSHOT("master"),true,false,PARENT_EVENT_ID)).get(0)); - Assert.assertEquals("Invalid projectId []. Existing project [PROD-1] has same [examples.metadata-test] coordinates", versionHandler.validate(new MetadataNotification("",TEST_GROUP_ID,TEST_ARTIFACT_ID,BRANCH_SNAPSHOT("master"),true,false,PARENT_EVENT_ID)).get(0)); + Assertions.assertNotNull(response); + Assertions.assertEquals("Invalid projectId [prod-d]. Existing project [PROD-1] has same [examples.metadata-test] coordinates", response.get(0)); + Assertions.assertEquals("Invalid projectId [null]. Existing project [PROD-1] has same [examples.metadata-test] coordinates", versionHandler.validate(new MetadataNotification(null,TEST_GROUP_ID,TEST_ARTIFACT_ID,BRANCH_SNAPSHOT("master"),true,false,PARENT_EVENT_ID)).get(0)); + Assertions.assertEquals("Invalid projectId []. Existing project [PROD-1] has same [examples.metadata-test] coordinates", versionHandler.validate(new MetadataNotification("",TEST_GROUP_ID,TEST_ARTIFACT_ID,BRANCH_SNAPSHOT("master"),true,false,PARENT_EVENT_ID)).get(0)); } @Test @@ -208,10 +208,10 @@ public void canRefreshMasterWithMasterSnapshotDependency() throws ArtifactReposi when(repositoryServices.findVersion(TEST_GROUP_ID,TEST_DEPENDENCIES_ARTIFACT_ID,BRANCH_SNAPSHOT("master"))).thenReturn(Optional.of(BRANCH_SNAPSHOT("master"))); when(repositoryServices.findDependencies(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master"))).thenReturn(artifactDependency); MetadataNotificationResponse response = versionHandler.handleNotification(new MetadataNotification("",TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master"), false, false, PARENT_EVENT_ID)); - Assert.assertNotNull(response); - Assert.assertEquals(MetadataNotificationStatus.FAILED, response.getStatus()); - Assert.assertTrue(response.getErrors().contains("Dependency examples.metadata-test-dependencies-master-SNAPSHOT not found in store")); - Assert.assertFalse(projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master")).get().getVersionData().getDependencies().isEmpty()); + Assertions.assertNotNull(response); + Assertions.assertEquals(MetadataNotificationStatus.FAILED, response.getStatus()); + Assertions.assertTrue(response.getErrors().contains("Dependency examples.metadata-test-dependencies-master-SNAPSHOT not found in store")); + Assertions.assertFalse(projectsService.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master")).get().getVersionData().getDependencies().isEmpty()); } @Test @@ -220,8 +220,8 @@ public void cantRefreshVersionWithMasterDependencies() Set artifactDependency = Collections.singleton(new ArtifactDependency(TEST_GROUP_ID, TEST_DEPENDENCIES_ARTIFACT_ID, BRANCH_SNAPSHOT("master"))); when(repositoryServices.findDependencies(TEST_GROUP_ID, TEST_ARTIFACT_ID, "1.0.0")).thenReturn(artifactDependency); MetadataNotificationResponse response = versionHandler.handleNotification(new MetadataNotification("",TEST_GROUP_ID, TEST_ARTIFACT_ID, "1.0.0", true,false, PARENT_EVENT_ID)); - Assert.assertNotNull(response); - Assert.assertEquals(MetadataNotificationStatus.FAILED, response.getStatus()); + Assertions.assertNotNull(response); + Assertions.assertEquals(MetadataNotificationStatus.FAILED, response.getStatus()); } @Test @@ -233,7 +233,7 @@ public void cannotLoadSnapshotVersionIfLimitExceeded() List errors = versionHandler.validate(new MetadataNotification("PROD-1", "examples.metadata", "test", "branch4-SNAPSHOT")); - Assert.assertEquals(1, errors.size()); + Assertions.assertEquals(1, errors.size()); } @Test @@ -245,6 +245,6 @@ public void canLoadSnapshotVersionIfAlreadyStored() List errors = versionHandler.validate(new MetadataNotification("PROD-1", "examples.metadata", "test", "branch3-SNAPSHOT")); - Assert.assertEquals(0, errors.size()); + Assertions.assertEquals(0, errors.size()); } } diff --git a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestRefreshDependenciesService.java b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestRefreshDependenciesService.java index 3435710bf..ae8543002 100644 --- a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestRefreshDependenciesService.java +++ b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestRefreshDependenciesService.java @@ -32,9 +32,9 @@ import org.finos.legend.depot.store.mongo.projects.ProjectsMongo; import org.finos.legend.depot.store.mongo.projects.ProjectsVersionsMongo; import org.finos.legend.depot.services.api.notifications.queue.Queue; -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 java.util.Arrays; import java.util.Collections; @@ -54,14 +54,14 @@ public class TestRefreshDependenciesService extends CoreDataMongoStoreTests private static final String GROUPID = "examples.metadata"; - @Before + @BeforeEach public void setUpData() { List projectVersionData = readProjectVersionsConfigsFile(this.getClass().getClassLoader().getResource("data/testProjectsVersions.json")); projectVersionData.forEach(pv -> this.projectsVersionsStore.createOrUpdate(pv)); List projectData = readProjectConfigsFile(this.getClass().getClassLoader().getResource("data/testProjects.json")); projectData.forEach(p -> this.projectsStore.createOrUpdate(p)); - Assert.assertEquals(5, projectsVersionsStore.getAll().size()); + Assertions.assertEquals(5, projectsVersionsStore.getAll().size()); } @Test @@ -74,11 +74,11 @@ public void canUpdateTransitiveDependencies() projectsVersionsStore.createOrUpdate(project1); StoreProjectVersionData versionData = refreshDependenciesService.updateTransitiveDependencies(GROUPID, "test-master", "3.0.0"); - Assert.assertTrue(versionData.getTransitiveDependenciesReport().isValid()); + Assertions.assertTrue(versionData.getTransitiveDependenciesReport().isValid()); List transitiveDependencies = versionData.getTransitiveDependenciesReport().getTransitiveDependencies(); - Assert.assertEquals(5, transitiveDependencies.size()); + Assertions.assertEquals(5, transitiveDependencies.size()); List dependencies = Arrays.asList(dependency, new ProjectVersion(GROUPID, "test-dependencies", "2.0.0"), new ProjectVersion(GROUPID, "art101", "1.0.0"),new ProjectVersion(GROUPID, "art102", "1.0.0"), new ProjectVersion(GROUPID, "art103", "1.0.0")); - Assert.assertEquals(transitiveDependencies, dependencies); + Assertions.assertEquals(transitiveDependencies, dependencies); } @Test @@ -104,16 +104,16 @@ public void canUpdateTransitiveDependenciesForRevision() projectsVersionsStore.createOrUpdate(project3); project1 = refreshDependenciesService.updateTransitiveDependencies(GROUPID, "test-master", "branch1-SNAPSHOT"); - Assert.assertTrue(project1.getTransitiveDependenciesReport().isValid()); - Assert.assertEquals(Collections.singletonList(dependency1), project1.getTransitiveDependenciesReport().getTransitiveDependencies()); + Assertions.assertTrue(project1.getTransitiveDependenciesReport().isValid()); + Assertions.assertEquals(Collections.singletonList(dependency1), project1.getTransitiveDependenciesReport().getTransitiveDependencies()); //chain update of snapshot dependants project2 = projectsService.find(GROUPID, "art105", "branch1-SNAPSHOT").get(); - Assert.assertTrue(project2.getTransitiveDependenciesReport().isValid()); - Assert.assertEquals(Arrays.asList(dependency1, dependency2), project2.getTransitiveDependenciesReport().getTransitiveDependencies()); + Assertions.assertTrue(project2.getTransitiveDependenciesReport().isValid()); + Assertions.assertEquals(Arrays.asList(dependency1, dependency2), project2.getTransitiveDependenciesReport().getTransitiveDependencies()); project3 = projectsService.find(GROUPID, "art106", "branch1-SNAPSHOT").get(); - Assert.assertTrue(project3.getTransitiveDependenciesReport().isValid()); - Assert.assertEquals(Arrays.asList(dependency1, dependency3, dependency2), project3.getTransitiveDependenciesReport().getTransitiveDependencies()); + Assertions.assertTrue(project3.getTransitiveDependenciesReport().isValid()); + Assertions.assertEquals(Arrays.asList(dependency1, dependency3, dependency2), project3.getTransitiveDependenciesReport().getTransitiveDependencies()); } @Test @@ -124,8 +124,8 @@ public void canOverrideDependencies1() project1.getVersionData().setDependencies(Collections.singletonList(dependency)); projectsService.createOrUpdate(project1); project1 = refreshDependenciesService.updateTransitiveDependencies(GROUPID, "art102", "2.0.0"); - Assert.assertTrue(project1.getTransitiveDependenciesReport().isValid()); - Assert.assertEquals(Collections.singletonList(dependency), project1.getTransitiveDependenciesReport().getTransitiveDependencies()); + Assertions.assertTrue(project1.getTransitiveDependenciesReport().isValid()); + Assertions.assertEquals(Collections.singletonList(dependency), project1.getTransitiveDependenciesReport().getTransitiveDependencies()); //overriding test:1.0.0 dependency with test:3.0.0 StoreProjectVersionData project2 = new StoreProjectVersionData(GROUPID, "test-master", "3.0.0"); @@ -135,8 +135,8 @@ public void canOverrideDependencies1() projectsService.createOrUpdate(project2); project2 = refreshDependenciesService.updateTransitiveDependencies(GROUPID, "test-master", "3.0.0"); - Assert.assertTrue(project2.getTransitiveDependenciesReport().isValid()); - Assert.assertEquals(Arrays.asList(dependency1, dependency2, new ProjectVersion(GROUPID, "test-dependencies", "2.0.0"), new ProjectVersion(GROUPID, "art101", "1.0.0")), project2.getTransitiveDependenciesReport().getTransitiveDependencies()); + Assertions.assertTrue(project2.getTransitiveDependenciesReport().isValid()); + Assertions.assertEquals(Arrays.asList(dependency1, dependency2, new ProjectVersion(GROUPID, "test-dependencies", "2.0.0"), new ProjectVersion(GROUPID, "art101", "1.0.0")), project2.getTransitiveDependenciesReport().getTransitiveDependencies()); } @Test @@ -149,8 +149,8 @@ public void canOverrideDependencies2() project1.getVersionData().setDependencies(Collections.singletonList(dependency)); projectsService.createOrUpdate(project1); project1 = refreshDependenciesService.updateTransitiveDependencies(GROUPID, "art102", "2.0.0"); - Assert.assertTrue(project1.getTransitiveDependenciesReport().isValid()); - Assert.assertEquals(Collections.singletonList(dependency), project1.getTransitiveDependenciesReport().getTransitiveDependencies()); + Assertions.assertTrue(project1.getTransitiveDependenciesReport().isValid()); + Assertions.assertEquals(Collections.singletonList(dependency), project1.getTransitiveDependenciesReport().getTransitiveDependencies()); //overriding art102:1.0.0 dependency with art102:2.0.0 with a different underlying dependency StoreProjectVersionData project2 = new StoreProjectVersionData(GROUPID, "test-master", "3.0.0"); @@ -160,8 +160,8 @@ public void canOverrideDependencies2() projectsService.createOrUpdate(project2); project2 = refreshDependenciesService.updateTransitiveDependencies(GROUPID, "test-master", "3.0.0"); - Assert.assertTrue(project2.getTransitiveDependenciesReport().isValid()); - Assert.assertEquals(Arrays.asList(dependency1, dependency, dependency2, new ProjectVersion(GROUPID, "test-dependencies", "2.0.0"), new ProjectVersion(GROUPID, "art101", "1.0.0")), project2.getTransitiveDependenciesReport().getTransitiveDependencies()); + Assertions.assertTrue(project2.getTransitiveDependenciesReport().isValid()); + Assertions.assertEquals(Arrays.asList(dependency1, dependency, dependency2, new ProjectVersion(GROUPID, "test-dependencies", "2.0.0"), new ProjectVersion(GROUPID, "art101", "1.0.0")), project2.getTransitiveDependenciesReport().getTransitiveDependencies()); } // Example : A -> B_V1 -> C_V1 @@ -178,8 +178,8 @@ public void canOverrideDependencies3() project1.getVersionData().setDependencies(Collections.singletonList(dependency)); projectsService.createOrUpdate(project1); project1 = refreshDependenciesService.updateTransitiveDependencies(GROUPID, "art102", "1.0.0"); - Assert.assertTrue(project1.getTransitiveDependenciesReport().isValid()); - Assert.assertEquals(Collections.singletonList(dependency), project1.getTransitiveDependenciesReport().getTransitiveDependencies()); + Assertions.assertTrue(project1.getTransitiveDependenciesReport().isValid()); + Assertions.assertEquals(Collections.singletonList(dependency), project1.getTransitiveDependenciesReport().getTransitiveDependencies()); projectsService.createOrUpdate(new StoreProjectVersionData(GROUPID, "art104", "2.0.0")); @@ -188,16 +188,16 @@ public void canOverrideDependencies3() project2.getVersionData().setDependencies(Collections.singletonList(dependency1)); projectsService.createOrUpdate(project2); project2 = refreshDependenciesService.updateTransitiveDependencies(GROUPID, "art102", "2.0.0"); - Assert.assertTrue(project2.getTransitiveDependenciesReport().isValid()); - Assert.assertEquals(Collections.singletonList(dependency1), project2.getTransitiveDependenciesReport().getTransitiveDependencies()); + Assertions.assertTrue(project2.getTransitiveDependenciesReport().isValid()); + Assertions.assertEquals(Collections.singletonList(dependency1), project2.getTransitiveDependenciesReport().getTransitiveDependencies()); StoreProjectVersionData project3 = new StoreProjectVersionData(GROUPID, "test", "5.0.0"); ProjectVersion dependency2 = new ProjectVersion(GROUPID, "art102", "1.0.0"); project3.getVersionData().setDependencies(Collections.singletonList(dependency2)); projectsService.createOrUpdate(project3); project3 = refreshDependenciesService.updateTransitiveDependencies(GROUPID, "test", "5.0.0"); - Assert.assertTrue(project3.getTransitiveDependenciesReport().isValid()); - Assert.assertEquals(Arrays.asList(dependency, dependency2), project3.getTransitiveDependenciesReport().getTransitiveDependencies()); + Assertions.assertTrue(project3.getTransitiveDependenciesReport().isValid()); + Assertions.assertEquals(Arrays.asList(dependency, dependency2), project3.getTransitiveDependenciesReport().getTransitiveDependencies()); //overriding art102:1.0.0 dependency with art102:2.0.0 with a different underlying dependency StoreProjectVersionData project4 = new StoreProjectVersionData(GROUPID, "test-master", "3.0.0"); @@ -207,8 +207,8 @@ public void canOverrideDependencies3() projectsService.createOrUpdate(project4); project4 = refreshDependenciesService.updateTransitiveDependencies(GROUPID, "test-master", "3.0.0"); - Assert.assertTrue(project4.getTransitiveDependenciesReport().isValid()); - Assert.assertEquals(Arrays.asList(dependency3, dependency4, dependency1), project4.getTransitiveDependenciesReport().getTransitiveDependencies()); + Assertions.assertTrue(project4.getTransitiveDependenciesReport().isValid()); + Assertions.assertEquals(Arrays.asList(dependency3, dependency4, dependency1), project4.getTransitiveDependenciesReport().getTransitiveDependencies()); } @Test @@ -250,7 +250,7 @@ public void canOverrideDependencies4() projectsService.createOrUpdate(project); project = refreshDependenciesService.updateTransitiveDependencies("examples.metadata", "testa", "1.0.0"); - Assert.assertEquals(4, project.getTransitiveDependenciesReport().getTransitiveDependencies().size()); - Assert.assertEquals(Arrays.asList(dependency2, pv2, dependency3, pv1), project.getTransitiveDependenciesReport().getTransitiveDependencies()); + Assertions.assertEquals(4, project.getTransitiveDependenciesReport().getTransitiveDependencies().size()); + Assertions.assertEquals(Arrays.asList(dependency2, pv2, dependency3, pv1), project.getTransitiveDependenciesReport().getTransitiveDependencies()); } } diff --git a/legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/artifacts/TestArtifactMongo.java b/legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/artifacts/TestArtifactMongo.java index be4a73ba1..85a9d9409 100644 --- a/legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/artifacts/TestArtifactMongo.java +++ b/legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/artifacts/TestArtifactMongo.java @@ -19,8 +19,8 @@ import org.finos.legend.depot.store.model.admin.artifacts.ArtifactFile; import org.finos.legend.depot.store.mongo.TestStoreMongo; import org.finos.legend.depot.store.mongo.artifacts.ArtifactsFilesMongo; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.Optional; @@ -37,11 +37,11 @@ public void canStoreArtifactsInformation() ArtifactsFilesStore artifacts = new ArtifactsFilesMongo(this.mongoProvider); ArtifactFile result = artifacts.createOrUpdate(detail); - Assert.assertNotNull(result); + Assertions.assertNotNull(result); Optional artifact = artifacts.find(FILE_PATH); - Assert.assertTrue(artifact.isPresent()); - Assert.assertEquals(FILE_PATH, artifact.get().getPath()); + Assertions.assertTrue(artifact.isPresent()); + Assertions.assertEquals(FILE_PATH, artifact.get().getPath()); } @@ -52,18 +52,18 @@ public void canUpdateArtifactsInformation() ArtifactsFilesStore artifacts = new ArtifactsFilesMongo(this.mongoProvider); ArtifactFile result = artifacts.createOrUpdate(detail); - Assert.assertNotNull(result); + Assertions.assertNotNull(result); Optional artifact = artifacts.find(FILE_PATH); - Assert.assertNotNull(artifact); - Assert.assertEquals(FILE_PATH, artifact.get().getPath()); - Assert.assertNull(artifact.get().getCheckSum()); + Assertions.assertNotNull(artifact); + Assertions.assertEquals(FILE_PATH, artifact.get().getPath()); + Assertions.assertNull(artifact.get().getCheckSum()); ArtifactFile result1 = artifacts.createOrUpdate(detail.setCheckSum("laalalala")); - Assert.assertNotNull(result1); + Assertions.assertNotNull(result1); Optional artifact1 = artifacts.find(FILE_PATH); - Assert.assertNotNull(artifact); - Assert.assertEquals(FILE_PATH, artifact1.get().getPath()); - Assert.assertEquals("laalalala", artifact1.get().getCheckSum()); + Assertions.assertNotNull(artifact); + Assertions.assertEquals(FILE_PATH, artifact1.get().getPath()); + Assertions.assertEquals("laalalala", artifact1.get().getCheckSum()); } diff --git a/legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/artifacts/TestMongoAdminStore.java b/legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/artifacts/TestMongoAdminStore.java index 31261e41b..bc84c53e5 100644 --- a/legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/artifacts/TestMongoAdminStore.java +++ b/legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/artifacts/TestMongoAdminStore.java @@ -20,8 +20,8 @@ import org.finos.legend.depot.store.mongo.admin.MongoAdminStore; import org.finos.legend.depot.store.mongo.artifacts.ArtifactsFilesMongo; import org.finos.legend.depot.store.mongo.core.BaseMongo; -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; @@ -37,15 +37,15 @@ public void canCreateProjectsIndexesIfAbsent() { List indexes = new ArrayList<>(); this.mongoProvider.getCollection(ArtifactsFilesMongo.COLLECTION).listIndexes().forEach((Consumer) indexes::add); - Assert.assertTrue(indexes.isEmpty()); + Assertions.assertTrue(indexes.isEmpty()); List result = BaseMongo.createIndexesIfAbsent(mongoProvider, ArtifactsFilesMongo.COLLECTION, ArtifactsFilesMongo.buildIndexes()); - Assert.assertFalse(result.isEmpty()); + Assertions.assertFalse(result.isEmpty()); List indexes1 = new ArrayList(); this.mongoProvider.getCollection(ArtifactsFilesMongo.COLLECTION).listIndexes().forEach((Consumer) indexes1::add); - Assert.assertFalse(indexes1.isEmpty()); - Assert.assertEquals(2, indexes1.size()); + Assertions.assertFalse(indexes1.isEmpty()); + Assertions.assertEquals(2, indexes1.size()); } } diff --git a/legend-depot-core-authorisation/src/test/java/org/finos/legend/depot/core/services/authorisation/TestBasicAuthorisationProvider.java b/legend-depot-core-authorisation/src/test/java/org/finos/legend/depot/core/services/authorisation/TestBasicAuthorisationProvider.java index e5e0d16ba..1450b68ae 100644 --- a/legend-depot-core-authorisation/src/test/java/org/finos/legend/depot/core/services/authorisation/TestBasicAuthorisationProvider.java +++ b/legend-depot-core-authorisation/src/test/java/org/finos/legend/depot/core/services/authorisation/TestBasicAuthorisationProvider.java @@ -16,8 +16,8 @@ package org.finos.legend.depot.core.services.authorisation; import org.finos.legend.depot.core.services.api.authorisation.AuthorisationProvider; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class TestBasicAuthorisationProvider { @@ -26,20 +26,20 @@ public void canAuthorise() { AuthorisationProvider provider = new BasicAuthorisationProvider(); provider.authorise(() -> () -> "test","admin"); - Assert.assertTrue(true); + Assertions.assertTrue(true); } - @Test(expected = SecurityException.class) + @Test public void failAuthorise() { AuthorisationProvider provider = new BasicAuthorisationProvider(); - provider.authorise(() -> () -> "test", "notknownrole"); + Assertions.assertThrows(SecurityException.class, () -> provider.authorise(() -> () -> "test", "notknownrole")); } - @Test(expected = SecurityException.class) + @Test public void userFailAuthorise() { AuthorisationProvider provider = new BasicAuthorisationProvider(); - provider.authorise(() -> () -> "notauthorised", "admin"); + Assertions.assertThrows(SecurityException.class, () -> provider.authorise(() -> () -> "notauthorised", "admin")); } } diff --git a/legend-depot-core-data-api/src/test/java/org/finos/legend/depot/domain/project/TestProjectUtilities.java b/legend-depot-core-data-api/src/test/java/org/finos/legend/depot/domain/project/TestProjectUtilities.java index fb6acc5a8..4f9c2dd83 100644 --- a/legend-depot-core-data-api/src/test/java/org/finos/legend/depot/domain/project/TestProjectUtilities.java +++ b/legend-depot-core-data-api/src/test/java/org/finos/legend/depot/domain/project/TestProjectUtilities.java @@ -17,8 +17,8 @@ import org.finos.legend.depot.domain.CoordinateValidator; import org.finos.legend.depot.store.model.projects.StoreProjectData; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class TestProjectUtilities { @@ -26,21 +26,21 @@ public class TestProjectUtilities @Test public void validGroupId() { - Assert.assertTrue(CoordinateValidator.isValidGroupId("example.good.group")); - Assert.assertTrue(CoordinateValidator.isValidGroupId("org.finos")); - Assert.assertFalse(CoordinateValidator.isValidGroupId("")); - Assert.assertFalse(CoordinateValidator.isValidGroupId("this is not a good one")); - Assert.assertFalse(CoordinateValidator.isValidGroupId("this.is.starting.well but not ending well")); - Assert.assertTrue(CoordinateValidator.isValidGroupId("singleWordNoDots")); + Assertions.assertTrue(CoordinateValidator.isValidGroupId("example.good.group")); + Assertions.assertTrue(CoordinateValidator.isValidGroupId("org.finos")); + Assertions.assertFalse(CoordinateValidator.isValidGroupId("")); + Assertions.assertFalse(CoordinateValidator.isValidGroupId("this is not a good one")); + Assertions.assertFalse(CoordinateValidator.isValidGroupId("this.is.starting.well but not ending well")); + Assertions.assertTrue(CoordinateValidator.isValidGroupId("singleWordNoDots")); } @Test public void validArtifactId() { - Assert.assertTrue(CoordinateValidator.isValidArtifactId("test")); - Assert.assertTrue(CoordinateValidator.isValidArtifactId("test-other")); - Assert.assertFalse(CoordinateValidator.isValidArtifactId("")); - Assert.assertFalse(CoordinateValidator.isValidArtifactId("singleWordNoDots")); + Assertions.assertTrue(CoordinateValidator.isValidArtifactId("test")); + Assertions.assertTrue(CoordinateValidator.isValidArtifactId("test-other")); + Assertions.assertFalse(CoordinateValidator.isValidArtifactId("")); + Assertions.assertFalse(CoordinateValidator.isValidArtifactId("singleWordNoDots")); } @Test @@ -48,17 +48,17 @@ public void testEvaluateLatestVersionAndUpdate() { StoreProjectData projectData = new StoreProjectData("PROD-1", "examples.test", "metadata", null, "2.1.0"); - Assert.assertTrue(projectData.evaluateLatestVersionAndUpdate("3.0.0")); - Assert.assertEquals(projectData.getLatestVersion(), "3.0.0"); + Assertions.assertTrue(projectData.evaluateLatestVersionAndUpdate("3.0.0")); + Assertions.assertEquals(projectData.getLatestVersion(), "3.0.0"); projectData.setLatestVersion("2.1.0"); - Assert.assertFalse(projectData.evaluateLatestVersionAndUpdate("2.1.0")); - Assert.assertFalse(projectData.evaluateLatestVersionAndUpdate("2.0.1")); + Assertions.assertFalse(projectData.evaluateLatestVersionAndUpdate("2.1.0")); + Assertions.assertFalse(projectData.evaluateLatestVersionAndUpdate("2.0.1")); projectData = new StoreProjectData("PROD-1", "examples.test", "metadata", null, null); - Assert.assertTrue(projectData.evaluateLatestVersionAndUpdate("3.0.0")); - Assert.assertEquals(projectData.getLatestVersion(), "3.0.0"); + Assertions.assertTrue(projectData.evaluateLatestVersionAndUpdate("3.0.0")); + Assertions.assertEquals(projectData.getLatestVersion(), "3.0.0"); - Assert.assertFalse(projectData.evaluateLatestVersionAndUpdate("master-SNAPSHOT")); + Assertions.assertFalse(projectData.evaluateLatestVersionAndUpdate("master-SNAPSHOT")); } } diff --git a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/server/resources/TestProjectsResource.java b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/server/resources/TestProjectsResource.java index 0abac14f4..a17644b5f 100644 --- a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/server/resources/TestProjectsResource.java +++ b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/server/resources/TestProjectsResource.java @@ -21,8 +21,8 @@ import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; import org.finos.legend.depot.services.api.projects.configuration.ProjectsConfiguration; import org.finos.legend.depot.services.api.notifications.queue.Queue; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.List; @@ -38,15 +38,15 @@ public class TestProjectsResource extends TestBaseServices public void canQueryVersionsForProjectGA() { List versionSet = (List) projectsVersionsResource.getVersions("examples.metadata", "test", false).getEntity(); - Assert.assertNotNull(versionSet); - Assert.assertEquals(2, versionSet.size()); + Assertions.assertNotNull(versionSet); + Assertions.assertEquals(2, versionSet.size()); } @Test public void canQueryVersionsForProject() { List versionSet = (List) projectsVersionsResource.getVersions("examples.metadata", "test",false).getEntity(); - Assert.assertNotNull(versionSet); - Assert.assertEquals(2, versionSet.size()); + Assertions.assertNotNull(versionSet); + Assertions.assertEquals(2, versionSet.size()); } } \ No newline at end of file diff --git a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/server/resources/TestProjectsVersionsResource.java b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/server/resources/TestProjectsVersionsResource.java index 16276d2a1..0a0cda10f 100644 --- a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/server/resources/TestProjectsVersionsResource.java +++ b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/server/resources/TestProjectsVersionsResource.java @@ -22,8 +22,8 @@ import org.finos.legend.depot.services.api.projects.configuration.ProjectsConfiguration; import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; import org.finos.legend.depot.services.api.notifications.queue.Queue; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Response; import java.util.Map; @@ -45,20 +45,20 @@ public void canQueryLatestProjectVersionData() { Response responseOne = projectsVersionsResource.getProjectVersion("examples.metadata", "test","latest"); Optional versionData = (Optional) responseOne.getEntity(); - Assert.assertTrue(versionData.isPresent()); - Assert.assertEquals(versionData.get().getGroupId(), "examples.metadata"); - Assert.assertEquals(versionData.get().getArtifactId(), "test"); - Assert.assertEquals(versionData.get().getVersionId(), "2.3.1"); - Assert.assertEquals(versionData.get().getVersionData().getDependencies().get(0), new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0")); + Assertions.assertTrue(versionData.isPresent()); + Assertions.assertEquals(versionData.get().getGroupId(), "examples.metadata"); + Assertions.assertEquals(versionData.get().getArtifactId(), "test"); + Assertions.assertEquals(versionData.get().getVersionId(), "2.3.1"); + Assertions.assertEquals(versionData.get().getVersionData().getDependencies().get(0), new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0")); Map manifestProperties = versionData.get().getVersionData().getManifestProperties(); - Assert.assertNotNull(manifestProperties); - Assert.assertEquals(manifestProperties.get("commit-author"), "test-author"); - Assert.assertEquals(manifestProperties.get("commit-timestamp"), "2023-04-11T14:48:27+00:00"); + Assertions.assertNotNull(manifestProperties); + Assertions.assertEquals(manifestProperties.get("commit-author"), "test-author"); + Assertions.assertEquals(manifestProperties.get("commit-timestamp"), "2023-04-11T14:48:27+00:00"); Response responseTwo = projectsVersionsResource.getProjectVersion("somethig.random", "test","latest"); Optional versionData1 = (Optional) responseTwo.getEntity(); - Assert.assertFalse(versionData1.isPresent()); + Assertions.assertFalse(versionData1.isPresent()); } @Test @@ -66,13 +66,13 @@ public void canQueryHeadProjectVersionData() { Response responseOne = projectsVersionsResource.getProjectVersion("examples.metadata", "test","head"); Optional versionData = (Optional) responseOne.getEntity(); - Assert.assertTrue(versionData.isPresent()); - Assert.assertEquals(versionData.get().getGroupId(), "examples.metadata"); - Assert.assertEquals(versionData.get().getArtifactId(), "test"); - Assert.assertEquals(versionData.get().getVersionId(), BRANCH_SNAPSHOT("master")); + Assertions.assertTrue(versionData.isPresent()); + Assertions.assertEquals(versionData.get().getGroupId(), "examples.metadata"); + Assertions.assertEquals(versionData.get().getArtifactId(), "test"); + Assertions.assertEquals(versionData.get().getVersionId(), BRANCH_SNAPSHOT("master")); Response responseTwo = projectsVersionsResource.getProjectVersion("somethig.random", "test","head"); Optional versionData1 = (Optional) responseTwo.getEntity(); - Assert.assertFalse(versionData1.isPresent()); + Assertions.assertFalse(versionData1.isPresent()); } } diff --git a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/TestBaseServices.java b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/TestBaseServices.java index 73dad484d..057dfae75 100644 --- a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/TestBaseServices.java +++ b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/TestBaseServices.java @@ -21,7 +21,7 @@ import org.finos.legend.depot.store.mongo.CoreDataMongoStoreTests; import org.finos.legend.depot.store.mongo.projects.ProjectsMongo; import org.finos.legend.depot.store.mongo.projects.ProjectsVersionsMongo; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; public class TestBaseServices extends CoreDataMongoStoreTests { @@ -29,7 +29,7 @@ public class TestBaseServices extends CoreDataMongoStoreTests protected UpdateProjects projectsStore = new ProjectsMongo(mongoProvider); - @Before + @BeforeEach public void setUpData() { setUpProjectsVersionsFromFile(TestStoreMongo.class.getClassLoader().getResource("data/projectsVersions.json")); diff --git a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/projects/TestProjectsService.java b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/projects/TestProjectsService.java index 4c7da390f..f20c8e0db 100644 --- a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/projects/TestProjectsService.java +++ b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/projects/TestProjectsService.java @@ -32,9 +32,9 @@ import org.finos.legend.depot.services.api.projects.configuration.ProjectsConfiguration; import org.finos.legend.depot.services.api.notifications.queue.Queue; import org.finos.legend.depot.store.mongo.notifications.queue.NotificationsQueueMongo; -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 java.util.List; import java.util.Optional; @@ -52,12 +52,12 @@ public class TestProjectsService extends TestBaseServices private final Queue queue = new NotificationsQueueMongo(mongoProvider); protected ManageProjectsService projectsService = new ManageProjectsServiceImpl(projectsVersionsStore, projectsStore, metrics, queue, new ProjectsConfiguration("master")); - @Before + @BeforeEach public void setUpData() { super.setUpData(); - Assert.assertEquals(6, projectsService.getAll().size()); - Assert.assertEquals(0, projectsService.find("examples.metadata","test", "2.2.0").get().getVersionData().getDependencies().size()); + Assertions.assertEquals(6, projectsService.getAll().size()); + Assertions.assertEquals(0, projectsService.find("examples.metadata","test", "2.2.0").get().getVersionData().getDependencies().size()); StoreProjectVersionData project1 = projectsService.find("examples.metadata", "test-dependencies", "1.0.0").get(); ProjectVersion pv = new ProjectVersion("example.services.test", "test", "1.0.0"); @@ -65,28 +65,28 @@ public void setUpData() projectsVersionsStore.createOrUpdate(new StoreProjectVersionData("example.services.test", "test", "1.0.0")); projectsVersionsStore.createOrUpdate(project1); StoreProjectVersionData project2 = projectsService.find("examples.metadata","test", "2.3.1").get(); - Assert.assertEquals(1, project2.getVersionData().getDependencies().size()); + Assertions.assertEquals(1, project2.getVersionData().getDependencies().size()); project2.setTransitiveDependenciesReport(new VersionDependencyReport(Collections.singletonList(pv), true)); projectsVersionsStore.createOrUpdate(project2); - Assert.assertEquals(1, projectsVersionsStore.find("examples.metadata", "test-dependencies", "1.0.0").get().getVersionData().getDependencies().size()); + Assertions.assertEquals(1, projectsVersionsStore.find("examples.metadata", "test-dependencies", "1.0.0").get().getVersionData().getDependencies().size()); } @Test public void canDeleteProjectByCoordinates() { List project1 = projectsService.find("examples.metadata","test-dependencies"); - Assert.assertFalse(project1.isEmpty()); + Assertions.assertFalse(project1.isEmpty()); projectsService.delete("examples.metadata","test-dependencies"); - Assert.assertTrue(projectsService.find("examples.metadata","test-dependencies").isEmpty()); + Assertions.assertTrue(projectsService.find("examples.metadata","test-dependencies").isEmpty()); } @Test public void canDeleteProjectVersion() { Optional project1 = projectsService.find("examples.metadata","test-dependencies", "1.0.0"); - Assert.assertTrue(project1.isPresent()); + Assertions.assertTrue(project1.isPresent()); projectsService.delete("examples.metadata","test-dependencies","1.0.0"); - Assert.assertFalse(projectsService.find("examples.metadata","test-dependencies","1.0.0").isPresent()); + Assertions.assertFalse(projectsService.find("examples.metadata","test-dependencies","1.0.0").isPresent()); } @@ -94,51 +94,51 @@ public void canDeleteProjectVersion() public void canGetProjectDependencies() { Set dependencyList = projectsService.getDependencies("examples.metadata", "test", "2.3.1", false); - Assert.assertFalse(dependencyList.isEmpty()); - Assert.assertTrue(dependencyList.contains(new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"))); + Assertions.assertFalse(dependencyList.isEmpty()); + Assertions.assertTrue(dependencyList.contains(new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"))); Set dependencyList2 = projectsService.getDependencies("examples.metadata", "test", "2.3.1", true); - Assert.assertFalse(dependencyList2.isEmpty()); - Assert.assertTrue(dependencyList2.contains(new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"))); - Assert.assertTrue(dependencyList2.contains(new ProjectVersion("example.services.test", "test", "1.0.0"))); - Assert.assertFalse(projectsService.getDependencies("examples.metadata", "test", "2.3.1", false).contains(new ProjectVersion("example.services.test", "test", "2.0.1"))); + Assertions.assertFalse(dependencyList2.isEmpty()); + Assertions.assertTrue(dependencyList2.contains(new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"))); + Assertions.assertTrue(dependencyList2.contains(new ProjectVersion("example.services.test", "test", "1.0.0"))); + Assertions.assertFalse(projectsService.getDependencies("examples.metadata", "test", "2.3.1", false).contains(new ProjectVersion("example.services.test", "test", "2.0.1"))); // Dependency Tree ProjectDependencyReport dependencyReport = projectsService.getProjectDependencyReport("examples.metadata", "test", "2.3.1"); ProjectDependencyReport.SerializedGraph graph = dependencyReport.getGraph(); MutableMap nodes = graph.getNodes(); - Assert.assertEquals(nodes.size(), 3); - Assert.assertEquals(graph.getRootNodes().size(), 1); + Assertions.assertEquals(nodes.size(), 3); + Assertions.assertEquals(graph.getRootNodes().size(), 1); String rootId = graph.getRootNodes().iterator().next(); - Assert.assertEquals("examples.metadata:test:2.3.1", rootId); + Assertions.assertEquals("examples.metadata:test:2.3.1", rootId); ProjectDependencyVersionNode versionNodeA = nodes.get(rootId); - Assert.assertNotNull(versionNodeA); - Assert.assertEquals("examples.metadata", versionNodeA.getGroupId()); - Assert.assertEquals("test", versionNodeA.getArtifactId()); - Assert.assertEquals("2.3.1", versionNodeA.getVersionId()); - Assert.assertEquals(versionNodeA.getForwardEdges().size(), 1); - Assert.assertEquals(versionNodeA.getBackEdges().size(), 0); + Assertions.assertNotNull(versionNodeA); + Assertions.assertEquals("examples.metadata", versionNodeA.getGroupId()); + Assertions.assertEquals("test", versionNodeA.getArtifactId()); + Assertions.assertEquals("2.3.1", versionNodeA.getVersionId()); + Assertions.assertEquals(versionNodeA.getForwardEdges().size(), 1); + Assertions.assertEquals(versionNodeA.getBackEdges().size(), 0); ProjectDependencyVersionNode versionNodeB = graph.getNodes().get(versionNodeA.getForwardEdges().iterator().next()); - Assert.assertNotNull(versionNodeB); - Assert.assertEquals("examples.metadata", versionNodeB.getGroupId()); - Assert.assertEquals("test-dependencies", versionNodeB.getArtifactId()); - Assert.assertEquals("1.0.0", versionNodeB.getVersionId()); - Assert.assertEquals(1, versionNodeB.getForwardEdges().size()); - Assert.assertEquals(1, versionNodeB.getBackEdges().size()); - Assert.assertEquals(versionNodeA.getId(), versionNodeB.getBackEdges().iterator().next()); + Assertions.assertNotNull(versionNodeB); + Assertions.assertEquals("examples.metadata", versionNodeB.getGroupId()); + Assertions.assertEquals("test-dependencies", versionNodeB.getArtifactId()); + Assertions.assertEquals("1.0.0", versionNodeB.getVersionId()); + Assertions.assertEquals(1, versionNodeB.getForwardEdges().size()); + Assertions.assertEquals(1, versionNodeB.getBackEdges().size()); + Assertions.assertEquals(versionNodeA.getId(), versionNodeB.getBackEdges().iterator().next()); ProjectDependencyVersionNode versionNodeC = graph.getNodes().get(versionNodeB.getForwardEdges().iterator().next()); - Assert.assertNotNull(versionNodeC); - Assert.assertEquals("example.services.test", versionNodeC.getGroupId()); - Assert.assertEquals("test", versionNodeC.getArtifactId()); - Assert.assertEquals("1.0.0", versionNodeC.getVersionId()); - Assert.assertEquals(0, versionNodeC.getForwardEdges().size()); - Assert.assertEquals(1, versionNodeC.getBackEdges().size()); - Assert.assertEquals(versionNodeB.getId(), versionNodeC.getBackEdges().iterator().next()); - - Assert.assertEquals(0, dependencyReport.getConflicts().size()); + Assertions.assertNotNull(versionNodeC); + Assertions.assertEquals("example.services.test", versionNodeC.getGroupId()); + Assertions.assertEquals("test", versionNodeC.getArtifactId()); + Assertions.assertEquals("1.0.0", versionNodeC.getVersionId()); + Assertions.assertEquals(0, versionNodeC.getForwardEdges().size()); + Assertions.assertEquals(1, versionNodeC.getBackEdges().size()); + Assertions.assertEquals(versionNodeB.getId(), versionNodeC.getBackEdges().iterator().next()); + + Assertions.assertEquals(0, dependencyReport.getConflicts().size()); } @Test @@ -157,19 +157,19 @@ public void canGetProjectDependenciesWithOutDuplicates() projectsVersionsStore.createOrUpdate(project1); Set dependencyList = projectsService.getDependencies("examples.metadata", "test", "2.3.1", false); - Assert.assertFalse(dependencyList.isEmpty()); - Assert.assertEquals(2, dependencyList.size()); - Assert.assertTrue(dependencyList.contains(new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"))); - Assert.assertTrue(dependencyList.contains(new ProjectVersion("example.group", "test-dups", "1.0.0"))); + Assertions.assertFalse(dependencyList.isEmpty()); + Assertions.assertEquals(2, dependencyList.size()); + Assertions.assertTrue(dependencyList.contains(new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"))); + Assertions.assertTrue(dependencyList.contains(new ProjectVersion("example.group", "test-dups", "1.0.0"))); Set dependencyList2 = projectsService.getDependencies("examples.metadata", "test", "2.3.1", true); - Assert.assertFalse(dependencyList2.isEmpty()); - Assert.assertEquals(3, dependencyList2.size()); - Assert.assertTrue(dependencyList2.contains(new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"))); - Assert.assertTrue(dependencyList2.contains(new ProjectVersion("example.services.test", "test", "1.0.0"))); - Assert.assertTrue(dependencyList2.contains(new ProjectVersion("example.group", "test-dups", "1.0.0"))); + Assertions.assertFalse(dependencyList2.isEmpty()); + Assertions.assertEquals(3, dependencyList2.size()); + Assertions.assertTrue(dependencyList2.contains(new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"))); + Assertions.assertTrue(dependencyList2.contains(new ProjectVersion("example.services.test", "test", "1.0.0"))); + Assertions.assertTrue(dependencyList2.contains(new ProjectVersion("example.group", "test-dups", "1.0.0"))); - Assert.assertFalse(projectsService.getDependencies("examples.metadata", "test", "2.3.1", false).contains(new ProjectVersion("example.services.test", "test", "1.0.0"))); + Assertions.assertFalse(projectsService.getDependencies("examples.metadata", "test", "2.3.1", false).contains(new ProjectVersion("example.services.test", "test", "1.0.0"))); } @@ -192,8 +192,8 @@ public void canGetProjectDependenciesWithConflicts() // Dependency Tree ProjectDependencyReport dependencyReport = projectsService.getProjectDependencyReport(Arrays.asList(new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), new ProjectVersion("example.services.test", "test-dependencies", "1.0.0"))); - Assert.assertEquals(1, dependencyReport.getConflicts().size()); - Assert.assertEquals(dependencyReport.getConflicts().get(0).getVersions(), Sets.mutable.of("example.services.test:test:1.0.0","example.services.test:test:2.0.0")); + Assertions.assertEquals(1, dependencyReport.getConflicts().size()); + Assertions.assertEquals(dependencyReport.getConflicts().get(0).getVersions(), Sets.mutable.of("example.services.test:test:1.0.0","example.services.test:test:2.0.0")); } @Test @@ -215,21 +215,21 @@ public void canGetProjectDependenciesReportWithOverrides() // Dependency Tree ProjectDependencyReport dependencyReport = projectsService.getProjectDependencyReport(Arrays.asList(new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), new ProjectVersion("example.services.test", "test-dependencies", "1.0.0"), dependencyB)); - Assert.assertEquals(0, dependencyReport.getConflicts().size()); + Assertions.assertEquals(0, dependencyReport.getConflicts().size()); } @Test public void canGetProjectDependenciesReportWithOverriddenDependencies() { Set dependencyList = projectsService.getDependencies("examples.metadata", "test", "2.3.1", false); - Assert.assertFalse(dependencyList.isEmpty()); - Assert.assertTrue(dependencyList.contains(new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"))); + Assertions.assertFalse(dependencyList.isEmpty()); + Assertions.assertTrue(dependencyList.contains(new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"))); Set dependencyList2 = projectsService.getDependencies("examples.metadata", "test", "2.3.1", true); - Assert.assertFalse(dependencyList2.isEmpty()); - Assert.assertTrue(dependencyList2.contains(new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"))); - Assert.assertTrue(dependencyList2.contains(new ProjectVersion("example.services.test", "test", "1.0.0"))); - Assert.assertFalse(projectsService.getDependencies("examples.metadata", "test", "2.3.1", false).contains(new ProjectVersion("example.services.test", "test", "2.0.1"))); + Assertions.assertFalse(dependencyList2.isEmpty()); + Assertions.assertTrue(dependencyList2.contains(new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"))); + Assertions.assertTrue(dependencyList2.contains(new ProjectVersion("example.services.test", "test", "1.0.0"))); + Assertions.assertFalse(projectsService.getDependencies("examples.metadata", "test", "2.3.1", false).contains(new ProjectVersion("example.services.test", "test", "2.0.1"))); StoreProjectVersionData projectA = projectsService.find("example.services.test", "test", "1.0.0").get(); StoreProjectVersionData projectB = new StoreProjectVersionData("examples.metadata", "test-dependencies", "2.0.0"); projectA.getVersionData().addDependency(new ProjectVersion("examples.metadata", "test-dependencies", "2.0.0")); @@ -240,7 +240,7 @@ public void canGetProjectDependenciesReportWithOverriddenDependencies() List projectDependencyVersions = Arrays.asList(new ProjectVersion("examples.metadata", "test", "2.3.1"), new ProjectVersion("examples.metadata", "test-dependencies", "2.0.0")); ProjectDependencyReport dependencyReport = projectsService.getProjectDependencyReport(projectDependencyVersions); - Assert.assertEquals(0, dependencyReport.getConflicts().size()); + Assertions.assertEquals(0, dependencyReport.getConflicts().size()); } @@ -249,19 +249,19 @@ public void canGetDependantProjects() { List dependencyList = projectsService.getDependantProjects("examples.metadata", "test", "2.3.1"); - Assert.assertTrue(dependencyList.isEmpty()); + Assertions.assertTrue(dependencyList.isEmpty()); List dependencyList2 = projectsService.getDependantProjects("examples.metadata", "test-dependencies", "1.0.0"); - Assert.assertFalse(dependencyList2.isEmpty()); - Assert.assertEquals(2, dependencyList2.size()); - Assert.assertTrue(dependencyList2.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "2.3.1", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); - Assert.assertTrue(dependencyList2.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", BRANCH_SNAPSHOT("master"), new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); + Assertions.assertFalse(dependencyList2.isEmpty()); + Assertions.assertEquals(2, dependencyList2.size()); + Assertions.assertTrue(dependencyList2.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "2.3.1", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); + Assertions.assertTrue(dependencyList2.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", BRANCH_SNAPSHOT("master"), new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); List dependencyList3 = projectsService.getDependantProjects("example.services.test", "test", "1.0.0"); - Assert.assertFalse(dependencyList3.isEmpty()); - Assert.assertEquals(1, dependencyList3.size()); - Assert.assertTrue(dependencyList3.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test-dependencies", "1.0.0", new ProjectVersion("example.services.test", "test", "1.0.0"), Collections.emptyList()))); - Assert.assertFalse(dependencyList3.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "2.3.1", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); + Assertions.assertFalse(dependencyList3.isEmpty()); + Assertions.assertEquals(1, dependencyList3.size()); + Assertions.assertTrue(dependencyList3.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test-dependencies", "1.0.0", new ProjectVersion("example.services.test", "test", "1.0.0"), Collections.emptyList()))); + Assertions.assertFalse(dependencyList3.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "2.3.1", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); } @@ -270,21 +270,21 @@ public void canExcludeProjectVersion() { final String EXCLUSION_REASON = "payload too big to be handled with mongo currently"; StoreProjectVersionData storeProjectVersionData = projectsService.excludeProjectVersion("examples.metadata", "test", "2.3.1", EXCLUSION_REASON); - Assert.assertTrue(storeProjectVersionData.getVersionData().isExcluded()); - Assert.assertTrue(storeProjectVersionData.getVersionData().getDependencies().size() == 0); - Assert.assertTrue(storeProjectVersionData.getVersionData().getProperties().size() == 0); - Assert.assertEquals(storeProjectVersionData.getVersionData().getExclusionReason(),EXCLUSION_REASON); + Assertions.assertTrue(storeProjectVersionData.getVersionData().isExcluded()); + Assertions.assertTrue(storeProjectVersionData.getVersionData().getDependencies().size() == 0); + Assertions.assertTrue(storeProjectVersionData.getVersionData().getProperties().size() == 0); + Assertions.assertEquals(storeProjectVersionData.getVersionData().getExclusionReason(),EXCLUSION_REASON); } @Test public void canGetProjectCoordinatesByGA() { Optional storeProjectData = projectsService.findCoordinates("examples.metadata", "test"); - Assert.assertTrue(storeProjectData.isPresent()); - Assert.assertEquals(storeProjectData.get(), new StoreProjectData("PROD-A", "examples.metadata", "test", null, "2.3.1")); + Assertions.assertTrue(storeProjectData.isPresent()); + Assertions.assertEquals(storeProjectData.get(), new StoreProjectData("PROD-A", "examples.metadata", "test", null, "2.3.1")); Optional storeProjectData1 = projectsService.findCoordinates("dummy.dep", "test"); - Assert.assertFalse(storeProjectData1.isPresent()); + Assertions.assertFalse(storeProjectData1.isPresent()); } @Test @@ -292,10 +292,10 @@ public void canGetProjectVersionWithLatestVersionNull() { projectsStore.createOrUpdate(new StoreProjectData("PROD-123", "dummy.project", "test")); Optional storeProjectData = projectsService.findCoordinates("dummy.project", "test"); - Assert.assertTrue(storeProjectData.isPresent()); + Assertions.assertTrue(storeProjectData.isPresent()); Optional projectVersionData = projectsService.find("dummy.project", "test", "latest"); - Assert.assertFalse(projectVersionData.isPresent()); + Assertions.assertFalse(projectVersionData.isPresent()); } @Test @@ -305,27 +305,27 @@ public void canRestoreEvictedProjectVersion() versionData.setEvicted(true); projectsVersionsStore.createOrUpdate(versionData); - Assert.assertThrows("Project version: examples.metadata-test-1.0.0 is being restored, please retry in 5 minutes", IllegalStateException.class, () -> projectsService.resolveAliasesAndCheckVersionExists("examples.metadata", "test", "1.0.0")); + Assertions.assertThrows(IllegalStateException.class, () -> projectsService.resolveAliasesAndCheckVersionExists("examples.metadata", "test", "1.0.0"), "Project version: examples.metadata-test-1.0.0 is being restored, please retry in 5 minutes"); List notifications = queue.getAll(); - Assert.assertEquals(1, notifications.size()); + Assertions.assertEquals(1, notifications.size()); } @Test public void canGetDependantProjectsWithAllVersions() { List dependencyList = projectsService.getDependantProjects("examples.metadata", "test", "all"); - Assert.assertTrue(dependencyList.isEmpty()); + Assertions.assertTrue(dependencyList.isEmpty()); List dependencyList2 = projectsService.getDependantProjects("examples.metadata", "test-dependencies", "all"); - Assert.assertFalse(dependencyList2.isEmpty()); - Assert.assertEquals(2, dependencyList2.size()); - Assert.assertTrue(dependencyList2.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "2.3.1", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); - Assert.assertTrue(dependencyList2.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", BRANCH_SNAPSHOT("master"), new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); + Assertions.assertFalse(dependencyList2.isEmpty()); + Assertions.assertEquals(2, dependencyList2.size()); + Assertions.assertTrue(dependencyList2.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "2.3.1", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); + Assertions.assertTrue(dependencyList2.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", BRANCH_SNAPSHOT("master"), new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); List dependencyList3 = projectsService.getDependantProjects("examples.metadata", "test-dependencies", "all", true); - Assert.assertFalse(dependencyList3.isEmpty()); - Assert.assertEquals(1, dependencyList3.size()); - Assert.assertTrue(dependencyList3.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "2.3.1", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); + Assertions.assertFalse(dependencyList3.isEmpty()); + Assertions.assertEquals(1, dependencyList3.size()); + Assertions.assertTrue(dependencyList3.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "2.3.1", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); StoreProjectVersionData projectData = projectsService.find("examples.metadata", "test-dependencies", "1.0.0").get(); @@ -333,48 +333,48 @@ public void canGetDependantProjectsWithAllVersions() projectsVersionsStore.createOrUpdate(projectData); List dependencyList4 = projectsService.getDependantProjects("example.services.test", "test", "all"); - Assert.assertFalse(dependencyList4.isEmpty()); - Assert.assertEquals(2, dependencyList4.size()); - Assert.assertTrue(dependencyList4.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test-dependencies", "1.0.0", new ProjectVersion("example.services.test", "test", "1.0.0"), Collections.emptyList()))); - Assert.assertTrue(dependencyList4.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test-dependencies", "1.0.0", new ProjectVersion("example.services.test", "test", "2.0.0"), Collections.emptyList()))); - Assert.assertFalse(dependencyList4.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "2.3.1", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); + Assertions.assertFalse(dependencyList4.isEmpty()); + Assertions.assertEquals(2, dependencyList4.size()); + Assertions.assertTrue(dependencyList4.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test-dependencies", "1.0.0", new ProjectVersion("example.services.test", "test", "1.0.0"), Collections.emptyList()))); + Assertions.assertTrue(dependencyList4.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test-dependencies", "1.0.0", new ProjectVersion("example.services.test", "test", "2.0.0"), Collections.emptyList()))); + Assertions.assertFalse(dependencyList4.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "2.3.1", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); StoreProjectVersionData projectData1 = projectsService.find("examples.metadata", "test", "3.0.0").get(); projectData1.getVersionData().addDependency(new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0")); projectsVersionsStore.createOrUpdate(projectData1); List dependencyList5 = projectsService.getDependantProjects("examples.metadata", "test-dependencies", "all", true); - Assert.assertFalse(dependencyList5.isEmpty()); - Assert.assertEquals(1, dependencyList5.size()); - Assert.assertTrue(dependencyList5.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "3.0.0", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); + Assertions.assertFalse(dependencyList5.isEmpty()); + Assertions.assertEquals(1, dependencyList5.size()); + Assertions.assertTrue(dependencyList5.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "3.0.0", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); List dependencyList6 = projectsService.getDependantProjects("examples.metadata", "test-dependencies", "all", false); - Assert.assertFalse(dependencyList6.isEmpty()); - Assert.assertEquals(3, dependencyList6.size()); - Assert.assertTrue(dependencyList6.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "2.3.1", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); - Assert.assertTrue(dependencyList6.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "master-SNAPSHOT", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); - Assert.assertTrue(dependencyList6.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "3.0.0", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); + Assertions.assertFalse(dependencyList6.isEmpty()); + Assertions.assertEquals(3, dependencyList6.size()); + Assertions.assertTrue(dependencyList6.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "2.3.1", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); + Assertions.assertTrue(dependencyList6.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "master-SNAPSHOT", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); + Assertions.assertTrue(dependencyList6.contains(new ProjectDependencyWithPlatformVersions("examples.metadata", "test", "3.0.0", new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0"), Collections.emptyList()))); } @Test public void canGetLatestVersionForProject() { List fullVersions = projectsService.getVersions("examples.metadata", "test"); - Assert.assertNotNull(fullVersions); - Assert.assertEquals(2, fullVersions.size()); + Assertions.assertNotNull(fullVersions); + Assertions.assertEquals(2, fullVersions.size()); - Assert.assertTrue(projectsService.findCoordinates("examples.metadata", "test").isPresent()); - Assert.assertEquals("2.3.1", projectsService.findCoordinates("examples.metadata", "test").get().getLatestVersion()); + Assertions.assertTrue(projectsService.findCoordinates("examples.metadata", "test").isPresent()); + Assertions.assertEquals("2.3.1", projectsService.findCoordinates("examples.metadata", "test").get().getLatestVersion()); - Assert.assertTrue(projectsService.find("examples.metadata", "test","latest").isPresent()); - Assert.assertEquals("2.3.1", projectsService.findCoordinates("examples.metadata", "test").get().getLatestVersion()); + Assertions.assertTrue(projectsService.find("examples.metadata", "test","latest").isPresent()); + Assertions.assertEquals("2.3.1", projectsService.findCoordinates("examples.metadata", "test").get().getLatestVersion()); - Assert.assertFalse(projectsService.find("dont","exist","latest").isPresent()); + Assertions.assertFalse(projectsService.find("dont","exist","latest").isPresent()); StoreProjectVersionData noVersions = new StoreProjectVersionData("noversion","examples",BRANCH_SNAPSHOT("master")); projectsService.createOrUpdate(noVersions); - Assert.assertFalse(projectsService.find("noversion","examples", VersionAlias.LATEST.getName()).isPresent()); + Assertions.assertFalse(projectsService.find("noversion","examples", VersionAlias.LATEST.getName()).isPresent()); } @@ -383,8 +383,8 @@ public void canGetLatestVersionForProject() public void canGetVersionsWithExcludedVersionsInStore() { List versions = projectsService.getVersions("examples.metadata", "test"); - Assert.assertEquals(2, versions.size()); - Assert.assertEquals(Arrays.asList("2.2.0", "2.3.1"), versions); + Assertions.assertEquals(2, versions.size()); + Assertions.assertEquals(Arrays.asList("2.2.0", "2.3.1"), versions); } @Test @@ -395,48 +395,48 @@ public void canCheckExistsEvictedVersion() try { projectsService.resolveAliasesAndCheckVersionExists("examples.metadata", "art106", "1.0.0"); - Assert.assertTrue(false); + Assertions.assertTrue(false); } catch (IllegalArgumentException e) { - Assert.assertTrue(true); + Assertions.assertTrue(true); } } @Test public void testGetVersions() { - Assert.assertEquals(2, projectsService.getVersions("examples.metadata","test", false).size()); - Assert.assertEquals(3, projectsService.getVersions("examples.metadata","test", true).size()); + Assertions.assertEquals(2, projectsService.getVersions("examples.metadata","test", false).size()); + Assertions.assertEquals(3, projectsService.getVersions("examples.metadata","test", true).size()); projectsService.excludeProjectVersion("examples.metadata","test",BRANCH_SNAPSHOT("master"),"test"); - Assert.assertEquals(2, projectsService.getVersions("examples.metadata","test", true).size()); + Assertions.assertEquals(2, projectsService.getVersions("examples.metadata","test", true).size()); projectsService.excludeProjectVersion("examples.metadata","test","2.3.1","test"); - Assert.assertEquals(1, projectsService.getVersions("examples.metadata","test", true).size()); + Assertions.assertEquals(1, projectsService.getVersions("examples.metadata","test", true).size()); } @Test public void testCanGetLatestVersionIdUsingAlias() { - Assert.assertEquals("2.3.1", projectsService.resolveAliasesAndCheckVersionExists("examples.metadata","test", "latest")); + Assertions.assertEquals("2.3.1", projectsService.resolveAliasesAndCheckVersionExists("examples.metadata","test", "latest")); } @Test public void testErrorThrownWhenIncorrectAliasIsUsed() { - Assert.assertThrows("project version not found for examples.metadata-test-lastest", IllegalArgumentException.class, () -> projectsService.resolveAliasesAndCheckVersionExists("examples.metadata","test", "lastest")); + Assertions.assertThrows(IllegalArgumentException.class, () -> projectsService.resolveAliasesAndCheckVersionExists("examples.metadata","test", "lastest"), "project version not found for examples.metadata-test-lastest"); } @Test public void testErrorThrownWhenNoProjectVersionFound() { - Assert.assertThrows("project version not found for examples.metadata-test1-1.0.0", IllegalArgumentException.class, () -> projectsService.resolveAliasesAndCheckVersionExists("examples.metadata","test1", "1.0.0")); + Assertions.assertThrows(IllegalArgumentException.class, () -> projectsService.resolveAliasesAndCheckVersionExists("examples.metadata","test1", "1.0.0"), "project version not found for examples.metadata-test1-1.0.0"); } @Test public void testCanGetMasterSnapshotVersionIdUsingAlias() { - Assert.assertEquals(BRANCH_SNAPSHOT("master"), projectsService.resolveAliasesAndCheckVersionExists("examples.metadata","test", "head")); + Assertions.assertEquals(BRANCH_SNAPSHOT("master"), projectsService.resolveAliasesAndCheckVersionExists("examples.metadata","test", "head")); } @Test @@ -447,8 +447,8 @@ public void canGetSnapshotVersions() projectVersionData.getVersionData().setExcluded(true); projectsService.createOrUpdate(projectVersionData); List versionData = projectsService.findSnapshotVersions("examples.metadata", "test"); - Assert.assertEquals(2, versionData.size()); - Assert.assertEquals(Arrays.asList("master-SNAPSHOT", "branch1-SNAPSHOT"), versionData.stream().map(x -> x.getVersionId()).collect(Collectors.toList())); + Assertions.assertEquals(2, versionData.size()); + Assertions.assertEquals(Arrays.asList("master-SNAPSHOT", "branch1-SNAPSHOT"), versionData.stream().map(x -> x.getVersionId()).collect(Collectors.toList())); } @Test @@ -477,8 +477,8 @@ public void canOverrideDependencies() // Cv1 will be overridden by CV2 and incoming dependency D will be part of the list List dependencies = projectsService.getDependencies(Arrays.asList(pv1, pv2), true).stream().collect(Collectors.toList()); - Assert.assertEquals(1, dependencies.size()); - Assert.assertEquals(dependency2, dependencies.get(0)); + Assertions.assertEquals(1, dependencies.size()); + Assertions.assertEquals(dependency2, dependencies.get(0)); } @@ -532,7 +532,7 @@ public void canGenerateReportForOverriddenDependenciesCase1() // Cv1 will be overridden by CV2 and incoming dependency Dv2 will override Dv1 ProjectDependencyReport dependencyReport = projectsService.getProjectDependencyReport(Arrays.asList(pv1, pv2, dependency3)); - Assert.assertEquals(0, dependencyReport.getConflicts().size()); + Assertions.assertEquals(0, dependencyReport.getConflicts().size()); } @Test @@ -583,8 +583,8 @@ public void canGenerateReportForOverriddenDependenciesCase2() // Cv1 will be overridden by CV2 and incoming dependency Dv2 will be part of the list ProjectDependencyReport dependencyReport = projectsService.getProjectDependencyReport(Arrays.asList(pv1, pv2, dependency3)); - Assert.assertEquals(1, dependencyReport.getConflicts().size()); - Assert.assertEquals(Sets.mutable.of("examples.metadata:testd:2.0.0", "examples.metadata:testd:1.0.0"),dependencyReport.getConflicts().get(0).getVersions()); + Assertions.assertEquals(1, dependencyReport.getConflicts().size()); + Assertions.assertEquals(Sets.mutable.of("examples.metadata:testd:2.0.0", "examples.metadata:testd:1.0.0"),dependencyReport.getConflicts().get(0).getVersions()); } } diff --git a/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/CoreDataMongoStoreTests.java b/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/CoreDataMongoStoreTests.java index fcd12b087..61ff9b16f 100644 --- a/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/CoreDataMongoStoreTests.java +++ b/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/CoreDataMongoStoreTests.java @@ -24,7 +24,7 @@ import org.finos.legend.depot.store.model.projects.StoreProjectVersionData; import org.finos.legend.depot.store.mongo.projects.ProjectsMongo; import org.finos.legend.depot.store.mongo.projects.ProjectsVersionsMongo; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import java.io.InputStream; import java.net.URL; @@ -43,12 +43,12 @@ public static List readProjectConfigsFile(URL fileName) List projects = new ObjectMapper().readValue(jsonInput, new TypeReference>() { }); - Assert.assertNotNull("testing file" + fileName.getFile(), projects); + Assertions.assertNotNull(projects, "testing file" + fileName.getFile()); return projects; } catch (Exception e) { - Assert.fail("an error has occurred loading test project metadata" + e.getMessage()); + Assertions.fail("an error has occurred loading test project metadata" + e.getMessage()); } return null; } @@ -63,12 +63,12 @@ public static List readProjectVersionsConfigsFile(URL f List projects = new ObjectMapper().readValue(jsonInput, new TypeReference>() { }); - Assert.assertNotNull("testing file" + fileName.getFile(), projects); + Assertions.assertNotNull(projects, "testing file" + fileName.getFile()); return projects; } catch (Exception e) { - Assert.fail("an error has occurred loading test project metadata" + e.getMessage()); + Assertions.fail("an error has occurred loading test project metadata" + e.getMessage()); } return null; } @@ -90,14 +90,14 @@ protected void setUpProjectsFromFile(URL projectConfigFile) } catch (JsonProcessingException e) { - Assert.fail("an error has occurred loading test project " + e.getMessage()); + Assertions.fail("an error has occurred loading test project " + e.getMessage()); } }); - Assert.assertNotNull(getMongoProjects()); + Assertions.assertNotNull(getMongoProjects()); } catch (Exception e) { - Assert.fail("an error has occurred loading test project metadata" + e.getMessage()); + Assertions.fail("an error has occurred loading test project metadata" + e.getMessage()); } } @@ -113,14 +113,14 @@ protected void setUpProjectsVersionsFromFile(URL projectConfigFile) } catch (JsonProcessingException e) { - Assert.fail("an error has occurred loading test project " + e.getMessage()); + Assertions.fail("an error has occurred loading test project " + e.getMessage()); } }); - Assert.assertNotNull(getMongoProjectVersions()); + Assertions.assertNotNull(getMongoProjectVersions()); } catch (Exception e) { - Assert.fail("an error has occurred loading test project metadata" + e.getMessage()); + Assertions.fail("an error has occurred loading test project metadata" + e.getMessage()); } } diff --git a/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/migrations/TestDependenciesMigration.java b/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/migrations/TestDependenciesMigration.java index 1ed595916..be406c7c1 100644 --- a/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/migrations/TestDependenciesMigration.java +++ b/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/migrations/TestDependenciesMigration.java @@ -25,9 +25,9 @@ import org.finos.legend.depot.store.mongo.CoreDataMongoStoreTests; import org.finos.legend.depot.store.mongo.admin.CoreDataMigrations; import org.finos.legend.depot.store.mongo.projects.ProjectsVersionsMongo; -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 java.io.InputStream; import java.net.URL; @@ -40,11 +40,11 @@ public class TestDependenciesMigration extends CoreDataMongoStoreTests CoreDataMigrations mongoAdminStore = new CoreDataMigrations(mongoProvider); private static final String VERSIONS_COLLECTION = "versionsTemp"; - @Before + @BeforeEach public void setupTestData() { setUpProjectDataFromFile(this.getClass().getClassLoader().getResource("data/projectsVersions1.json")); - Assert.assertEquals(9, mongoProvider.getCollection(ProjectsVersionsMongo.COLLECTION).countDocuments()); + Assertions.assertEquals(9, mongoProvider.getCollection(ProjectsVersionsMongo.COLLECTION).countDocuments()); } protected static List readProjectDataConfigsFile(URL fileName) @@ -54,12 +54,12 @@ protected static List readProjectDataConfigsFile(URL fileName) InputStream stream = fileName.openStream(); String jsonInput = new java.util.Scanner(stream).useDelimiter("\\A").next(); List projects = new ObjectMapper().readValue(jsonInput, new TypeReference>() {}); - Assert.assertNotNull("testing file" + fileName.getFile(), projects); + Assertions.assertNotNull(projects, "testing file" + fileName.getFile()); return projects; } catch (Exception e) { - Assert.fail("an error has occurred loading test project metadata" + e.getMessage()); + Assertions.fail("an error has occurred loading test project metadata" + e.getMessage()); } return null; } @@ -76,13 +76,13 @@ private void setUpProjectDataFromFile(URL projectConfigFile) } catch (JsonProcessingException e) { - Assert.fail("an error has occurred loading test project " + e.getMessage()); + Assertions.fail("an error has occurred loading test project " + e.getMessage()); } }); } catch (Exception e) { - Assert.fail("an error has occurred loading test project metadata" + e.getMessage()); + Assertions.fail("an error has occurred loading test project metadata" + e.getMessage()); } } @@ -92,26 +92,26 @@ public void testStoringTransitiveDependencies() mongoAdminStore.calculateTransitiveDependenciesForAllProjectVersions(); StoreProjectVersionData result = convert(new ObjectMapper(),mongoProvider.getCollection(VERSIONS_COLLECTION).find().first(), StoreProjectVersionData.class); - Assert.assertTrue(result.getTransitiveDependenciesReport().isValid()); - Assert.assertEquals(4, result.getTransitiveDependenciesReport().getTransitiveDependencies().size()); + Assertions.assertTrue(result.getTransitiveDependenciesReport().isValid()); + Assertions.assertEquals(4, result.getTransitiveDependenciesReport().getTransitiveDependencies().size()); ProjectVersion pv1 = new ProjectVersion("examples.metadata", "test-dependencies", "2.0.0"); ProjectVersion pv2 = new ProjectVersion("examples.metadata", "art101", "1.0.0"); ProjectVersion pv3 = new ProjectVersion("examples.metadata", "art102", "1.0.0"); ProjectVersion pv4 = new ProjectVersion("examples.metadata", "art103", "1.0.0"); - Assert.assertEquals(result.getTransitiveDependenciesReport().getTransitiveDependencies(), Arrays.asList(pv1, pv2, pv3, pv4)); + Assertions.assertEquals(result.getTransitiveDependenciesReport().getTransitiveDependencies(), Arrays.asList(pv1, pv2, pv3, pv4)); //check for the excluded Dependency StoreProjectVersionData result1 = convert(new ObjectMapper(), mongoProvider.getCollection(VERSIONS_COLLECTION).find(Filters.and(Filters.eq("groupId", "examples.metadata"), Filters.eq("artifactId", "art104"))).first(), StoreProjectVersionData.class); - Assert.assertFalse(result1.getTransitiveDependenciesReport().isValid()); + Assertions.assertFalse(result1.getTransitiveDependenciesReport().isValid()); //check for other dependencies StoreProjectVersionData result2 = convert(new ObjectMapper(), mongoProvider.getCollection(VERSIONS_COLLECTION).find(Filters.and(Filters.eq("groupId", "examples.metadata"), Filters.eq("artifactId", "test-dependencies"))).first(), StoreProjectVersionData.class); - Assert.assertTrue(result2.getTransitiveDependenciesReport().isValid()); - Assert.assertEquals(result2.getTransitiveDependenciesReport().getTransitiveDependencies(), Arrays.asList(pv2, pv3, pv4)); + Assertions.assertTrue(result2.getTransitiveDependenciesReport().isValid()); + Assertions.assertEquals(result2.getTransitiveDependenciesReport().getTransitiveDependencies(), Arrays.asList(pv2, pv3, pv4)); //check for dependency not present in store StoreProjectVersionData result3 = convert(new ObjectMapper(), mongoProvider.getCollection(VERSIONS_COLLECTION).find(Filters.and(Filters.eq("groupId", "examples.metadata"), Filters.eq("artifactId", "art108"))).first(), StoreProjectVersionData.class); - Assert.assertFalse(result3.getTransitiveDependenciesReport().isValid()); + Assertions.assertFalse(result3.getTransitiveDependenciesReport().isValid()); } @Test @@ -120,25 +120,25 @@ public void testUpdatingVersionsCollection() mongoAdminStore.calculateTransitiveDependenciesForAllProjectVersions(); mongoAdminStore.addTransitiveDependenciesToVersionData(); StoreProjectVersionData result = convert(new ObjectMapper(),mongoProvider.getCollection(ProjectsVersionsMongo.COLLECTION).find().first(), StoreProjectVersionData.class); - Assert.assertTrue(result.getTransitiveDependenciesReport().isValid()); - Assert.assertEquals(4, result.getTransitiveDependenciesReport().getTransitiveDependencies().size()); + Assertions.assertTrue(result.getTransitiveDependenciesReport().isValid()); + Assertions.assertEquals(4, result.getTransitiveDependenciesReport().getTransitiveDependencies().size()); ProjectVersion pv1 = new ProjectVersion("examples.metadata", "test-dependencies", "2.0.0"); ProjectVersion pv2 = new ProjectVersion("examples.metadata", "art101", "1.0.0"); ProjectVersion pv3 = new ProjectVersion("examples.metadata", "art102", "1.0.0"); ProjectVersion pv4 = new ProjectVersion("examples.metadata", "art103", "1.0.0"); - Assert.assertEquals(result.getTransitiveDependenciesReport().getTransitiveDependencies(), Arrays.asList(pv1, pv2, pv3, pv4)); + Assertions.assertEquals(result.getTransitiveDependenciesReport().getTransitiveDependencies(), Arrays.asList(pv1, pv2, pv3, pv4)); //check for the excluded Dependency StoreProjectVersionData result1 = convert(new ObjectMapper(), mongoProvider.getCollection(ProjectsVersionsMongo.COLLECTION).find(Filters.and(Filters.eq("groupId", "examples.metadata"), Filters.eq("artifactId", "art104"))).first(), StoreProjectVersionData.class); - Assert.assertFalse(result1.getTransitiveDependenciesReport().isValid()); + Assertions.assertFalse(result1.getTransitiveDependenciesReport().isValid()); //check for other dependencies StoreProjectVersionData result2 = convert(new ObjectMapper(), mongoProvider.getCollection(ProjectsVersionsMongo.COLLECTION).find(Filters.and(Filters.eq("groupId", "examples.metadata"), Filters.eq("artifactId", "test-dependencies"))).first(), StoreProjectVersionData.class); - Assert.assertTrue(result2.getTransitiveDependenciesReport().isValid()); - Assert.assertEquals(result2.getTransitiveDependenciesReport().getTransitiveDependencies(), Arrays.asList(pv2, pv3, pv4)); + Assertions.assertTrue(result2.getTransitiveDependenciesReport().isValid()); + Assertions.assertEquals(result2.getTransitiveDependenciesReport().getTransitiveDependencies(), Arrays.asList(pv2, pv3, pv4)); //check for dependency not present in store StoreProjectVersionData result3 = convert(new ObjectMapper(), mongoProvider.getCollection(ProjectsVersionsMongo.COLLECTION).find(Filters.and(Filters.eq("groupId", "examples.metadata"), Filters.eq("artifactId", "art108"))).first(), StoreProjectVersionData.class); - Assert.assertFalse(result3.getTransitiveDependenciesReport().isValid()); + Assertions.assertFalse(result3.getTransitiveDependenciesReport().isValid()); } } diff --git a/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/migrations/TestProjectVersionMigrations.java b/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/migrations/TestProjectVersionMigrations.java index 8a8b17918..3e3dee78e 100644 --- a/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/migrations/TestProjectVersionMigrations.java +++ b/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/migrations/TestProjectVersionMigrations.java @@ -24,9 +24,9 @@ import org.finos.legend.depot.store.mongo.CoreDataMongoStoreTests; import org.finos.legend.depot.store.mongo.admin.CoreDataMigrations; import org.finos.legend.depot.store.mongo.core.BaseMongo; -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 java.io.InputStream; import java.net.URL; @@ -42,11 +42,11 @@ public class TestProjectVersionMigrations extends CoreDataMongoStoreTests { CoreDataMigrations mongoAdminStore = new CoreDataMigrations(mongoProvider); - @Before + @BeforeEach public void setupTestData() { setUpProjectDataFromFile(this.getClass().getClassLoader().getResource("data/projectVersionMigration/projectsData.json")); - Assert.assertEquals(3,mongoProvider.getCollection("project-configurations").countDocuments()); + Assertions.assertEquals(3,mongoProvider.getCollection("project-configurations").countDocuments()); } protected static List readProjectDataConfigsFile(URL fileName) @@ -56,12 +56,12 @@ protected static List readProjectDataConfigsFile(URL fileName) InputStream stream = fileName.openStream(); String jsonInput = new java.util.Scanner(stream).useDelimiter("\\A").next(); List projects = new ObjectMapper().readValue(jsonInput, new TypeReference>() {}); - Assert.assertNotNull("testing file" + fileName.getFile(), projects); + Assertions.assertNotNull(projects, "testing file" + fileName.getFile()); return projects; } catch (Exception e) { - Assert.fail("an error has occurred loading test project metadata" + e.getMessage()); + Assertions.fail("an error has occurred loading test project metadata" + e.getMessage()); } return null; } @@ -70,7 +70,7 @@ private void setUpProjectDataFromFile(URL projectConfigFile) { try { - Assert.assertNotNull(getMongoProjects()); + Assertions.assertNotNull(getMongoProjects()); readProjectDataConfigsFile(projectConfigFile).forEach(project -> { try @@ -79,13 +79,13 @@ private void setUpProjectDataFromFile(URL projectConfigFile) } catch (JsonProcessingException e) { - Assert.fail("an error has occurred loading test project " + e.getMessage()); + Assertions.fail("an error has occurred loading test project " + e.getMessage()); } }); } catch (Exception e) { - Assert.fail("an error has occurred loading test project metadata" + e.getMessage()); + Assertions.fail("an error has occurred loading test project metadata" + e.getMessage()); } } @@ -93,13 +93,13 @@ private void setUpProjectDataFromFile(URL projectConfigFile) public void testProjectToProjectVersionMigration() { - Assert.assertEquals(0,mongoProvider.getCollection("versions").countDocuments()); + Assertions.assertEquals(0,mongoProvider.getCollection("versions").countDocuments()); mongoAdminStore.migrationToProjectVersions(); - Assert.assertEquals(7,mongoProvider.getCollection("versions").countDocuments()); + Assertions.assertEquals(7,mongoProvider.getCollection("versions").countDocuments()); StoreProjectVersionData result = convert(new ObjectMapper(),mongoProvider.getCollection("versions").find().first(), StoreProjectVersionData.class); - Assert.assertEquals(result.getGroupId(), "examples.metadata"); - Assert.assertEquals(result.getArtifactId(), "test"); - Assert.assertEquals(result.getVersionId(), BRANCH_SNAPSHOT("master")); + Assertions.assertEquals(result.getGroupId(), "examples.metadata"); + Assertions.assertEquals(result.getArtifactId(), "test"); + Assertions.assertEquals(result.getVersionId(), BRANCH_SNAPSHOT("master")); } @Test @@ -107,29 +107,29 @@ public void testProjectDataCleanUp() { mongoAdminStore.cleanUpProjectData(); - Assert.assertEquals(3,mongoProvider.getCollection("project-configurations").countDocuments()); + Assertions.assertEquals(3,mongoProvider.getCollection("project-configurations").countDocuments()); StoreProjectData result = convert(new ObjectMapper(),mongoProvider.getCollection("project-configurations").find().first(), StoreProjectData.class); - Assert.assertEquals(1,1); - Assert.assertEquals(result.getProjectId(), "PROD-A"); - Assert.assertEquals(result.getGroupId(), "examples.metadata"); - Assert.assertEquals(result.getArtifactId(), "test"); + Assertions.assertEquals(1,1); + Assertions.assertEquals(result.getProjectId(), "PROD-A"); + Assertions.assertEquals(result.getGroupId(), "examples.metadata"); + Assertions.assertEquals(result.getArtifactId(), "test"); } @Test public void testProjectUpdatesWithLatestVersion() { - Assert.assertEquals(0,mongoProvider.getCollection("versions").countDocuments()); + Assertions.assertEquals(0,mongoProvider.getCollection("versions").countDocuments()); mongoAdminStore.migrationToProjectVersions(); - Assert.assertEquals(7,mongoProvider.getCollection("versions").countDocuments()); + Assertions.assertEquals(7,mongoProvider.getCollection("versions").countDocuments()); mongoAdminStore.cleanUpProjectData(); - Assert.assertEquals(3,mongoProvider.getCollection("project-configurations").countDocuments()); + Assertions.assertEquals(3,mongoProvider.getCollection("project-configurations").countDocuments()); mongoAdminStore.addLatestVersionToProjectData(); - Assert.assertEquals(3,mongoProvider.getCollection("project-configurations").countDocuments()); + Assertions.assertEquals(3,mongoProvider.getCollection("project-configurations").countDocuments()); List result = new ArrayList<>(); mongoProvider.getCollection("project-configurations").find().forEach((Consumer) doc -> result.add(convert(new ObjectMapper(), doc, StoreProjectData.class))); - Assert.assertEquals(result.get(0).getLatestVersion(), "2.3.1"); - Assert.assertEquals(result.get(1).getLatestVersion(), "1.0.0"); - Assert.assertEquals(result.get(2).getLatestVersion(), "2.0.1"); + Assertions.assertEquals(result.get(0).getLatestVersion(), "2.3.1"); + Assertions.assertEquals(result.get(1).getLatestVersion(), "1.0.0"); + Assertions.assertEquals(result.get(2).getLatestVersion(), "2.0.1"); } @Test @@ -142,6 +142,6 @@ public void testProjectUpdatesForLatestWithNoVersion() mongoAdminStore.addLatestVersionToProjectData(); StoreProjectData result = convert(new ObjectMapper(),mongoProvider.getCollection("project-configurations").find().first(), StoreProjectData.class); - Assert.assertNull(result.getLatestVersion()); + Assertions.assertNull(result.getLatestVersion()); } } diff --git a/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/projects/TestQueryProjectApi.java b/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/projects/TestQueryProjectApi.java index 7d68fb128..7479354ba 100644 --- a/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/projects/TestQueryProjectApi.java +++ b/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/projects/TestQueryProjectApi.java @@ -18,9 +18,9 @@ import org.finos.legend.depot.store.model.projects.StoreProjectData; import org.finos.legend.depot.store.api.projects.Projects; import org.finos.legend.depot.store.mongo.CoreDataMongoStoreTests; -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 java.util.List; import java.util.Optional; @@ -30,7 +30,7 @@ public class TestQueryProjectApi extends CoreDataMongoStoreTests { private Projects projectsAPI = new ProjectsMongo(mongoProvider); - @Before + @BeforeEach public void setUpProjectData() { setUpProjectsFromFile(this.getClass().getClassLoader().getResource("data/projects.json")); @@ -40,15 +40,15 @@ public void setUpProjectData() public void canCollectAllProjectConfig() { List allConfigs = projectsAPI.getAll(); - Assert.assertNotNull(allConfigs); - Assert.assertEquals(3, allConfigs.size()); + Assertions.assertNotNull(allConfigs); + Assertions.assertEquals(3, allConfigs.size()); } @Test public void canFindByMavenCoordinates() { Optional projectConfig = projectsAPI.find("examples.metadata", "test"); - Assert.assertTrue(projectConfig.isPresent()); + Assertions.assertTrue(projectConfig.isPresent()); } @@ -56,10 +56,10 @@ public void canFindByMavenCoordinates() public void canFindByProjectId() { List projectConfig = projectsAPI.findByProjectId("PROD-A"); - Assert.assertTrue(!projectConfig.isEmpty()); - Assert.assertEquals(projectConfig.size(), 1); - Assert.assertEquals(projectConfig.get(0).getGroupId(), "examples.metadata"); - Assert.assertEquals(projectConfig.get(0).getArtifactId(), "test"); + Assertions.assertTrue(!projectConfig.isEmpty()); + Assertions.assertEquals(projectConfig.size(), 1); + Assertions.assertEquals(projectConfig.get(0).getGroupId(), "examples.metadata"); + Assertions.assertEquals(projectConfig.get(0).getArtifactId(), "test"); } @@ -67,7 +67,7 @@ public void canFindByProjectId() public void cannotFindProject() { Optional project = projectsAPI.find("PROD-9691231123", "lalal"); - Assert.assertFalse(project.isPresent()); + Assertions.assertFalse(project.isPresent()); } diff --git a/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/projects/TestQueryProjectVersionApi.java b/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/projects/TestQueryProjectVersionApi.java index 6ef617983..79aa820cc 100644 --- a/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/projects/TestQueryProjectVersionApi.java +++ b/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/projects/TestQueryProjectVersionApi.java @@ -18,9 +18,9 @@ import org.finos.legend.depot.store.model.projects.StoreProjectVersionData; import org.finos.legend.depot.store.api.projects.ProjectsVersions; import org.finos.legend.depot.store.mongo.CoreDataMongoStoreTests; -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 java.time.LocalDateTime; import java.util.List; @@ -33,7 +33,7 @@ public class TestQueryProjectVersionApi extends CoreDataMongoStoreTests { private ProjectsVersions projectsVersionsAPI = new ProjectsVersionsMongo(mongoProvider); - @Before + @BeforeEach public void setUpProjectData() { setUpProjectsVersionsFromFile(this.getClass().getClassLoader().getResource("data/projectsVersions.json")); @@ -43,8 +43,8 @@ public void setUpProjectData() public void canCollectAllProjectConfig() { List allConfigs = projectsVersionsAPI.getAll(); - Assert.assertNotNull(allConfigs); - Assert.assertEquals(6, allConfigs.size()); + Assertions.assertNotNull(allConfigs); + Assertions.assertEquals(6, allConfigs.size()); } @Test @@ -52,51 +52,51 @@ public void canCollectAllProjectConfigUpdatedFrom() { List allConfigs = projectsVersionsAPI.findByUpdatedDate(1687227600000L, toTime(LocalDateTime.now())); - Assert.assertNotNull(allConfigs); - Assert.assertEquals(3, allConfigs.size()); + Assertions.assertNotNull(allConfigs); + Assertions.assertEquals(3, allConfigs.size()); } @Test public void canCollectAllProjectConfigUpdatedFromTo() { List allConfigs = projectsVersionsAPI.findByUpdatedDate(1687219200000L, 1687219210000L); - Assert.assertNotNull(allConfigs); - Assert.assertEquals(1, allConfigs.size()); + Assertions.assertNotNull(allConfigs); + Assertions.assertEquals(1, allConfigs.size()); } @Test public void testFindingByProjectVersionCoordinates() { Optional projectConfig = projectsVersionsAPI.find("examples.metadata", "test", "2.2.0"); - Assert.assertTrue(projectConfig.isPresent()); + Assertions.assertTrue(projectConfig.isPresent()); projectConfig = projectsVersionsAPI.find("examples.metadata", "test", "1.0.0"); - Assert.assertFalse(projectConfig.isPresent()); + Assertions.assertFalse(projectConfig.isPresent()); } @Test public void canFindProjectByMavenCoordinates() { List project = projectsVersionsAPI.find("examples.metadata", "test"); - Assert.assertFalse(project.isEmpty()); - Assert.assertEquals(4, project.size()); + Assertions.assertFalse(project.isEmpty()); + Assertions.assertEquals(4, project.size()); } @Test public void cannotFindProject() { List project = projectsVersionsAPI.find("PROD-9691231123", "lalal"); - Assert.assertTrue(project.isEmpty()); + Assertions.assertTrue(project.isEmpty()); } @Test public void canGetProjectVersionIfExcluded() { List storeProjectVersionData = projectsVersionsAPI.findVersion(true); - Assert.assertFalse(storeProjectVersionData.isEmpty()); - Assert.assertEquals(1, storeProjectVersionData.size()); - Assert.assertEquals("examples.metadata", storeProjectVersionData.get(0).getGroupId()); - Assert.assertEquals("test", storeProjectVersionData.get(0).getArtifactId()); - Assert.assertEquals("3.0.0", storeProjectVersionData.get(0).getVersionId()); + Assertions.assertFalse(storeProjectVersionData.isEmpty()); + Assertions.assertEquals(1, storeProjectVersionData.size()); + Assertions.assertEquals("examples.metadata", storeProjectVersionData.get(0).getGroupId()); + Assertions.assertEquals("test", storeProjectVersionData.get(0).getArtifactId()); + Assertions.assertEquals("3.0.0", storeProjectVersionData.get(0).getVersionId()); } } diff --git a/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/projects/TestUpdateProjectApi.java b/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/projects/TestUpdateProjectApi.java index 987cd4d6c..60bf1b48b 100644 --- a/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/projects/TestUpdateProjectApi.java +++ b/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/projects/TestUpdateProjectApi.java @@ -17,9 +17,9 @@ import org.finos.legend.depot.store.model.projects.StoreProjectData; import org.finos.legend.depot.store.mongo.CoreDataMongoStoreTests; -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 java.util.List; import java.util.Optional; @@ -31,7 +31,7 @@ public class TestUpdateProjectApi extends CoreDataMongoStoreTests public static final String TEST_GROUP_ID = "some.examples"; private ProjectsMongo projectsAPI = new ProjectsMongo(mongoProvider); - @Before + @BeforeEach public void setUpTestData() { setUpProjectsFromFile(this.getClass().getClassLoader().getResource("data/projects.json")); @@ -46,85 +46,85 @@ public void canCreateAnewProjectConfiguration() projectsAPI.createOrUpdate(projectConfiguration); Optional newConfig = projectsAPI.find("some.examples", "test121"); - Assert.assertNotNull(newConfig); - Assert.assertTrue(newConfig.isPresent()); - Assert.assertEquals("PROD-121", newConfig.get().getProjectId()); - Assert.assertEquals("some.examples", newConfig.get().getGroupId()); - Assert.assertEquals("test121", newConfig.get().getArtifactId()); + Assertions.assertNotNull(newConfig); + Assertions.assertTrue(newConfig.isPresent()); + Assertions.assertEquals("PROD-121", newConfig.get().getProjectId()); + Assertions.assertEquals("some.examples", newConfig.get().getGroupId()); + Assertions.assertEquals("test121", newConfig.get().getArtifactId()); } - @Test(expected = IllegalArgumentException.class) + @Test public void cantCreateAnewProjectWithBadConfiguration() { StoreProjectData projectConfiguration = new StoreProjectData("PROD-121", "example.bad this is bad", "test121"); - projectsAPI.createOrUpdate(projectConfiguration); + Assertions.assertThrows(IllegalArgumentException.class, () -> projectsAPI.createOrUpdate(projectConfiguration)); } @Test public void canCreateUpdateProjectsWithSameCoordinates() { - Assert.assertEquals(3, projectsAPI.getAll().size()); + Assertions.assertEquals(3, projectsAPI.getAll().size()); StoreProjectData projectConfiguration = new StoreProjectData("PROD-123", TEST_GROUP_ID, "test121"); projectsAPI.createOrUpdate(projectConfiguration); - Assert.assertEquals(4, projectsAPI.getAll().size()); + Assertions.assertEquals(4, projectsAPI.getAll().size()); StoreProjectData projectConfiguration2 = new StoreProjectData("PROD-124", TEST_GROUP_ID, "test121"); try { projectsAPI.createOrUpdate(projectConfiguration2); - Assert.fail("cant create duplicate coordinates"); + Assertions.fail("cant create duplicate coordinates"); } catch (Exception e) { - Assert.assertTrue(e.getMessage().contains("Duplicate")); + Assertions.assertTrue(e.getMessage().contains("Duplicate")); } StoreProjectData newData = projectsAPI.createOrUpdate(new StoreProjectData("PROD-124", TEST_GROUP_ID, "test122")); - Assert.assertEquals("test122", newData.getArtifactId()); + Assertions.assertEquals("test122", newData.getArtifactId()); newData.setArtifactId("test121"); try { projectsAPI.createOrUpdate(newData); - Assert.fail("cant create duplicate coordinates"); + Assertions.fail("cant create duplicate coordinates"); } catch (Exception e) { - Assert.assertTrue(e.getMessage().contains("Duplicate")); + Assertions.assertTrue(e.getMessage().contains("Duplicate")); } } @Test public void coordinatesAreCaseSensitive() { - Assert.assertEquals(3, projectsAPI.getAll().size()); + Assertions.assertEquals(3, projectsAPI.getAll().size()); StoreProjectData projectConfiguration = new StoreProjectData("PROD-123", "some.examples", "test121"); projectsAPI.createOrUpdate(projectConfiguration); - Assert.assertEquals(4, projectsAPI.getAll().size()); + Assertions.assertEquals(4, projectsAPI.getAll().size()); StoreProjectData projectConfiguration2 = new StoreProjectData("PROD-124", "some.Examples", "test121"); try { - Assert.assertNotNull(projectsAPI.createOrUpdate(projectConfiguration2)); - Assert.assertEquals(5, projectsAPI.getAll().size()); + Assertions.assertNotNull(projectsAPI.createOrUpdate(projectConfiguration2)); + Assertions.assertEquals(5, projectsAPI.getAll().size()); } catch (Exception e) { - Assert.fail("not duplicate coordinates, different in case"); + Assertions.fail("not duplicate coordinates, different in case"); } try { projectsAPI.createOrUpdate(new StoreProjectData("PROD-124", "some.examples", "test121")); - Assert.fail("cant create duplicate coordinates"); + Assertions.fail("cant create duplicate coordinates"); } catch (Exception e) { - Assert.assertTrue(e.getMessage().contains("Duplicate")); + Assertions.assertTrue(e.getMessage().contains("Duplicate")); } } @@ -132,11 +132,11 @@ public void coordinatesAreCaseSensitive() public void onlyInsertIfAbsent() { - Assert.assertEquals(3, projectsAPI.getAll().size()); + Assertions.assertEquals(3, projectsAPI.getAll().size()); StoreProjectData projectConfiguration = new StoreProjectData("PROD-123", TEST_GROUP_ID, "test121"); projectsAPI.createOrUpdate(projectConfiguration); - Assert.assertEquals(4, projectsAPI.getAll().size()); + Assertions.assertEquals(4, projectsAPI.getAll().size()); StoreProjectData projectConfiguration2 = new StoreProjectData("PROD-123", TEST_GROUP_ID, "test121"); try @@ -145,11 +145,11 @@ public void onlyInsertIfAbsent() } catch (Exception e) { - Assert.assertTrue(e.getMessage().contains("Duplicate")); + Assertions.assertTrue(e.getMessage().contains("Duplicate")); } List newConfig = projectsAPI.getAll(); - Assert.assertNotNull(newConfig); - Assert.assertEquals(4, newConfig.size()); + Assertions.assertNotNull(newConfig); + Assertions.assertEquals(4, newConfig.size()); } @@ -157,27 +157,27 @@ public void onlyInsertIfAbsent() public void canInsertIfAbsent() { - Assert.assertEquals(3, projectsAPI.getAll().size()); + Assertions.assertEquals(3, projectsAPI.getAll().size()); StoreProjectData projectConfiguration = new StoreProjectData("PROD-123", TEST_GROUP_ID, "test121"); projectsAPI.createOrUpdate(projectConfiguration); - Assert.assertEquals(4, projectsAPI.getAll().size()); + Assertions.assertEquals(4, projectsAPI.getAll().size()); StoreProjectData projectConfiguration2 = new StoreProjectData("PROD-21111", TEST_GROUP_ID, "test121"); try { projectsAPI.createOrUpdate(projectConfiguration2); - Assert.fail("duplicate coordinates"); + Assertions.fail("duplicate coordinates"); } catch (Exception e) { - Assert.assertTrue(e.getMessage().contains("Duplicate")); + Assertions.assertTrue(e.getMessage().contains("Duplicate")); } StoreProjectData projectConfiguration3 = new StoreProjectData("PROD-21111", TEST_GROUP_ID, "test12111"); StoreProjectData res1 = projectsAPI.createOrUpdate(projectConfiguration3); - Assert.assertNotNull(res1); - Assert.assertEquals(5, projectsAPI.getAll().size()); + Assertions.assertNotNull(res1); + Assertions.assertEquals(5, projectsAPI.getAll().size()); } } diff --git a/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/projects/TestUpdateProjectVersionApi.java b/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/projects/TestUpdateProjectVersionApi.java index 05d8bb67b..302f292ff 100644 --- a/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/projects/TestUpdateProjectVersionApi.java +++ b/legend-depot-core-data-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/projects/TestUpdateProjectVersionApi.java @@ -18,9 +18,9 @@ import org.finos.legend.depot.domain.project.ProjectVersion; import org.finos.legend.depot.store.model.projects.StoreProjectVersionData; import org.finos.legend.depot.store.mongo.CoreDataMongoStoreTests; -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 java.util.Collections; import java.util.List; @@ -31,7 +31,7 @@ public class TestUpdateProjectVersionApi extends CoreDataMongoStoreTests { private ProjectsVersionsMongo projectsVersionsAPI = new ProjectsVersionsMongo(mongoProvider); - @Before + @BeforeEach public void setUpTestData() { setUpProjectsVersionsFromFile(this.getClass().getClassLoader().getResource("data/projectsVersions.json")); @@ -46,19 +46,19 @@ public void canCreateAnewProjectConfiguration() projectsVersionsAPI.createOrUpdate(projectConfiguration); Optional newConfig = projectsVersionsAPI.find("some.examples", "test121","2.0.0"); - Assert.assertNotNull(newConfig); - Assert.assertTrue(newConfig.isPresent()); - Assert.assertEquals("some.examples", newConfig.get().getGroupId()); - Assert.assertEquals("test121", newConfig.get().getArtifactId()); - Assert.assertEquals("2.0.0", newConfig.get().getVersionId()); + Assertions.assertNotNull(newConfig); + Assertions.assertTrue(newConfig.isPresent()); + Assertions.assertEquals("some.examples", newConfig.get().getGroupId()); + Assertions.assertEquals("test121", newConfig.get().getArtifactId()); + Assertions.assertEquals("2.0.0", newConfig.get().getVersionId()); } - @Test(expected = IllegalArgumentException.class) + @Test public void cantCreateAnewProjectWithBadConfiguration() { StoreProjectVersionData projectConfiguration = new StoreProjectVersionData("example.bad this is bad", "test121","4.0.0"); - projectsVersionsAPI.createOrUpdate(projectConfiguration); + Assertions.assertThrows(IllegalArgumentException.class, () -> projectsVersionsAPI.createOrUpdate(projectConfiguration)); } @Test @@ -66,16 +66,16 @@ public void canUpdateProjectVersion() { List project = projectsVersionsAPI.find("examples.metadata","test"); - Assert.assertFalse(project.isEmpty()); - Assert.assertEquals(4, project.size()); + Assertions.assertFalse(project.isEmpty()); + Assertions.assertEquals(4, project.size()); Optional updatedProject = projectsVersionsAPI.find("examples.metadata","test", "2.2.0"); - Assert.assertTrue(updatedProject.isPresent()); - Assert.assertEquals(updatedProject.get().getVersionData().getDependencies().size(),0); + Assertions.assertTrue(updatedProject.isPresent()); + Assertions.assertEquals(updatedProject.get().getVersionData().getDependencies().size(),0); updatedProject.get().getVersionData().setDependencies(Collections.singletonList(new ProjectVersion("examples.metadata","test-dependencies","1.0.0"))); projectsVersionsAPI.createOrUpdate(updatedProject.get()); updatedProject = projectsVersionsAPI.find("examples.metadata","test", "2.2.0"); - Assert.assertTrue(updatedProject.isPresent()); - Assert.assertEquals(updatedProject.get().getVersionData().getDependencies().size(),1); + Assertions.assertTrue(updatedProject.isPresent()); + Assertions.assertEquals(updatedProject.get().getVersionData().getDependencies().size(),1); } } diff --git a/legend-depot-core-schedules/src/test/java/org/finos/legend/depot/services/schedules/TestSchedules.java b/legend-depot-core-schedules/src/test/java/org/finos/legend/depot/services/schedules/TestSchedules.java index 24fbcdf6c..3d8b1fea8 100644 --- a/legend-depot-core-schedules/src/test/java/org/finos/legend/depot/services/schedules/TestSchedules.java +++ b/legend-depot-core-schedules/src/test/java/org/finos/legend/depot/services/schedules/TestSchedules.java @@ -16,10 +16,10 @@ package org.finos.legend.depot.services.schedules; import org.finos.legend.depot.store.model.admin.schedules.ScheduleInstance; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.LocalDateTime; @@ -29,14 +29,14 @@ public class TestSchedules { private SchedulesFactoryImpl schedulesFactory; - @Before + @BeforeEach public void setUp() { schedulesFactory = new SchedulesFactoryImpl(new MockScheduleStore(), new MockInstancesStore(),false); - Assert.assertTrue(schedulesFactory.tasksRegistry.isEmpty()); + Assertions.assertTrue(schedulesFactory.tasksRegistry.isEmpty()); } - @After + @AfterEach public void tearDown() { schedulesFactory.deRegisterAll(); @@ -49,12 +49,12 @@ public void testDisabledAllToggle() schedulesFactory.register("job3", 600000, 100000, () -> "hello toggles"); schedulesFactory.register("job4", 600000, 100000, () -> "hello toggles again"); schedulesFactory.toggleDisableAll(false); - Assert.assertTrue(schedulesFactory.schedulesStore.getAll().stream().allMatch(j -> !j.disabled)); + Assertions.assertTrue(schedulesFactory.schedulesStore.getAll().stream().allMatch(j -> !j.disabled)); schedulesFactory.toggleDisableAll(true); - Assert.assertTrue(schedulesFactory.schedulesStore.getAll().stream().allMatch(j -> j.disabled)); + Assertions.assertTrue(schedulesFactory.schedulesStore.getAll().stream().allMatch(j -> j.disabled)); schedulesFactory.run("job3"); - Assert.assertTrue(schedulesFactory.instancesStore.getAll().isEmpty()); + Assertions.assertTrue(schedulesFactory.instancesStore.getAll().isEmpty()); } @Test @@ -62,10 +62,10 @@ public void testDeregister() { schedulesFactory.register("job33", 600000, 100000, () -> "hello toggles"); schedulesFactory.register("job34", 600000, 100000, () -> "hello toggles again"); - Assert.assertEquals(2,schedulesFactory.schedulesStore.getAll().size()); + Assertions.assertEquals(2,schedulesFactory.schedulesStore.getAll().size()); schedulesFactory.deRegister("job33"); - Assert.assertEquals(1,schedulesFactory.schedulesStore.getAll().size()); - Assert.assertFalse(schedulesFactory.tasksRegistry.contains("job33")); + Assertions.assertEquals(1,schedulesFactory.schedulesStore.getAll().size()); + Assertions.assertFalse(schedulesFactory.tasksRegistry.contains("job33")); } @@ -80,7 +80,7 @@ public void deleteExpired() schedulesFactory.deleteExpired(); - Assert.assertTrue(schedulesFactory.instancesStore.getAll().stream().noneMatch(i -> i.getSchedule().equals("expired"))); + Assertions.assertTrue(schedulesFactory.instancesStore.getAll().stream().noneMatch(i -> i.getSchedule().equals("expired"))); } @Test @@ -88,25 +88,25 @@ public void canExecute() { schedulesFactory.register("multiInstance",10000000L,100000000L, () -> "happy run"); schedulesFactory.registerSingleInstance("singleInstance",10000000L,100000000L, () -> "single run"); - Assert.assertEquals(2, schedulesFactory.schedulesStore.getAll().size()); + Assertions.assertEquals(2, schedulesFactory.schedulesStore.getAll().size()); schedulesFactory.run("multiInstance"); schedulesFactory.run("multiInstance"); schedulesFactory.run("multiInstance"); - Assert.assertEquals(3,schedulesFactory.instancesStore.getAll().size()); + Assertions.assertEquals(3,schedulesFactory.instancesStore.getAll().size()); schedulesFactory.run("singleInstance"); schedulesFactory.run("singleInstance"); - Assert.assertEquals(4,schedulesFactory.instancesStore.getAll().size()); + Assertions.assertEquals(4,schedulesFactory.instancesStore.getAll().size()); - Assert.assertEquals(1,schedulesFactory.instancesStore.find("singleInstance").size()); + Assertions.assertEquals(1,schedulesFactory.instancesStore.find("singleInstance").size()); schedulesFactory.instancesStore.find("singleInstance").get(0).setExpires(toDate(LocalDateTime.now().minusMinutes(10))); schedulesFactory.run("singleInstance"); - Assert.assertEquals(5,schedulesFactory.instancesStore.getAll().size()); + Assertions.assertEquals(5,schedulesFactory.instancesStore.getAll().size()); } } diff --git a/legend-depot-core-tracing/src/test/java/org/finos/legend/depot/core/services/metrics/TestPrometheusHandler.java b/legend-depot-core-tracing/src/test/java/org/finos/legend/depot/core/services/metrics/TestPrometheusHandler.java index 50b9045e4..c37794e2d 100644 --- a/legend-depot-core-tracing/src/test/java/org/finos/legend/depot/core/services/metrics/TestPrometheusHandler.java +++ b/legend-depot-core-tracing/src/test/java/org/finos/legend/depot/core/services/metrics/TestPrometheusHandler.java @@ -18,15 +18,15 @@ import io.prometheus.client.CollectorRegistry; import org.finos.legend.depot.core.services.api.metrics.configuration.PrometheusConfiguration; -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; public class TestPrometheusHandler { DepotPrometheusMetricsHandler prometheusMetrics = (DepotPrometheusMetricsHandler) PrometheusMetricsFactory.configure(new PrometheusConfiguration(true,new DepotPrometheusMetricsHandler("test"))); - @Before + @BeforeEach public void setUp() { CollectorRegistry.defaultRegistry.clear(); @@ -35,26 +35,26 @@ public void setUp() @Test public void canConfigureHandler() { - Assert.assertNotNull(PrometheusMetricsFactory.getInstance()); + Assertions.assertNotNull(PrometheusMetricsFactory.getInstance()); } @Test public void canCreateCounterAndIncrement() { prometheusMetrics.registerCounter("test1","help"); - Assert.assertEquals(1, prometheusMetrics.allCounters.size()); - Assert.assertEquals(1, prometheusMetrics.allErrorCounters.size()); + Assertions.assertEquals(1, prometheusMetrics.allCounters.size()); + Assertions.assertEquals(1, prometheusMetrics.allErrorCounters.size()); - Assert.assertEquals(0.0D, prometheusMetrics.allCounters.get("test_test1").get(),0.0D); - Assert.assertEquals(0.0D, prometheusMetrics.allErrorCounters.get("test_test1_errors").get(),0.0); + Assertions.assertEquals(0.0D, prometheusMetrics.allCounters.get("test_test1").get(),0.0D); + Assertions.assertEquals(0.0D, prometheusMetrics.allErrorCounters.get("test_test1_errors").get(),0.0); prometheusMetrics.incrementCount("test1"); - Assert.assertEquals(1.0D, prometheusMetrics.allCounters.get("test_test1").get(),0.0); - Assert.assertEquals(0.0D, prometheusMetrics.allErrorCounters.get("test_test1_errors").get(),0.0); + Assertions.assertEquals(1.0D, prometheusMetrics.allCounters.get("test_test1").get(),0.0); + Assertions.assertEquals(0.0D, prometheusMetrics.allErrorCounters.get("test_test1_errors").get(),0.0); prometheusMetrics.incrementErrorCount("test1"); - Assert.assertEquals(1.0D, prometheusMetrics.allCounters.get("test_test1").get(),0.0); - Assert.assertEquals(1.0D, prometheusMetrics.allErrorCounters.get("test_test1_errors").get(),0.0); + Assertions.assertEquals(1.0D, prometheusMetrics.allCounters.get("test_test1").get(),0.0); + Assertions.assertEquals(1.0D, prometheusMetrics.allErrorCounters.get("test_test1_errors").get(),0.0); } @Test @@ -62,14 +62,14 @@ public void cannotRegisterSameCounterTwice() { prometheusMetrics.registerCounter("test2","help"); prometheusMetrics.incrementCount("test2"); - Assert.assertEquals(1, prometheusMetrics.allCounters.size()); - Assert.assertEquals(1, prometheusMetrics.allErrorCounters.size()); + Assertions.assertEquals(1, prometheusMetrics.allCounters.size()); + Assertions.assertEquals(1, prometheusMetrics.allErrorCounters.size()); prometheusMetrics.registerCounter("test2","help"); - Assert.assertEquals(1, prometheusMetrics.allCounters.size()); - Assert.assertEquals(1, prometheusMetrics.allErrorCounters.size()); + Assertions.assertEquals(1, prometheusMetrics.allCounters.size()); + Assertions.assertEquals(1, prometheusMetrics.allErrorCounters.size()); prometheusMetrics.incrementCount("test2"); - Assert.assertEquals(2.0D, prometheusMetrics.allCounters.get("test_test2").get(),0.0); - Assert.assertEquals(0.0D, prometheusMetrics.allErrorCounters.get("test_test2_errors").get(),0.0); + Assertions.assertEquals(2.0D, prometheusMetrics.allCounters.get("test_test2").get(),0.0); + Assertions.assertEquals(0.0D, prometheusMetrics.allErrorCounters.get("test_test2_errors").get(),0.0); } @@ -77,15 +77,15 @@ public void cannotRegisterSameCounterTwice() public void incrementUnknownMetric() { prometheusMetrics.incrementCount("test2"); - Assert.assertEquals(1, prometheusMetrics.allCounters.size()); - Assert.assertEquals(0, prometheusMetrics.allErrorCounters.size()); + Assertions.assertEquals(1, prometheusMetrics.allCounters.size()); + Assertions.assertEquals(0, prometheusMetrics.allErrorCounters.size()); prometheusMetrics.incrementCount("test2"); - Assert.assertEquals(2.0D, prometheusMetrics.allCounters.get("test_test2").get(),0.0); - Assert.assertNull(prometheusMetrics.allErrorCounters.get("test_test2_errors")); + Assertions.assertEquals(2.0D, prometheusMetrics.allCounters.get("test_test2").get(),0.0); + Assertions.assertNull(prometheusMetrics.allErrorCounters.get("test_test2_errors")); prometheusMetrics.incrementErrorCount("test2"); - Assert.assertEquals(1.0D, prometheusMetrics.allErrorCounters.get("test_test2_errors").get(),0.0); + Assertions.assertEquals(1.0D, prometheusMetrics.allErrorCounters.get("test_test2_errors").get(),0.0); } @@ -94,9 +94,9 @@ public void incrementUnknownMetric() public void testSummaryRegistration() { prometheusMetrics.registerSummary("test","test"); - Assert.assertEquals(1,prometheusMetrics.allSummaries.keySet().size()); + Assertions.assertEquals(1,prometheusMetrics.allSummaries.keySet().size()); prometheusMetrics.registerSummary("test","test"); - Assert.assertEquals(1,prometheusMetrics.allSummaries.keySet().size()); + Assertions.assertEquals(1,prometheusMetrics.allSummaries.keySet().size()); } } diff --git a/legend-depot-core-tracing/src/test/java/org/finos/legend/depot/core/services/metrics/TestResourceApiTracing.java b/legend-depot-core-tracing/src/test/java/org/finos/legend/depot/core/services/metrics/TestResourceApiTracing.java index fa1187544..f40723854 100644 --- a/legend-depot-core-tracing/src/test/java/org/finos/legend/depot/core/services/metrics/TestResourceApiTracing.java +++ b/legend-depot-core-tracing/src/test/java/org/finos/legend/depot/core/services/metrics/TestResourceApiTracing.java @@ -16,8 +16,8 @@ package org.finos.legend.depot.core.services.metrics; import org.finos.legend.depot.core.services.api.metrics.configuration.PrometheusConfiguration; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class TestResourceApiTracing { @@ -27,7 +27,7 @@ public class TestResourceApiTracing public void testMetricRegistrationForResource() { prometheusMetrics.registerResourceSummaries(TestTracingResource.class); - Assert.assertEquals(1,prometheusMetrics.allSummaries.keySet().size()); + Assertions.assertEquals(1,prometheusMetrics.allSummaries.keySet().size()); } } diff --git a/legend-depot-entities-services/src/test/java/org/finos/legend/depot/server/resources/TestEntitiesResource.java b/legend-depot-entities-services/src/test/java/org/finos/legend/depot/server/resources/TestEntitiesResource.java index 1fc5f7b22..0762ca8ac 100644 --- a/legend-depot-entities-services/src/test/java/org/finos/legend/depot/server/resources/TestEntitiesResource.java +++ b/legend-depot-entities-services/src/test/java/org/finos/legend/depot/server/resources/TestEntitiesResource.java @@ -37,10 +37,10 @@ import org.finos.legend.depot.store.mongo.metrics.query.QueryMetricsMongo; import org.finos.legend.depot.services.api.notifications.queue.Queue; import org.finos.legend.sdlc.domain.model.entity.Entity; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Response; import java.util.List; @@ -68,7 +68,7 @@ public class TestEntitiesResource extends TestBaseServices private QueryMetricsService metricsHandler = new QueryMetricsServiceImpl(metricsStore); - @Before + @BeforeEach public void setupMetadata() { super.setUpData(); @@ -81,7 +81,7 @@ public void setupMetadata() when(projectsVersions.find("example.services.test", "test", "1.0.1")).thenReturn(Optional.of(new StoreProjectVersionData("example.services.test", "test", "1.0.1"))); } - @After + @AfterEach public void tearDown() { metricsStore.getCollection().drop(); @@ -92,8 +92,8 @@ public void canGetEntitiesForProjectAndVersion() { Response response = entitiesResource.getEntities("examples.metadata", "test", "2.3.0", null); List entityList = (List) response.getEntity(); - Assert.assertNotNull(entityList); - Assert.assertEquals(7, entityList.size()); + Assertions.assertNotNull(entityList); + Assertions.assertEquals(7, entityList.size()); } @Test @@ -101,8 +101,8 @@ public void canGetEntityByPathForProjectAndVersion() { Response response = entitiesResource.getEntity("examples.metadata", "test", "2.3.0", "examples::metadata::test::TestProfile", null); Entity entity = ((Optional) response.getEntity()).get(); - Assert.assertNotNull(entity); - Assert.assertEquals("meta::pure::metamodel::extension::Profile", entity.getClassifierPath()); + Assertions.assertNotNull(entity); + Assertions.assertEquals("meta::pure::metamodel::extension::Profile", entity.getClassifierPath()); } @@ -111,8 +111,8 @@ public void canGetEntitiesByPackageForProjectAndVersion() { Response response = entitiesResource.getEntities("examples.metadata", "test", "2.3.0", "examples::metadata::test", null, true, null); List entityList = (List) response.getEntity(); - Assert.assertNotNull(entityList); - Assert.assertEquals(4, entityList.size()); + Assertions.assertNotNull(entityList); + Assertions.assertEquals(4, entityList.size()); } @@ -120,31 +120,31 @@ public void canGetEntitiesByPackageForProjectAndVersion() @Test public void canGetMetrics() throws InterruptedException { - Assert.assertTrue(metricsStore.getAllStoredEntities().isEmpty()); - Assert.assertEquals(0, metricsStore.get("examples.metadata", "test", "2.3.0").size()); + Assertions.assertTrue(metricsStore.getAllStoredEntities().isEmpty()); + Assertions.assertEquals(0, metricsStore.get("examples.metadata", "test", "2.3.0").size()); when(projects.find("examples.metadata","test")).thenReturn(Optional.of(new StoreProjectData("mock","examples.metadata","test"))); Response responseOne = entitiesResource.getEntities("examples.metadata", "test", "2.3.0", "examples::metadata::test", null, true, null); - Assert.assertEquals(Response.Status.OK.getStatusCode(), responseOne.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), responseOne.getStatus()); metricsHandler.persist(metricsRegistry); - Assert.assertEquals(1, metricsStore.get("examples.metadata", "test", "2.3.0").size()); - Assert.assertNotNull(metricsStore.get("examples.metadata", "test", "2.3.0").get(0).getLastQueryTime()); + Assertions.assertEquals(1, metricsStore.get("examples.metadata", "test", "2.3.0").size()); + Assertions.assertNotNull(metricsStore.get("examples.metadata", "test", "2.3.0").get(0).getLastQueryTime()); TimeUnit.SECONDS.sleep(30); Response responseTwo = entitiesResource.getEntities("example.services.test", "test", "1.0.1", null); - Assert.assertEquals(Response.Status.OK.getStatusCode(), responseTwo.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), responseTwo.getStatus()); metricsHandler.persist(metricsRegistry); - Assert.assertNotNull(metricsStore.get("examples.metadata", "test", "2.3.0").get(0).getLastQueryTime()); - Assert.assertEquals(3, metricsStore.getAllStoredEntities().size()); + Assertions.assertNotNull(metricsStore.get("examples.metadata", "test", "2.3.0").get(0).getLastQueryTime()); + Assertions.assertEquals(3, metricsStore.getAllStoredEntities().size()); } @Test public void canGetMetricsForTransitiveDependencies() throws InterruptedException { - Assert.assertTrue(metricsStore.getAllStoredEntities().isEmpty()); - Assert.assertEquals(0, metricsStore.get("examples.metadata", "test", "2.3.0").size()); + Assertions.assertTrue(metricsStore.getAllStoredEntities().isEmpty()); + Assertions.assertEquals(0, metricsStore.get("examples.metadata", "test", "2.3.0").size()); StoreProjectVersionData versionData = new StoreProjectVersionData("examples.metadata", "test-master", "2.3.0"); versionData.getVersionData().setDependencies(Collections.singletonList(new ProjectVersion("examples.metadata","test", "2.3.0"))); @@ -154,9 +154,9 @@ public void canGetMetricsForTransitiveDependencies() throws InterruptedException entitiesService.getDependenciesEntities("examples.metadata", "test-master", "2.3.0", true, false); metricsHandler.persist(metricsRegistry); - Assert.assertEquals(2, metricsStore.getAll().size()); - Assert.assertNotNull(metricsStore.get("examples.metadata", "test", "2.3.0").get(0).getLastQueryTime()); - Assert.assertNotNull(metricsStore.get("examples.metadata", "test-master", "2.3.0").get(0).getLastQueryTime()); + Assertions.assertEquals(2, metricsStore.getAll().size()); + Assertions.assertNotNull(metricsStore.get("examples.metadata", "test", "2.3.0").get(0).getLastQueryTime()); + Assertions.assertNotNull(metricsStore.get("examples.metadata", "test-master", "2.3.0").get(0).getLastQueryTime()); } @@ -165,8 +165,8 @@ public void canGetEntityByElementPath() { Response response = entitiesResource.getEntity("examples.metadata", "test", "2.3.0", "examples::metadata::test::TestProfile", null); Entity entity = ((Optional) response.getEntity()).get(); - Assert.assertNotNull(entity); - Assert.assertEquals("meta::pure::metamodel::extension::Profile", entity.getClassifierPath()); + Assertions.assertNotNull(entity); + Assertions.assertEquals("meta::pure::metamodel::extension::Profile", entity.getClassifierPath()); } @Test @@ -174,8 +174,8 @@ public void canGetEntityByPathWithVersion() { Response response = entitiesResource.getEntity("examples.metadata", "test", "2.3.0", "examples::metadata::test::TestProfile", null); Entity entity = ((Optional) response.getEntity()).get(); - Assert.assertNotNull(entity); - Assert.assertEquals("meta::pure::metamodel::extension::Profile", entity.getClassifierPath()); + Assertions.assertNotNull(entity); + Assertions.assertEquals("meta::pure::metamodel::extension::Profile", entity.getClassifierPath()); } @Test @@ -183,8 +183,8 @@ public void canGetEntitiesByPackage() { Response response = entitiesResource.getEntities("examples.metadata", "test", "2.3.0", "examples::metadata::test", null, true, null); List entityList = (List) response.getEntity(); - Assert.assertNotNull(entityList); - Assert.assertEquals(4, entityList.size()); + Assertions.assertNotNull(entityList); + Assertions.assertEquals(4, entityList.size()); } } diff --git a/legend-depot-entities-services/src/test/java/org/finos/legend/depot/services/entities/TestEntitiesService.java b/legend-depot-entities-services/src/test/java/org/finos/legend/depot/services/entities/TestEntitiesService.java index df25dba28..7f8dbda7d 100644 --- a/legend-depot-entities-services/src/test/java/org/finos/legend/depot/services/entities/TestEntitiesService.java +++ b/legend-depot-entities-services/src/test/java/org/finos/legend/depot/services/entities/TestEntitiesService.java @@ -38,9 +38,9 @@ import org.finos.legend.depot.store.mongo.entities.EntitiesMongo; import org.finos.legend.depot.store.mongo.entities.test.EntitiesMongoTestUtils; import org.finos.legend.sdlc.domain.model.entity.Entity; -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 java.util.Arrays; import java.util.Collections; @@ -62,7 +62,7 @@ public class TestEntitiesService extends TestBaseServices protected ManageEntitiesService entitiesService = new ManageEntitiesServiceImpl(entitiesStore, projectsService); protected EntityClassifierService classifierService = new EntityClassifierServiceImpl(projectsService, entitiesStore); - @Before + @BeforeEach public void setUpData() { super.setUpData(); @@ -85,44 +85,44 @@ public void canGetDependencies() { List entityList = entitiesService.getEntities("examples.metadata", "test", "2.3.1"); - Assert.assertFalse(entityList.isEmpty()); - Assert.assertEquals(7, entityList.size()); + Assertions.assertFalse(entityList.isEmpty()); + Assertions.assertEquals(7, entityList.size()); List entityList2 = entitiesService.getEntities("examples.metadata", "test-dependencies", "1.0.0"); - Assert.assertFalse(entityList2.isEmpty()); - Assert.assertEquals(1, entityList2.size()); + Assertions.assertFalse(entityList2.isEmpty()); + Assertions.assertEquals(1, entityList2.size()); List entityList3 = entitiesService.getEntities("example.services.test", "test", "2.0.1"); - Assert.assertFalse(entityList3.isEmpty()); - Assert.assertEquals(18, entityList3.size()); + Assertions.assertFalse(entityList3.isEmpty()); + Assertions.assertEquals(18, entityList3.size()); List dependencyList = entitiesService.getDependenciesEntities("examples.metadata", "test", "2.3.1",false, false); - Assert.assertFalse(dependencyList.isEmpty()); - Assert.assertEquals(1, dependencyList.size()); - Assert.assertFalse(dependencyList.stream().filter(projectToArtifactFilter("examples.metadata", "test")).findFirst().isPresent()); - Assert.assertEquals(1, dependencyList.stream().filter(projectToArtifactFilter("examples.metadata", "test-dependencies")).findFirst().get().getEntities().size()); - Assert.assertFalse(dependencyList.stream().filter(projectToArtifactFilter("example.services.test", "test")).findFirst().isPresent()); + Assertions.assertFalse(dependencyList.isEmpty()); + Assertions.assertEquals(1, dependencyList.size()); + Assertions.assertFalse(dependencyList.stream().filter(projectToArtifactFilter("examples.metadata", "test")).findFirst().isPresent()); + Assertions.assertEquals(1, dependencyList.stream().filter(projectToArtifactFilter("examples.metadata", "test-dependencies")).findFirst().get().getEntities().size()); + Assertions.assertFalse(dependencyList.stream().filter(projectToArtifactFilter("example.services.test", "test")).findFirst().isPresent()); List dependencyList2 = entitiesService.getDependenciesEntities("examples.metadata", "test", "2.3.1", true, false); - Assert.assertFalse(dependencyList2.isEmpty()); - Assert.assertEquals(2, dependencyList2.size()); - Assert.assertFalse(dependencyList2.stream().filter(projectToArtifactFilter("examples.metadata", "test")).findFirst().isPresent()); - Assert.assertEquals(1, dependencyList2.stream().filter(projectToArtifactFilter("examples.metadata", "test-dependencies")).findFirst().get().getEntities().size()); - Assert.assertEquals(18, dependencyList2.stream().filter(projectToArtifactFilter("example.services.test", "test")).findFirst().get().getEntities().size()); + Assertions.assertFalse(dependencyList2.isEmpty()); + Assertions.assertEquals(2, dependencyList2.size()); + Assertions.assertFalse(dependencyList2.stream().filter(projectToArtifactFilter("examples.metadata", "test")).findFirst().isPresent()); + Assertions.assertEquals(1, dependencyList2.stream().filter(projectToArtifactFilter("examples.metadata", "test-dependencies")).findFirst().get().getEntities().size()); + Assertions.assertEquals(18, dependencyList2.stream().filter(projectToArtifactFilter("example.services.test", "test")).findFirst().get().getEntities().size()); List dependencyList3 = entitiesService.getDependenciesEntities("examples.metadata", "test", "2.3.1", true, true); - Assert.assertFalse(dependencyList3.isEmpty()); - Assert.assertEquals(3, dependencyList3.size()); - Assert.assertEquals(7, dependencyList3.stream().filter(projectToArtifactFilter("examples.metadata", "test")).findFirst().get().getEntities().size()); - Assert.assertEquals(1, dependencyList3.stream().filter(projectToArtifactFilter("examples.metadata", "test-dependencies")).findFirst().get().getEntities().size()); - Assert.assertEquals(18, dependencyList3.stream().filter(projectToArtifactFilter("example.services.test", "test")).findFirst().get().getEntities().size()); + Assertions.assertFalse(dependencyList3.isEmpty()); + Assertions.assertEquals(3, dependencyList3.size()); + Assertions.assertEquals(7, dependencyList3.stream().filter(projectToArtifactFilter("examples.metadata", "test")).findFirst().get().getEntities().size()); + Assertions.assertEquals(1, dependencyList3.stream().filter(projectToArtifactFilter("examples.metadata", "test-dependencies")).findFirst().get().getEntities().size()); + Assertions.assertEquals(18, dependencyList3.stream().filter(projectToArtifactFilter("example.services.test", "test")).findFirst().get().getEntities().size()); } private Predicate projectToArtifactFilter(String groupId,String artifactId) { List p = projectsVersionsStore.find(groupId, artifactId); - Assert.assertTrue(!p.isEmpty()); + Assertions.assertTrue(!p.isEmpty()); return dep -> dep.getGroupId().equals(groupId) && dep.getArtifactId().equals(artifactId); } @@ -131,11 +131,11 @@ public void canGetDependenciesMap() { List projectVersions = Arrays.asList(new ProjectVersion("examples.metadata", "test", "2.3.1"), new ProjectVersion("examples.metadata", "test-dependencies", "1.0.0")); List dependencyList3 = entitiesService.getDependenciesEntities(projectVersions, true, true); - Assert.assertFalse(dependencyList3.isEmpty()); - Assert.assertEquals(3, dependencyList3.size()); - Assert.assertEquals(7, dependencyList3.stream().filter(projectToArtifactFilter("examples.metadata", "test")).findFirst().get().getEntities().size()); - Assert.assertEquals(1, dependencyList3.stream().filter(projectToArtifactFilter("examples.metadata", "test-dependencies")).findFirst().get().getEntities().size()); - Assert.assertEquals(18, dependencyList3.stream().filter(projectToArtifactFilter("example.services.test", "test")).findFirst().get().getEntities().size()); + Assertions.assertFalse(dependencyList3.isEmpty()); + Assertions.assertEquals(3, dependencyList3.size()); + Assertions.assertEquals(7, dependencyList3.stream().filter(projectToArtifactFilter("examples.metadata", "test")).findFirst().get().getEntities().size()); + Assertions.assertEquals(1, dependencyList3.stream().filter(projectToArtifactFilter("examples.metadata", "test-dependencies")).findFirst().get().getEntities().size()); + Assertions.assertEquals(18, dependencyList3.stream().filter(projectToArtifactFilter("example.services.test", "test")).findFirst().get().getEntities().size()); } @@ -147,12 +147,12 @@ public void canQueryEntitiesWithVersionInPackage() entityUtils.loadEntities("PROD-D", "1.0.0"); String pkgName = "examples::metadata::test::dependency::v1_2_3"; - Assert.assertEquals(2, entitiesService.getStoredEntities("examples.metadata","test1","1.0.0").size()); + Assertions.assertEquals(2, entitiesService.getStoredEntities("examples.metadata","test1","1.0.0").size()); entitiesService.getStoredEntities("examples.metadata","test1","1.0.0").stream().allMatch(e -> ((StoredEntityData)e).getEntity().getPath().startsWith(pkgName)); entitiesService.getStoredEntities("examples.metadata","test1","1.0.0").stream().allMatch(e -> ((String)(((StoredEntityData)e).getEntity().getContent().get("package"))).startsWith(pkgName));; - Assert.assertEquals(2, entitiesService.getEntities("examples.metadata","test1","1.0.0").size()); - Assert.assertEquals(2, entitiesService.getEntitiesByPackage("examples.metadata","test1","1.0.0",pkgName, Collections.EMPTY_SET,true).size()); + Assertions.assertEquals(2, entitiesService.getEntities("examples.metadata","test1","1.0.0").size()); + Assertions.assertEquals(2, entitiesService.getEntitiesByPackage("examples.metadata","test1","1.0.0",pkgName, Collections.EMPTY_SET,true).size()); } @@ -167,8 +167,8 @@ public void canQueryEntitiesWithLatestVersionAlias() String pkgName = "examples::metadata::test::dependency::v1_2_3"; - Assert.assertEquals(2, entitiesService.getEntities("examples.metadata","test1","latest").size()); - Assert.assertEquals(2, entitiesService.getEntitiesByPackage("examples.metadata","test1","latest", pkgName, Collections.EMPTY_SET,true).size()); + Assertions.assertEquals(2, entitiesService.getEntities("examples.metadata","test1","latest").size()); + Assertions.assertEquals(2, entitiesService.getEntitiesByPackage("examples.metadata","test1","latest", pkgName, Collections.EMPTY_SET,true).size()); } @@ -177,11 +177,11 @@ public void canGetDependenciesMapWithLatestAlias() { List projectVersions = Arrays.asList(new ProjectVersion("examples.metadata", "test", "latest"), new ProjectVersion("examples.metadata", "test-dependencies", "latest")); List dependencyList3 = entitiesService.getDependenciesEntities(projectVersions, true, true); - Assert.assertFalse(dependencyList3.isEmpty()); - Assert.assertEquals(3, dependencyList3.size()); - Assert.assertEquals(7, dependencyList3.stream().filter(projectToArtifactFilter("examples.metadata", "test")).findFirst().get().getEntities().size()); - Assert.assertEquals(1, dependencyList3.stream().filter(projectToArtifactFilter("examples.metadata", "test-dependencies")).findFirst().get().getEntities().size()); - Assert.assertEquals(18, dependencyList3.stream().filter(projectToArtifactFilter("example.services.test", "test")).findFirst().get().getEntities().size()); + Assertions.assertFalse(dependencyList3.isEmpty()); + Assertions.assertEquals(3, dependencyList3.size()); + Assertions.assertEquals(7, dependencyList3.stream().filter(projectToArtifactFilter("examples.metadata", "test")).findFirst().get().getEntities().size()); + Assertions.assertEquals(1, dependencyList3.stream().filter(projectToArtifactFilter("examples.metadata", "test-dependencies")).findFirst().get().getEntities().size()); + Assertions.assertEquals(18, dependencyList3.stream().filter(projectToArtifactFilter("example.services.test", "test")).findFirst().get().getEntities().size()); } @Test @@ -189,10 +189,10 @@ public void canGetDependenciesMapWithHeadAlias() { List projectVersions = Arrays.asList(new ProjectVersion("examples.metadata", "test", "head"), new ProjectVersion("examples.metadata", "test-dependencies", "latest")); List dependencyList3 = entitiesService.getDependenciesEntities(projectVersions, true, true); - Assert.assertFalse(dependencyList3.isEmpty()); - Assert.assertEquals(3, dependencyList3.size()); - Assert.assertEquals(1, dependencyList3.stream().filter(projectToArtifactFilter("examples.metadata", "test-dependencies")).findFirst().get().getEntities().size()); - Assert.assertEquals(18, dependencyList3.stream().filter(projectToArtifactFilter("example.services.test", "test")).findFirst().get().getEntities().size()); + Assertions.assertFalse(dependencyList3.isEmpty()); + Assertions.assertEquals(3, dependencyList3.size()); + Assertions.assertEquals(1, dependencyList3.stream().filter(projectToArtifactFilter("examples.metadata", "test-dependencies")).findFirst().get().getEntities().size()); + Assertions.assertEquals(18, dependencyList3.stream().filter(projectToArtifactFilter("example.services.test", "test")).findFirst().get().getEntities().size()); } @Test @@ -203,8 +203,8 @@ public void canQueryEntitiesWithHeadVersionAlias() String pkgName = "examples::metadata::test::v2_3_1::examples::metadata::test"; - Assert.assertEquals(7, entitiesService.getEntities("examples.metadata","test","head").size()); - Assert.assertEquals(0, entitiesService.getEntitiesByPackage("examples.metadata","test","head",pkgName, Collections.EMPTY_SET,true).size()); + Assertions.assertEquals(7, entitiesService.getEntities("examples.metadata","test","head").size()); + Assertions.assertEquals(0, entitiesService.getEntitiesByPackage("examples.metadata","test","head",pkgName, Collections.EMPTY_SET,true).size()); } @@ -215,8 +215,8 @@ public void canCreateAndUpdateEntities() entitiesService.createOrUpdate("examples.metadata", "test", "3.0.0", Arrays.asList(entity)); List storedEntities = entitiesService.getStoredEntities("examples.metadata", "test", "3.0.0"); - Assert.assertEquals(1, storedEntities.size()); - Assert.assertTrue(storedEntities.get(0) instanceof StoredEntityStringData); + Assertions.assertEquals(1, storedEntities.size()); + Assertions.assertTrue(storedEntities.get(0) instanceof StoredEntityStringData); } @@ -233,14 +233,14 @@ public void canSerializeEntityDefinitionWithNulls() // check entities serialization and deserialization Entity entity = (Entity) entitiesService.getEntities("examples.metadata", "test", "5.0.0").get(0); - Assert.assertEquals(content, entity.getContent()); + Assertions.assertEquals(content, entity.getContent()); } @Test public void canGetClassifiers() { List entities = classifierService.getEntitiesByClassifierPath("meta::pure::metamodel::type::Class", null, null, Scope.RELEASES, true); - Assert.assertEquals(entities.size(), 3); + Assertions.assertEquals(entities.size(), 3); } @Test @@ -249,8 +249,8 @@ public void canGetEntitiesForProjectAndVersionByClassifier() projectsVersionsStore.createOrUpdate(new StoreProjectVersionData("example.services.test","test","2.0.2")); entityUtils.loadEntities("PROD-C", "2.0.2"); List entity = entitiesService.getEntitiesByClassifier("example.services.test", "test", "2.0.2", "meta::pure::metamodel::function::ConcreteFunctionDefinition"); - Assert.assertNotNull(entity); - Assert.assertEquals(1, entity.size()); + Assertions.assertNotNull(entity); + Assertions.assertEquals(1, entity.size()); } @Test @@ -264,29 +264,29 @@ public void canGetDependencyEntitiesForProjectAndVersionByClassifier() entityUtils.loadEntities("PROD-B", "1.0.1"); entityUtils.loadEntities("PROD-C", "2.0.2"); List entity = entitiesService.getDependenciesEntitiesByClassifier("examples.metadata", "test-dependencies", "1.0.1", "meta::pure::metamodel::function::ConcreteFunctionDefinition", true, true); - Assert.assertNotNull(entity); - Assert.assertEquals(2, entity.size()); + Assertions.assertNotNull(entity); + Assertions.assertEquals(2, entity.size()); List entity1 = entitiesService.getDependenciesEntitiesByClassifier("examples.metadata", "test-dependencies", "1.0.1", "meta::pure::metamodel::function::ConcreteFunctionDefinition", true, false); - Assert.assertNotNull(entity1); - Assert.assertEquals(1, entity1.size()); + Assertions.assertNotNull(entity1); + Assertions.assertEquals(1, entity1.size()); } @Test public void canGetEntityFromDependencies() { List entity = entitiesService.getEntityFromDependencies("examples.metadata", "test", "2.3.1", Lists.fixedSize.of("domain::covid::JHUCovid19","examples::metadata::test::dependency::Dependency"), false); - Assert.assertEquals(entity.size(), 2); + Assertions.assertEquals(entity.size(), 2); entity = entitiesService.getEntityFromDependencies("examples.metadata", "test", "2.3.1", Lists.fixedSize.of("examples::metadata::test::dependency::Dependency","com::MyGenerationSpecification"), true); - Assert.assertEquals(entity.size(), 2); + Assertions.assertEquals(entity.size(), 2); entity = entitiesService.getEntityFromDependencies("examples.metadata", "test", "2.3.1", Lists.fixedSize.of("examples::metadata::test::dependency::Dependency","covid::JHUCovid19"), false); - Assert.assertEquals(entity.size(), 1); + Assertions.assertEquals(entity.size(), 1); entity = entitiesService.getEntityFromDependencies("examples.metadata", "test", "2.3.1", Lists.fixedSize.of("com::MyGenerationSpecification","covid::JHUCovid19"), false); - Assert.assertEquals(entity.size(), 0); + Assertions.assertEquals(entity.size(), 0); - Assert.assertThrows("project version not found for examples.metadata-test-3.0.1", IllegalArgumentException.class, () -> entitiesService.getEntityFromDependencies("examples.metadata", "test", "3.0.1", Lists.fixedSize.of("covid::JHUCovid19"), false)); + Assertions.assertThrows(IllegalArgumentException.class, () -> entitiesService.getEntityFromDependencies("examples.metadata", "test", "3.0.1", Lists.fixedSize.of("covid::JHUCovid19"), false), "project version not found for examples.metadata-test-3.0.1"); } } diff --git a/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/TestMongoAdminStore.java b/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/TestMongoAdminStore.java index ab6659788..964b76a91 100644 --- a/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/TestMongoAdminStore.java +++ b/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/TestMongoAdminStore.java @@ -19,9 +19,9 @@ import org.bson.Document; import org.finos.legend.depot.store.mongo.TestStoreMongo; import org.finos.legend.depot.store.mongo.entities.test.EntitiesMongoTestUtils; -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 java.util.Arrays; import java.util.List; @@ -31,7 +31,7 @@ public class TestMongoAdminStore extends TestStoreMongo MongoAdminStore mongoAdminStore = new MongoAdminStore(mongoProvider); - @Before + @BeforeEach public void setUp() { new EntitiesMongoTestUtils(mongoProvider).loadEntities(this.getClass().getClassLoader().getResource("data/versioned-entities.json")); @@ -65,8 +65,8 @@ public void canRunPipelineAsJson() throws JsonProcessingException "]"; List result = mongoAdminStore.runPipeline("entities", pipeline); - Assert.assertNotNull(result); - Assert.assertEquals(1,result.size()); + Assertions.assertNotNull(result); + Assertions.assertEquals(1,result.size()); } @@ -86,10 +86,10 @@ public void canRunPipeline() throws JsonProcessingException .append("total", new Document("$sum", 1L)))); - Assert.assertEquals(3,mongoProvider.getCollection("entities").countDocuments()); + Assertions.assertEquals(3,mongoProvider.getCollection("entities").countDocuments()); List result = mongoAdminStore.runPipeline("entities", pipeline); - Assert.assertNotNull(result); - Assert.assertEquals(1,result.size()); + Assertions.assertNotNull(result); + Assertions.assertEquals(1,result.size()); } } diff --git a/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/migrations/TestEntitiesMigration.java b/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/migrations/TestEntitiesMigration.java index d27665932..f0c7f7d1b 100644 --- a/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/migrations/TestEntitiesMigration.java +++ b/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/migrations/TestEntitiesMigration.java @@ -34,9 +34,9 @@ import org.finos.legend.depot.store.mongo.entities.EntitiesMongo; import org.finos.legend.depot.store.mongo.entities.test.EntitiesMongoTestUtils; import org.finos.legend.sdlc.domain.model.entity.Entity; -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 java.io.InputStream; import java.net.URL; @@ -52,11 +52,11 @@ public class TestEntitiesMigration extends TestStoreMongo { MongoEntitiesMigrations mongoAdminStore = new MongoEntitiesMigrations(mongoProvider); - @Before + @BeforeEach public void setupTestData() { new EntitiesMongoTestUtils(mongoProvider).loadEntities(this.getClass().getClassLoader().getResource("data/versioned-entities-deletion.json")); - Assert.assertEquals(3,mongoProvider.getCollection("entities").countDocuments()); + Assertions.assertEquals(3,mongoProvider.getCollection("entities").countDocuments()); } private Bson getArtifactAndVersionFilter(String groupId, String artifactId, String versionId) @@ -72,7 +72,7 @@ public void canDeleteVersionedEntities() mongoProvider.getCollection("entities").updateOne(and(Filters.eq("entity.path", "examples::metadata::test::TestProfile"), getArtifactAndVersionFilter("examples.metadata", "test", "2.2.0")), Updates.combine(Updates.set("versionedEntity", true))); DeleteResult result = mongoAdminStore.deleteVersionedEntities(); - Assert.assertEquals(2, mongoProvider.getCollection("entities").countDocuments()); + Assertions.assertEquals(2, mongoProvider.getCollection("entities").countDocuments()); } @Test @@ -81,7 +81,7 @@ public void canDeleteAllVersionedEntities() mongoProvider.getCollection("entities").updateMany(getArtifactAndVersionFilter("examples.metadata", "test", "2.2.0"), Updates.combine(Updates.set("versionedEntity", true))); DeleteResult result = mongoAdminStore.deleteVersionedEntities(); - Assert.assertEquals(0, mongoProvider.getCollection("entities").countDocuments()); + Assertions.assertEquals(0, mongoProvider.getCollection("entities").countDocuments()); } @Test @@ -91,15 +91,15 @@ public void canMigrateToStoredEntityData() setUpLegacyEntitiesDataFromFile(this.getClass().getClassLoader().getResource("data/migration/legacy-entities.json")); mongoAdminStore.migrateEntitiesToStoredEntityData(); - Assert.assertEquals(3, mongoProvider.getCollection("entities").countDocuments()); - Assert.assertNotNull(mongoProvider.getCollection("entities").find().first().getString("_type")); - Assert.assertEquals("entityData", mongoProvider.getCollection("entities").find().first().getString("_type")); + Assertions.assertEquals(3, mongoProvider.getCollection("entities").countDocuments()); + Assertions.assertNotNull(mongoProvider.getCollection("entities").find().first().getString("_type")); + Assertions.assertEquals("entityData", mongoProvider.getCollection("entities").find().first().getString("_type")); EntitiesMongo entitiesMongo = new EntitiesMongo(mongoProvider); List storedEntities = entitiesMongo.getAllStoredEntities(); - Assert.assertTrue(storedEntities.get(0) instanceof StoredEntityData); - Assert.assertTrue(storedEntities.get(1) instanceof StoredEntityData); - Assert.assertTrue(storedEntities.get(2) instanceof StoredEntityData); + Assertions.assertTrue(storedEntities.get(0) instanceof StoredEntityData); + Assertions.assertTrue(storedEntities.get(1) instanceof StoredEntityData); + Assertions.assertTrue(storedEntities.get(2) instanceof StoredEntityData); } protected void setUpLegacyEntitiesDataFromFile(URL entitiesFile) @@ -114,14 +114,14 @@ protected void setUpLegacyEntitiesDataFromFile(URL entitiesFile) } catch (JsonProcessingException e) { - Assert.fail("an error has occurred loading test entity" + e.getMessage()); + Assertions.fail("an error has occurred loading test entity" + e.getMessage()); } }); - Assert.assertNotNull(getMongoDatabase().getCollection("entities")); + Assertions.assertNotNull(getMongoDatabase().getCollection("entities")); } catch (Exception e) { - Assert.fail("an error has occurred loading test entity" + e.getMessage()); + Assertions.fail("an error has occurred loading test entity" + e.getMessage()); } } @@ -135,12 +135,12 @@ protected List readLegacyEntitiesFile(URL fileName) List entities = new ObjectMapper().readValue(jsonInput, new TypeReference>() { }); - Assert.assertNotNull("testing file" + fileName.getFile(), entities); + Assertions.assertNotNull(entities, "testing file" + fileName.getFile()); return entities; } catch (Exception e) { - Assert.fail("an error has occurred loading test versioned entity metadata" + e.getMessage()); + Assertions.fail("an error has occurred loading test versioned entity metadata" + e.getMessage()); } return null; } diff --git a/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/TestQueryClassifierPath.java b/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/TestQueryClassifierPath.java index e2cabde2c..86086eb16 100644 --- a/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/TestQueryClassifierPath.java +++ b/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/TestQueryClassifierPath.java @@ -19,9 +19,9 @@ import org.finos.legend.depot.domain.project.ProjectVersion; import org.finos.legend.depot.store.mongo.TestStoreMongo; import org.finos.legend.depot.store.mongo.entities.test.EntitiesMongoTestUtils; -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 java.net.URL; @@ -30,7 +30,7 @@ public class TestQueryClassifierPath extends TestStoreMongo private static final URL ENTITIES_FILE = TestUpdateVersions.class.getClassLoader().getResource("data/classifiers.json"); private EntitiesMongo mongo = new EntitiesMongo(mongoProvider); - @Before + @BeforeEach public void setUp() { new EntitiesMongoTestUtils(mongoProvider).loadEntities(ENTITIES_FILE); @@ -40,32 +40,32 @@ public void setUp() public void canQuerySnapshotEntitiesByClassifier() { String CPATH = "meta::pure::metamodel::extension::Profile"; - Assert.assertEquals(3, mongo.findLatestClassifierEntities(CPATH).size()); - Assert.assertEquals(3, mongo.findLatestClassifierSummaries(CPATH).size()); - Assert.assertEquals(2, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "master-SNAPSHOT"))).size()); - Assert.assertEquals(2, mongo.findClassifierSummariesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "master-SNAPSHOT"))).size()); - Assert.assertEquals(1, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "master-SNAPSHOT")), "TestProfileTwo", 2).size()); - Assert.assertEquals(2, mongo.findLatestClassifierEntities(CPATH, null, 2).size()); - Assert.assertEquals(1, mongo.findLatestClassifierEntities(CPATH, "TestProfileTwo", 2).size()); + Assertions.assertEquals(3, mongo.findLatestClassifierEntities(CPATH).size()); + Assertions.assertEquals(3, mongo.findLatestClassifierSummaries(CPATH).size()); + Assertions.assertEquals(2, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "master-SNAPSHOT"))).size()); + Assertions.assertEquals(2, mongo.findClassifierSummariesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "master-SNAPSHOT"))).size()); + Assertions.assertEquals(1, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "master-SNAPSHOT")), "TestProfileTwo", 2).size()); + Assertions.assertEquals(2, mongo.findLatestClassifierEntities(CPATH, null, 2).size()); + Assertions.assertEquals(1, mongo.findLatestClassifierEntities(CPATH, "TestProfileTwo", 2).size()); } @Test public void canQueryVersionEntitiesByClassifier() { String CPATH = "meta::pure::metamodel::extension::Profile"; - Assert.assertEquals(6, mongo.findReleasedClassifierEntities(CPATH).size()); - Assert.assertEquals(6, mongo.findReleasedClassifierSummaries(CPATH).size()); - Assert.assertEquals(2, mongo.findReleasedClassifierEntities(CPATH, null, 2).size()); - Assert.assertEquals(3, mongo.findReleasedClassifierEntities(CPATH, "TestProfileTwo", null).size()); - Assert.assertEquals(6, mongo.findReleasedClassifierEntities(CPATH, "TestProfile", null).size()); - Assert.assertEquals(0, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "1.0.0"))).size()); - Assert.assertEquals(3, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "2.2.0"))).size()); - Assert.assertEquals(3, mongo.findClassifierSummariesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "2.2.0"))).size()); - Assert.assertEquals(1, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "2.3.0")), null, null).size()); - Assert.assertEquals(2, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test2", "2.3.0")), null, null).size()); - Assert.assertEquals(3, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "2.3.0"), new ProjectVersion("examples.metadata", "test2", "2.3.0")), null, null).size()); - Assert.assertEquals(1, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "2.3.0")), "TestProfileTwo", null).size()); - Assert.assertEquals(1, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test2", "2.3.0")), "TestProfileTwo", null).size()); - Assert.assertEquals(2, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "2.3.0"), new ProjectVersion("examples.metadata", "test2", "2.3.0")), "TestProfileTwo", null).size()); + Assertions.assertEquals(6, mongo.findReleasedClassifierEntities(CPATH).size()); + Assertions.assertEquals(6, mongo.findReleasedClassifierSummaries(CPATH).size()); + Assertions.assertEquals(2, mongo.findReleasedClassifierEntities(CPATH, null, 2).size()); + Assertions.assertEquals(3, mongo.findReleasedClassifierEntities(CPATH, "TestProfileTwo", null).size()); + Assertions.assertEquals(6, mongo.findReleasedClassifierEntities(CPATH, "TestProfile", null).size()); + Assertions.assertEquals(0, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "1.0.0"))).size()); + Assertions.assertEquals(3, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "2.2.0"))).size()); + Assertions.assertEquals(3, mongo.findClassifierSummariesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "2.2.0"))).size()); + Assertions.assertEquals(1, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "2.3.0")), null, null).size()); + Assertions.assertEquals(2, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test2", "2.3.0")), null, null).size()); + Assertions.assertEquals(3, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "2.3.0"), new ProjectVersion("examples.metadata", "test2", "2.3.0")), null, null).size()); + Assertions.assertEquals(1, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "2.3.0")), "TestProfileTwo", null).size()); + Assertions.assertEquals(1, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test2", "2.3.0")), "TestProfileTwo", null).size()); + Assertions.assertEquals(2, mongo.findClassifierEntitiesByVersions(CPATH, Lists.fixedSize.of(new ProjectVersion("examples.metadata", "test", "2.3.0"), new ProjectVersion("examples.metadata", "test2", "2.3.0")), "TestProfileTwo", null).size()); } } diff --git a/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/TestQueryRevisions.java b/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/TestQueryRevisions.java index b6b5856dd..2a79112bf 100644 --- a/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/TestQueryRevisions.java +++ b/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/TestQueryRevisions.java @@ -20,9 +20,9 @@ import org.finos.legend.depot.store.mongo.TestStoreMongo; import org.finos.legend.depot.store.mongo.entities.test.EntitiesMongoTestUtils; import org.finos.legend.sdlc.domain.model.entity.Entity; -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 java.util.ArrayList; import java.util.List; @@ -34,7 +34,7 @@ public class TestQueryRevisions extends TestStoreMongo private EntitiesMongo revisionsMongo = new EntitiesMongo(mongoProvider); private EntitiesMongoTestUtils entityUtils = new EntitiesMongoTestUtils(mongoProvider); - @Before + @BeforeEach public void setupMetadata() { entityUtils.loadEntities(this.getClass().getClassLoader().getResource("data/revision-entities.json")); @@ -45,31 +45,31 @@ public void setupMetadata() public void canQueryAllEntityMetadataByProjectVersion() { List entityList = revisionsMongo.getAllEntities("examples.metadata", "test",BRANCH_SNAPSHOT("master")); - Assert.assertNotNull(entityList); - Assert.assertEquals(4, entityList.size()); + Assertions.assertNotNull(entityList); + Assertions.assertEquals(4, entityList.size()); List paths = new ArrayList<>(); entityList.forEach(entity -> paths.add(entity.getPath())); - Assert.assertEquals(4, paths.size()); - Assert.assertTrue(paths.contains("examples::metadata::test::TestProfile")); - Assert.assertTrue(paths.contains("examples::metadata::test::ClientBasic")); + Assertions.assertEquals(4, paths.size()); + Assertions.assertTrue(paths.contains("examples::metadata::test::TestProfile")); + Assertions.assertTrue(paths.contains("examples::metadata::test::ClientBasic")); } @Test public void canQueryEntityMetadataByProjectVersion() { List entityList = revisionsMongo.getAllEntities("examples.metadata", "test", BRANCH_SNAPSHOT("master")); - Assert.assertNotNull(entityList); - Assert.assertEquals(4, entityList.size()); + Assertions.assertNotNull(entityList); + Assertions.assertEquals(4, entityList.size()); } @Test public void canQueryEntityMetadataByProjectVersionPath() { Entity entity = (Entity) revisionsMongo.getEntity("examples.metadata", "test", BRANCH_SNAPSHOT("master"),"examples::metadata::test::TestProfile").get(); - Assert.assertNotNull(entity); - Assert.assertEquals("examples::metadata::test::TestProfile", entity.getPath()); - Assert.assertEquals("meta::pure::metamodel::extension::Profile", entity.getClassifierPath()); - Assert.assertEquals("examples::metadata::test", entity.getContent().get("package")); + Assertions.assertNotNull(entity); + Assertions.assertEquals("examples::metadata::test::TestProfile", entity.getPath()); + Assertions.assertEquals("meta::pure::metamodel::extension::Profile", entity.getClassifierPath()); + Assertions.assertEquals("examples::metadata::test", entity.getContent().get("package")); } @@ -77,11 +77,11 @@ public void canQueryEntityMetadataByProjectVersionPath() public void canQueryEntityMetadataByProjectVersionPackage() { List entities = revisionsMongo.getEntitiesByPackage("examples.metadata", "test", BRANCH_SNAPSHOT("master"),"examples::metadata::test", null, false); - Assert.assertNotNull(entities); - Assert.assertEquals(3, entities.size()); + Assertions.assertNotNull(entities); + Assertions.assertEquals(3, entities.size()); for (Entity entity : entities) { - Assert.assertEquals("examples::metadata::test", entity.getContent().get("package")); + Assertions.assertEquals("examples::metadata::test", entity.getContent().get("package")); } } @@ -90,11 +90,11 @@ public void canQueryEntityMetadataByProjectVersionPackage() public void canQueryEntityMetadataByProjectSubPackage() { List entities = revisionsMongo.getEntitiesByPackage("examples.metadata", "test", BRANCH_SNAPSHOT("master"),"examples::metadata::test", null, true); - Assert.assertNotNull(entities); - Assert.assertEquals(4, entities.size()); + Assertions.assertNotNull(entities); + Assertions.assertEquals(4, entities.size()); for (Entity entity : entities) { - Assert.assertTrue(entity.getContent().get("package").toString().startsWith("examples::metadata::test")); + Assertions.assertTrue(entity.getContent().get("package").toString().startsWith("examples::metadata::test")); } } @@ -102,11 +102,11 @@ public void canQueryEntityMetadataByProjectSubPackage() public void canQueryByClassifier() { List entities = revisionsMongo.findLatestClassifierSummaries("meta::pure::metamodel::type::Class"); - Assert.assertNotNull(entities); - Assert.assertEquals(2, entities.size()); + Assertions.assertNotNull(entities); + Assertions.assertEquals(2, entities.size()); for (DepotEntity entity : entities) { - Assert.assertEquals("meta::pure::metamodel::type::Class", ((DepotEntityOverview)entity).getClassifierPath()); + Assertions.assertEquals("meta::pure::metamodel::type::Class", ((DepotEntityOverview)entity).getClassifierPath()); } } } diff --git a/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/TestQueryVersions.java b/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/TestQueryVersions.java index b5861aedb..e276f9e1c 100644 --- a/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/TestQueryVersions.java +++ b/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/TestQueryVersions.java @@ -19,9 +19,9 @@ import org.finos.legend.depot.store.mongo.TestStoreMongo; import org.finos.legend.depot.store.mongo.entities.test.EntitiesMongoTestUtils; import org.finos.legend.sdlc.domain.model.entity.Entity; -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 java.util.ArrayList; import java.util.HashSet; @@ -35,7 +35,7 @@ public class TestQueryVersions extends TestStoreMongo private EntitiesMongo versionsMongo = new EntitiesMongo(mongoProvider); private EntitiesMongoTestUtils entityUtils = new EntitiesMongoTestUtils(mongoProvider); - @Before + @BeforeEach public void setupMetadata() { @@ -48,13 +48,13 @@ public void setupMetadata() public void canQueryEntityMetadataByProjectVersion() { List entityList = versionsMongo.getAllEntities("examples.metadata", "test", "2.2.0"); - Assert.assertNotNull(entityList); - Assert.assertEquals(3, entityList.size()); + Assertions.assertNotNull(entityList); + Assertions.assertEquals(3, entityList.size()); List paths = new ArrayList<>(); entityList.forEach(entity -> paths.add(entity.getPath())); - Assert.assertEquals(3, paths.size()); - Assert.assertTrue(paths.contains("examples::metadata::test::TestProfile")); - Assert.assertTrue(paths.contains("examples::metadata::test::ClientBasic")); + Assertions.assertEquals(3, paths.size()); + Assertions.assertTrue(paths.contains("examples::metadata::test::TestProfile")); + Assertions.assertTrue(paths.contains("examples::metadata::test::ClientBasic")); } @@ -62,10 +62,10 @@ public void canQueryEntityMetadataByProjectVersion() public void canQueryEntityMetadataByProjectVersionPath() { Entity entity = (Entity) versionsMongo.getEntity("examples.metadata", "test", "2.2.0", "examples::metadata::test::TestProfile").get(); - Assert.assertNotNull(entity); - Assert.assertEquals("examples::metadata::test::TestProfile", entity.getPath()); - Assert.assertEquals("meta::pure::metamodel::extension::Profile", entity.getClassifierPath()); - Assert.assertEquals("examples::metadata::test", entity.getContent().get("package")); + Assertions.assertNotNull(entity); + Assertions.assertEquals("examples::metadata::test::TestProfile", entity.getPath()); + Assertions.assertEquals("meta::pure::metamodel::extension::Profile", entity.getClassifierPath()); + Assertions.assertEquals("examples::metadata::test", entity.getContent().get("package")); } @@ -73,11 +73,11 @@ public void canQueryEntityMetadataByProjectVersionPath() public void canQueryEntityMetadataByProjectVersionPackageAll() { List entities = versionsMongo.getEntitiesByPackage("examples.metadata", "test", "2.2.0", null, null, false); - Assert.assertNotNull(entities); - Assert.assertEquals(3, entities.size()); + Assertions.assertNotNull(entities); + Assertions.assertEquals(3, entities.size()); for (Entity entity : entities) { - Assert.assertTrue(entity.getContent().get("package").toString().startsWith("examples::metadata::test")); + Assertions.assertTrue(entity.getContent().get("package").toString().startsWith("examples::metadata::test")); } } @@ -85,11 +85,11 @@ public void canQueryEntityMetadataByProjectVersionPackageAll() public void canQueryEntityMetadataByProjectVersionPackage() { List entities = versionsMongo.getEntitiesByPackage("examples.metadata", "test", "2.2.0", "examples::metadata::test", null, false); - Assert.assertNotNull(entities); - Assert.assertEquals(2, entities.size()); + Assertions.assertNotNull(entities); + Assertions.assertEquals(2, entities.size()); for (Entity entity : entities) { - Assert.assertEquals("examples::metadata::test", entity.getContent().get("package")); + Assertions.assertEquals("examples::metadata::test", entity.getContent().get("package")); } } @@ -97,11 +97,11 @@ public void canQueryEntityMetadataByProjectVersionPackage() public void canQueryEntityMetadataByProjectVersionAndSubPackage() { List entities = versionsMongo.getEntitiesByPackage("examples.metadata", "test", "2.2.0", "examples::metadata::test", null, true); - Assert.assertNotNull(entities); - Assert.assertEquals(3, entities.size()); + Assertions.assertNotNull(entities); + Assertions.assertEquals(3, entities.size()); for (Entity entity : entities) { - Assert.assertTrue(entity.getContent().get("package").toString().startsWith("examples::metadata::test")); + Assertions.assertTrue(entity.getContent().get("package").toString().startsWith("examples::metadata::test")); } } @@ -115,11 +115,11 @@ public void canQueryEntityMetadataByClassifierPath() "2.2.0", "examples::metadata::test", classifiers, true); - Assert.assertNotNull(entities); - Assert.assertEquals(2, entities.size()); + Assertions.assertNotNull(entities); + Assertions.assertEquals(2, entities.size()); for (Entity entity : entities) { - Assert.assertEquals("meta::pure::metamodel::extension::Profile", entity.getClassifierPath()); + Assertions.assertEquals("meta::pure::metamodel::extension::Profile", entity.getClassifierPath()); } } @@ -127,13 +127,13 @@ public void canQueryEntityMetadataByClassifierPath() public void getMasterVersionWithoutVersionInPath() { List entities = versionsMongo.getStoredEntities("examples.metadata", "test"); - Assert.assertNotNull(entities); - Assert.assertEquals(7, entities.size()); + Assertions.assertNotNull(entities); + Assertions.assertEquals(7, entities.size()); List withoutVersions = versionsMongo.getAllEntities("examples.metadata", "test", "2.2.0"); - Assert.assertNotNull(withoutVersions); + Assertions.assertNotNull(withoutVersions); Set allPaths = withoutVersions.stream().map(Entity::getPath).collect(Collectors.toSet()); - Assert.assertTrue(allPaths.stream().noneMatch(ent -> ent.contains("v2_2_0"))); + Assertions.assertTrue(allPaths.stream().noneMatch(ent -> ent.contains("v2_2_0"))); } diff --git a/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/TestUpdateVersions.java b/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/TestUpdateVersions.java index 3f48051a6..209385f2b 100644 --- a/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/TestUpdateVersions.java +++ b/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/TestUpdateVersions.java @@ -22,9 +22,9 @@ import org.finos.legend.depot.store.mongo.TestStoreMongo; import org.finos.legend.depot.store.mongo.entities.test.EntitiesMongoTestUtils; import org.finos.legend.sdlc.domain.model.entity.Entity; -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 java.net.URL; import java.util.Arrays; @@ -42,7 +42,7 @@ public class TestUpdateVersions extends TestStoreMongo private EntitiesMongo entitiesMongo = new EntitiesMongo(mongoProvider); private final EntitiesMongoTestUtils entityUtils = new EntitiesMongoTestUtils(mongoProvider); - @Before + @BeforeEach public void setUp() { @@ -53,19 +53,19 @@ public void canStoreANewVersion() { List entitiesList = entityUtils.readEntitiesFile(ENTITIES_FILE); - Assert.assertNotNull(entitiesList); + Assertions.assertNotNull(entitiesList); StoredEntityData entity = (StoredEntityData) entitiesList.get(0); List result = entitiesMongo.createOrUpdate(Arrays.asList(entity)); - Assert.assertNotNull(result); - Assert.assertEquals(1, result.size()); + Assertions.assertNotNull(result); + Assertions.assertEquals(1, result.size()); MongoCollection entities = getMongoDatabase().getCollection(EntitiesMongo.COLLECTION); - Assert.assertNotNull(entities); - Assert.assertEquals(1, entities.countDocuments()); + Assertions.assertNotNull(entities); + Assertions.assertEquals(1, entities.countDocuments()); Document doc = (Document)entities.find().iterator().next(); - Assert.assertEquals(entity.getVersionId(), doc.getString(EntitiesMongo.VERSION_ID)); - Assert.assertEquals(entity.getEntity().getPath(), ((Map)doc.get(EntitiesMongo.ENTITY_ATTRIBUTES)).get(PATH)); - Assert.assertEquals(entity.getEntity().getClassifierPath(), ((Map)doc.get(EntitiesMongo.ENTITY_ATTRIBUTES)).get(CLASSIFIER_PATH)); + Assertions.assertEquals(entity.getVersionId(), doc.getString(EntitiesMongo.VERSION_ID)); + Assertions.assertEquals(entity.getEntity().getPath(), ((Map)doc.get(EntitiesMongo.ENTITY_ATTRIBUTES)).get(PATH)); + Assertions.assertEquals(entity.getEntity().getClassifierPath(), ((Map)doc.get(EntitiesMongo.ENTITY_ATTRIBUTES)).get(CLASSIFIER_PATH)); } @@ -73,14 +73,14 @@ public void canStoreANewVersion() public void canStoreEntitiesWithDotCharacterAsFieldContent() { List entitiesList = entityUtils.readEntitiesFile(TestUpdateVersions.class.getClassLoader().getResource("data/versioned-entity-dot-character.json")); - Assert.assertNotNull(entitiesList); + Assertions.assertNotNull(entitiesList); List result = entitiesMongo.createOrUpdate(entitiesList); - Assert.assertNotNull(result); - Assert.assertEquals(1, result.size()); + Assertions.assertNotNull(result); + Assertions.assertEquals(1, result.size()); MongoCollection entities = getMongoDatabase().getCollection(EntitiesMongo.COLLECTION); - Assert.assertNotNull(entities); - Assert.assertEquals(1, entities.countDocuments()); + Assertions.assertNotNull(entities); + Assertions.assertEquals(1, entities.countDocuments()); } @Test @@ -88,32 +88,32 @@ public void canUpdateAVersion() { List entitiesList = entityUtils.readEntitiesFile(ENTITIES_FILE); - Assert.assertNotNull(entitiesList); + Assertions.assertNotNull(entitiesList); StoredEntityData entity = (StoredEntityData) entitiesList.get(0); List result = entitiesMongo.createOrUpdate(Arrays.asList(entity)); - Assert.assertNotNull(result); - Assert.assertEquals(1, result.size()); + Assertions.assertNotNull(result); + Assertions.assertEquals(1, result.size()); MongoCollection entities = getMongoDatabase().getCollection(EntitiesMongo.COLLECTION); - Assert.assertNotNull(entities); - Assert.assertEquals(1, entities.countDocuments()); + Assertions.assertNotNull(entities); + Assertions.assertEquals(1, entities.countDocuments()); Document doc = (Document)entities.find().iterator().next(); - Assert.assertEquals(entity.getVersionId(), doc.getString(EntitiesMongo.VERSION_ID)); - Assert.assertEquals(entity.getEntity().getPath(), ((Map)doc.get(EntitiesMongo.ENTITY_ATTRIBUTES)).get(PATH)); - Assert.assertEquals(entity.getEntity().getClassifierPath(), ((Map)doc.get(EntitiesMongo.ENTITY_ATTRIBUTES)).get(CLASSIFIER_PATH)); + Assertions.assertEquals(entity.getVersionId(), doc.getString(EntitiesMongo.VERSION_ID)); + Assertions.assertEquals(entity.getEntity().getPath(), ((Map)doc.get(EntitiesMongo.ENTITY_ATTRIBUTES)).get(PATH)); + Assertions.assertEquals(entity.getEntity().getClassifierPath(), ((Map)doc.get(EntitiesMongo.ENTITY_ATTRIBUTES)).get(CLASSIFIER_PATH)); List result2 = entitiesMongo.createOrUpdate(Arrays.asList(entity)); - Assert.assertNotNull(result2); - Assert.assertEquals(1, result2.size()); - Assert.assertEquals(1, entities.countDocuments()); + Assertions.assertNotNull(result2); + Assertions.assertEquals(1, result2.size()); + Assertions.assertEquals(1, entities.countDocuments()); MongoCollection entities1 = getMongoDatabase().getCollection(EntitiesMongo.COLLECTION); - Assert.assertNotNull(entities1); - Assert.assertEquals(1, entities1.countDocuments()); + Assertions.assertNotNull(entities1); + Assertions.assertEquals(1, entities1.countDocuments()); Document doc1 = (Document)entities.find().iterator().next(); - Assert.assertEquals(entity.getVersionId(), doc1.getString(EntitiesMongo.VERSION_ID)); - Assert.assertEquals(entity.getEntity().getPath(), ((Map)doc1.get(EntitiesMongo.ENTITY_ATTRIBUTES)).get(PATH)); - Assert.assertEquals(entity.getEntity().getClassifierPath(), ((Map)doc1.get(EntitiesMongo.ENTITY_ATTRIBUTES)).get(CLASSIFIER_PATH)); + Assertions.assertEquals(entity.getVersionId(), doc1.getString(EntitiesMongo.VERSION_ID)); + Assertions.assertEquals(entity.getEntity().getPath(), ((Map)doc1.get(EntitiesMongo.ENTITY_ATTRIBUTES)).get(PATH)); + Assertions.assertEquals(entity.getEntity().getClassifierPath(), ((Map)doc1.get(EntitiesMongo.ENTITY_ATTRIBUTES)).get(CLASSIFIER_PATH)); } @@ -121,14 +121,14 @@ public void canUpdateAVersion() public void updatingSameEntityDoesNotCreateAnewONe() { List entitiesList = entityUtils.readEntitiesFile(ENTITIES_FILE); - Assert.assertNotNull(entitiesList); + Assertions.assertNotNull(entitiesList); StoredEntity entity = entitiesList.get(0); entitiesMongo.createOrUpdate(Arrays.asList(entity)); entitiesMongo.createOrUpdate(Arrays.asList(entity)); List entities = entitiesMongo.getAllEntities("examples.metadata", "test", entity.getVersionId()); - Assert.assertNotNull(entities); - Assert.assertEquals(1, entities.size()); + Assertions.assertNotNull(entities); + Assertions.assertEquals(1, entities.size()); } @@ -137,9 +137,9 @@ public void canDeleteVersion() { entityUtils.loadEntities(ENTITIES_FILE); long count = entitiesMongo.getAllEntities("examples.metadata", "test", "2.2.0").size(); - Assert.assertEquals(3, count); + Assertions.assertEquals(3, count); entitiesMongo.delete("examples.metadata", "test", "2.2.0"); - Assert.assertEquals(0, entitiesMongo.getAllEntities("examples.metadata", "test", "2.2.0").size()); + Assertions.assertEquals(0, entitiesMongo.getAllEntities("examples.metadata", "test", "2.2.0").size()); } @@ -148,16 +148,16 @@ public void canDeleteStoreEntities() { entityUtils.loadEntities(ENTITIES_FILE); long count = entitiesMongo.getStoredEntities("examples.metadata", "test").stream().count(); - Assert.assertEquals(3, count); + Assertions.assertEquals(3, count); entitiesMongo.delete("examples.metadata", "test"); - Assert.assertEquals(0, entitiesMongo.getStoredEntities("examples.metadata", "test").size()); + Assertions.assertEquals(0, entitiesMongo.getStoredEntities("examples.metadata", "test").size()); } @Test public void canCreateUpdateStoreEntities() { List entities = entityUtils.readEntitiesFile(ENTITIES_FILE); - Assert.assertEquals(3, entities.size()); + Assertions.assertEquals(3, entities.size()); //lets do a change StoredEntityData first = (StoredEntityData) entities.get(0); @@ -166,9 +166,9 @@ public void canCreateUpdateStoreEntities() entitiesMongo.createOrUpdate(entities); Optional found = entitiesMongo.getEntity(first.getGroupId(),first.getArtifactId(),first.getVersionId(),first.getEntity().getPath()); - Assert.assertTrue(found.isPresent()); - Assert.assertTrue(found.get().getContent().containsKey("new")); - Assert.assertEquals("stuff",found.get().getContent().get("new")); + Assertions.assertTrue(found.isPresent()); + Assertions.assertTrue(found.get().getContent().containsKey("new")); + Assertions.assertEquals("stuff",found.get().getContent().get("new")); } } diff --git a/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/test/EntitiesMongoTestUtils.java b/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/test/EntitiesMongoTestUtils.java index d837cfba7..5a9d839ab 100644 --- a/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/test/EntitiesMongoTestUtils.java +++ b/legend-depot-entities-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/entities/test/EntitiesMongoTestUtils.java @@ -23,7 +23,7 @@ import org.bson.Document; import org.finos.legend.depot.store.model.entities.StoredEntity; import org.finos.legend.depot.store.mongo.entities.EntitiesMongo; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import java.io.InputStream; import java.net.URL; @@ -54,12 +54,12 @@ public List readEntitiesFile(URL fileName) List entities = new ObjectMapper().readValue(jsonInput, new TypeReference>() { }); - Assert.assertNotNull("testing file" + fileName.getFile(), entities); + Assertions.assertNotNull(entities, "testing file" + fileName.getFile()); return entities; } catch (Exception e) { - Assert.fail("an error has occurred loading test versioned entity metadata" + e.getMessage()); + Assertions.fail("an error has occurred loading test versioned entity metadata" + e.getMessage()); } return null; } @@ -68,7 +68,7 @@ public void loadEntities(URL entitiesFile) { try { - Assert.assertNotNull(getMongoEntities()); + Assertions.assertNotNull(getMongoEntities()); readEntitiesFile(entitiesFile).forEach(entity -> { try @@ -77,13 +77,13 @@ public void loadEntities(URL entitiesFile) } catch (JsonProcessingException e) { - Assert.fail("an error has occurred loading test entity" + e.getMessage()); + Assertions.fail("an error has occurred loading test entity" + e.getMessage()); } }); } catch (Exception e) { - Assert.fail("an error has occurred loading test entity" + e.getMessage()); + Assertions.fail("an error has occurred loading test entity" + e.getMessage()); } } diff --git a/legend-depot-generations-api/src/test/java/org/finos/legend/depot/services/generations/loader/TestFileGenerationLoader.java b/legend-depot-generations-api/src/test/java/org/finos/legend/depot/services/generations/loader/TestFileGenerationLoader.java index 1d0756172..14ac874fe 100644 --- a/legend-depot-generations-api/src/test/java/org/finos/legend/depot/services/generations/loader/TestFileGenerationLoader.java +++ b/legend-depot-generations-api/src/test/java/org/finos/legend/depot/services/generations/loader/TestFileGenerationLoader.java @@ -16,8 +16,8 @@ package org.finos.legend.depot.services.generations.loader; import org.finos.legend.depot.domain.generation.DepotGeneration; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.File; import java.net.URISyntaxException; @@ -34,10 +34,10 @@ public class TestFileGenerationLoader public void canReadFileGenerationArtifacts() throws URISyntaxException { List generations = FileGenerationLoader.newFileGenerationsLoader(new File(filePath.toURI())).getAllFileGenerations().collect(Collectors.toList()); - Assert.assertNotNull(generations); - Assert.assertEquals(14, generations.size()); + Assertions.assertNotNull(generations); + Assertions.assertEquals(14, generations.size()); DepotGeneration generation = generations.get(0); - Assert.assertFalse(generation.getContent().isEmpty()); + Assertions.assertFalse(generation.getContent().isEmpty()); } } diff --git a/legend-depot-generations-services/src/test/java/org/finos/legend/depot/services/generations/TestFileGenerationsService.java b/legend-depot-generations-services/src/test/java/org/finos/legend/depot/services/generations/TestFileGenerationsService.java index ff9d554ba..adadac912 100644 --- a/legend-depot-generations-services/src/test/java/org/finos/legend/depot/services/generations/TestFileGenerationsService.java +++ b/legend-depot-generations-services/src/test/java/org/finos/legend/depot/services/generations/TestFileGenerationsService.java @@ -32,9 +32,9 @@ import org.finos.legend.depot.store.mongo.TestStoreMongo; import org.finos.legend.depot.store.mongo.generations.FileGenerationsMongo; import org.finos.legend.depot.services.api.notifications.queue.Queue; -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 java.io.File; import java.net.URL; @@ -61,14 +61,14 @@ public class TestFileGenerationsService extends TestStoreMongo private ProjectsService projectsService = new ProjectsServiceImpl(projectsVersionsStore, projectsStore, metrics, queue, new ProjectsConfiguration("master")); private ManageFileGenerationsService service = new ManageFileGenerationsServiceImpl(generations, projectsService); - @Before + @BeforeEach public void loadData() throws Exception { try (FileGenerationLoader file = FileGenerationLoader.newFileGenerationsLoader(new File(filePath.toURI()))) { Stream data = file.getAllFileGenerations(); - Assert.assertNotNull(data); + Assertions.assertNotNull(data); data.forEach(gen -> { if (gen.getPath().startsWith("/examples/metadata")) @@ -88,7 +88,7 @@ public void loadData() throws Exception } }); - Assert.assertEquals(54, generations.getAll().size()); + Assertions.assertEquals(54, generations.getAll().size()); } when(projectsStore.find("group.test","test")).thenReturn(Optional.of(new StoreProjectData("prod-1","group.test","test",null,"1.0.0"))); @@ -105,19 +105,19 @@ public void canDelete() { service.delete("group.test", "test",BRANCH_SNAPSHOT("master")); - Assert.assertEquals(40, generations.getAll().size()); + Assertions.assertEquals(40, generations.getAll().size()); service.delete("group.test.otherproject", "test", "1.0.0"); - Assert.assertEquals(26, generations.getAll().size()); + Assertions.assertEquals(26, generations.getAll().size()); try { service.delete("group.test", "test111", "1.1.0"); - Assert.fail("exception expected"); + Assertions.fail("exception expected"); } catch (IllegalArgumentException e) { - Assert.assertTrue(true); + Assertions.assertTrue(true); } - Assert.assertEquals(26, generations.getAll().size()); + Assertions.assertEquals(26, generations.getAll().size()); } @@ -126,70 +126,70 @@ public void canQueryFileGenerationEntities() { List generations = service.getFileGenerations("group.test", "test",BRANCH_SNAPSHOT("master")); - Assert.assertEquals(14, generations.size()); + Assertions.assertEquals(14, generations.size()); List gens1 = service.getFileGenerations("group.test", "test", "1.0.0"); - Assert.assertEquals(14, gens1.size()); + Assertions.assertEquals(14, gens1.size()); try { List gens2 = service.getFileGenerations("group.test.other", "test", "1.0.0"); - Assert.fail("Exception expected"); + Assertions.fail("Exception expected"); } catch (IllegalArgumentException e) { - Assert.assertTrue(true); + Assertions.assertTrue(true); } } @Test public void canQueryFileGenerationEntitiesByElementPath() { - Assert.assertEquals(12, service.getFileGenerationsByElementPath("group.test", "test", "1.0.0", "examples::avrogen").size()); - Assert.assertTrue(service.getFileGenerationsByElementPath("group.test", "test", "1.0.0", "examples::avrogen1").isEmpty()); - Assert.assertEquals(2, service.getFileGenerationsByElementPath("group.test", "test", "1.0.0", "examples::metadata::test::ClientBasic").size()); + Assertions.assertEquals(12, service.getFileGenerationsByElementPath("group.test", "test", "1.0.0", "examples::avrogen").size()); + Assertions.assertTrue(service.getFileGenerationsByElementPath("group.test", "test", "1.0.0", "examples::avrogen1").isEmpty()); + Assertions.assertEquals(2, service.getFileGenerationsByElementPath("group.test", "test", "1.0.0", "examples::metadata::test::ClientBasic").size()); } @Test public void canGetByType() { List fileGenerations = service.findByType("group.test", "test", "1.0.0", AVRO); - Assert.assertEquals(12, fileGenerations.size()); - Assert.assertEquals(0, service.findByTypeAndElementPath("group.test", "test", "1.0.0", AVRO, "element::NotFound").size()); - Assert.assertEquals(12, service.findByTypeAndElementPath("group.test", "test", "1.0.0", AVRO, "examples::avrogen").size()); + Assertions.assertEquals(12, fileGenerations.size()); + Assertions.assertEquals(0, service.findByTypeAndElementPath("group.test", "test", "1.0.0", AVRO, "element::NotFound").size()); + Assertions.assertEquals(12, service.findByTypeAndElementPath("group.test", "test", "1.0.0", AVRO, "examples::avrogen").size()); } @Test public void canQueryFileGenerationEntitiesByFilePath() { - Assert.assertTrue(service.getFileGenerationsByFilePath("group.test", "test", "1.0.0", "/examples/metadata/test/ClientBasic.avro").isPresent()); - Assert.assertTrue(service.getFileGenerationsByFilePath("group.test", "test", "1.0.0", "/examples/metadata/test/ClientBasic/my-ext/Output1.txt").isPresent()); - Assert.assertTrue(service.getFileGenerationsByFilePath("group.test", "test", "1.0.0", "/examples/metadata/test/ClientBasic/my-ext/Output2.txt").isPresent()); - Assert.assertTrue(service.getFileGenerationsByFilePath("group.test.otherproject", "test", "1.0.0", "/examples/metadata/test/ClientBasic.avro").isPresent()); + Assertions.assertTrue(service.getFileGenerationsByFilePath("group.test", "test", "1.0.0", "/examples/metadata/test/ClientBasic.avro").isPresent()); + Assertions.assertTrue(service.getFileGenerationsByFilePath("group.test", "test", "1.0.0", "/examples/metadata/test/ClientBasic/my-ext/Output1.txt").isPresent()); + Assertions.assertTrue(service.getFileGenerationsByFilePath("group.test", "test", "1.0.0", "/examples/metadata/test/ClientBasic/my-ext/Output2.txt").isPresent()); + Assertions.assertTrue(service.getFileGenerationsByFilePath("group.test.otherproject", "test", "1.0.0", "/examples/metadata/test/ClientBasic.avro").isPresent()); - Assert.assertFalse(service.getFileGenerationsByFilePath("group.test", "test", "1.0.0", "bad").isPresent()); - Assert.assertFalse(service.getFileGenerationsByFilePath("group.test", "test", "1.0.0", "/examples/metadata/test/ClientBasic/my-ext/DND.txt").isPresent()); + Assertions.assertFalse(service.getFileGenerationsByFilePath("group.test", "test", "1.0.0", "bad").isPresent()); + Assertions.assertFalse(service.getFileGenerationsByFilePath("group.test", "test", "1.0.0", "/examples/metadata/test/ClientBasic/my-ext/DND.txt").isPresent()); } @Test public void canQueryFileGenerationEntitiesByFileContent() { - Assert.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "1.0.0", "/examples/metadata/test/ClientBasic.avro").isPresent()); - Assert.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "1.0.0", "/examples/metadata/test/ClientBasic/my-ext/Output1.txt").isPresent()); - Assert.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "1.0.0", "/examples/metadata/test/ClientBasic/my-ext/Output2.txt").isPresent()); - Assert.assertTrue(service.getFileGenerationsByFilePath("group.test", "test",BRANCH_SNAPSHOT("master"), "/examples/metadata/test/ClientBasic.avro").isPresent()); + Assertions.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "1.0.0", "/examples/metadata/test/ClientBasic.avro").isPresent()); + Assertions.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "1.0.0", "/examples/metadata/test/ClientBasic/my-ext/Output1.txt").isPresent()); + Assertions.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "1.0.0", "/examples/metadata/test/ClientBasic/my-ext/Output2.txt").isPresent()); + Assertions.assertTrue(service.getFileGenerationsByFilePath("group.test", "test",BRANCH_SNAPSHOT("master"), "/examples/metadata/test/ClientBasic.avro").isPresent()); } - @Test(expected = IllegalArgumentException.class) + @Test public void cantGetGenerationsForNonExistentProject() { - service.getFileGenerations("i.dont","exist","version"); + Assertions.assertThrows(IllegalArgumentException.class, () -> service.getFileGenerations("i.dont","exist","version")); } - @Test(expected = IllegalArgumentException.class) + @Test public void cantGetGenerationsForNonExistentVersion() { - service.getFileGenerations("group.test","test","10.0.0"); + Assertions.assertThrows(IllegalArgumentException.class, () -> service.getFileGenerations("group.test","test","10.0.0")); } @Test @@ -197,12 +197,12 @@ public void canQueryFileGenerationEntitiesWithLatestAlias() { List gens1 = service.getFileGenerations("group.test", "test", "latest"); - Assert.assertEquals(14, gens1.size()); - Assert.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "latest", "/examples/metadata/test/ClientBasic.avro").isPresent()); - Assert.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "latest", "/examples/metadata/test/ClientBasic/my-ext/Output1.txt").isPresent()); - Assert.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "latest", "/examples/metadata/test/ClientBasic/my-ext/Output2.txt").isPresent()); - Assert.assertEquals(2, service.getFileGenerationsByElementPath("group.test", "test", "latest", "examples::metadata::test::ClientBasic").size()); - Assert.assertEquals(12, service.getFileGenerationsByElementPath("group.test", "test", "latest", "examples::avrogen").size()); + Assertions.assertEquals(14, gens1.size()); + Assertions.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "latest", "/examples/metadata/test/ClientBasic.avro").isPresent()); + Assertions.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "latest", "/examples/metadata/test/ClientBasic/my-ext/Output1.txt").isPresent()); + Assertions.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "latest", "/examples/metadata/test/ClientBasic/my-ext/Output2.txt").isPresent()); + Assertions.assertEquals(2, service.getFileGenerationsByElementPath("group.test", "test", "latest", "examples::metadata::test::ClientBasic").size()); + Assertions.assertEquals(12, service.getFileGenerationsByElementPath("group.test", "test", "latest", "examples::avrogen").size()); } @Test @@ -210,9 +210,9 @@ public void canQueryFileGenerationEntitiesWithHeadAlias() { List gens1 = service.getFileGenerations("group.test", "test", "head"); - Assert.assertEquals(14, gens1.size()); - Assert.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "head", "/examples/metadata/test/ClientBasic.avro").isPresent()); - Assert.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "head", "/examples/metadata/test/ClientBasic/my-ext/Output1.txt").isPresent()); - Assert.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "head", "/examples/metadata/test/ClientBasic/my-ext/Output2.txt").isPresent()); + Assertions.assertEquals(14, gens1.size()); + Assertions.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "head", "/examples/metadata/test/ClientBasic.avro").isPresent()); + Assertions.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "head", "/examples/metadata/test/ClientBasic/my-ext/Output1.txt").isPresent()); + Assertions.assertTrue(service.getFileGenerationContentByFilePath("group.test", "test", "head", "/examples/metadata/test/ClientBasic/my-ext/Output2.txt").isPresent()); } } \ No newline at end of file diff --git a/legend-depot-generations-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/generations/TestFileGenerationsStore.java b/legend-depot-generations-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/generations/TestFileGenerationsStore.java index 1234ae769..fdbe08b85 100644 --- a/legend-depot-generations-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/generations/TestFileGenerationsStore.java +++ b/legend-depot-generations-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/generations/TestFileGenerationsStore.java @@ -17,9 +17,9 @@ import org.finos.legend.depot.store.model.generations.StoredFileGeneration; import org.finos.legend.depot.store.api.generations.UpdateFileGenerations; -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 java.util.List; @@ -33,11 +33,11 @@ public class TestFileGenerationsStore extends TestGenerationsStoreMongo private static String TEST_ARTIFACT_ID = "test"; - @Before + @BeforeEach public void loadData() { setUpFileGenerationFromFile(this.getClass().getClassLoader().getResource("data/file-generations.json"),mongoProvider); - Assert.assertEquals(11, generations.getAll().size()); + Assertions.assertEquals(11, generations.getAll().size()); } @@ -45,9 +45,9 @@ public void loadData() public void canQueryByVersion() { List result = generations.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.3.3"); - Assert.assertEquals(11, result.size()); + Assertions.assertEquals(11, result.size()); - Assert.assertEquals(0, generations.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "12.3.2").size()); + Assertions.assertEquals(0, generations.find(TEST_GROUP_ID, TEST_ARTIFACT_ID, "12.3.2").size()); } @@ -55,36 +55,36 @@ public void canQueryByVersion() public void canQueryByElementPath() { List result = generations.findByElementPath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.3.3", "com::avrogen"); - Assert.assertEquals(3, result.size()); + Assertions.assertEquals(3, result.size()); - Assert.assertEquals(0, generations.findByElementPath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "12.3.2", "com::avrogen").size()); - Assert.assertEquals(0, generations.findByElementPath(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master"), "com::jsonGen").size()); + Assertions.assertEquals(0, generations.findByElementPath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "12.3.2", "com::avrogen").size()); + Assertions.assertEquals(0, generations.findByElementPath(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master"), "com::jsonGen").size()); List result2 = generations.findByElementPath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.3.3", "com::avrogen"); - Assert.assertEquals(3, result2.size()); + Assertions.assertEquals(3, result2.size()); List result3 = generations.findByElementPath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.3.3", "com::MyElementPath"); - Assert.assertEquals(1, result3.size()); + Assertions.assertEquals(1, result3.size()); } @Test public void canQueryByGenerationType() { List result = generations.findByType(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.3.3", "avro"); - Assert.assertEquals(3, result.size()); + Assertions.assertEquals(3, result.size()); - Assert.assertEquals(0, generations.findByType(TEST_GROUP_ID, TEST_ARTIFACT_ID, "12.3.2", "java").size()); - Assert.assertEquals(0, generations.findByType(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master"), "java").size()); + Assertions.assertEquals(0, generations.findByType(TEST_GROUP_ID, TEST_ARTIFACT_ID, "12.3.2", "java").size()); + Assertions.assertEquals(0, generations.findByType(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master"), "java").size()); } @Test public void canQueryByGenerationFilePath() { - Assert.assertTrue(generations.findByFilePath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.3.3", "/examples/metadata/test/ClientBasic.avro").isPresent()); - Assert.assertTrue(generations.findByFilePath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.3.3", "/examples/generated/test/other/MyOutput.json").isPresent()); - Assert.assertFalse(generations.findByFilePath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "0.01.1", "/examples/metadata/test/ClientBasic.avro").isPresent()); - Assert.assertFalse(generations.findByFilePath(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master"), "com/finos/sdgashdf").isPresent()); + Assertions.assertTrue(generations.findByFilePath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.3.3", "/examples/metadata/test/ClientBasic.avro").isPresent()); + Assertions.assertTrue(generations.findByFilePath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "2.3.3", "/examples/generated/test/other/MyOutput.json").isPresent()); + Assertions.assertFalse(generations.findByFilePath(TEST_GROUP_ID, TEST_ARTIFACT_ID, "0.01.1", "/examples/metadata/test/ClientBasic.avro").isPresent()); + Assertions.assertFalse(generations.findByFilePath(TEST_GROUP_ID, TEST_ARTIFACT_ID, BRANCH_SNAPSHOT("master"), "com/finos/sdgashdf").isPresent()); } } diff --git a/legend-depot-generations-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/generations/TestGenerationsStoreMongo.java b/legend-depot-generations-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/generations/TestGenerationsStoreMongo.java index 0ac504711..b4505f94a 100644 --- a/legend-depot-generations-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/generations/TestGenerationsStoreMongo.java +++ b/legend-depot-generations-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/generations/TestGenerationsStoreMongo.java @@ -23,7 +23,7 @@ import org.bson.Document; import org.finos.legend.depot.store.model.generations.StoredFileGeneration; import org.finos.legend.depot.store.mongo.TestStoreMongo; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import java.io.InputStream; import java.net.URL; @@ -41,12 +41,12 @@ private static List readGenerationsFile(URL fileName) List generations = new ObjectMapper().readValue(jsonInput, new TypeReference>() { }); - Assert.assertNotNull("testing file" + fileName.getFile(), generations); + Assertions.assertNotNull(generations, "testing file" + fileName.getFile()); return generations; } catch (Exception e) { - Assert.fail("an error has occurred loading test metadata" + e.getMessage()); + Assertions.fail("an error has occurred loading test metadata" + e.getMessage()); } return null; } @@ -55,7 +55,7 @@ public static void setUpFileGenerationFromFile(URL generationsData, MongoDatabas { try { - Assert.assertNotNull(getMongoFileGenerations(database)); + Assertions.assertNotNull(getMongoFileGenerations(database)); readGenerationsFile(generationsData).forEach(project -> { try @@ -64,14 +64,14 @@ public static void setUpFileGenerationFromFile(URL generationsData, MongoDatabas } catch (JsonProcessingException e) { - Assert.fail("an error has occurred loading test project metadata" + e.getMessage()); + Assertions.fail("an error has occurred loading test project metadata" + e.getMessage()); } }); } catch (Exception e) { - Assert.fail("an error has occurred loading test project metadata" + e.getMessage()); + Assertions.fail("an error has occurred loading test project metadata" + e.getMessage()); } } diff --git a/legend-depot-metrics-query-services/src/test/java/org/finos/legend/depot/services/metrics/query/TestMetricsServices.java b/legend-depot-metrics-query-services/src/test/java/org/finos/legend/depot/services/metrics/query/TestMetricsServices.java index 3de95183e..24130a00d 100644 --- a/legend-depot-metrics-query-services/src/test/java/org/finos/legend/depot/services/metrics/query/TestMetricsServices.java +++ b/legend-depot-metrics-query-services/src/test/java/org/finos/legend/depot/services/metrics/query/TestMetricsServices.java @@ -21,10 +21,10 @@ import org.finos.legend.depot.store.model.metrics.query.VersionQueryMetric; import org.finos.legend.depot.store.mongo.metrics.query.QueryMetricsMongo; import org.finos.legend.depot.store.mongo.TestStoreMongo; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -50,7 +50,7 @@ public class TestMetricsServices extends TestStoreMongo private QueryMetricsService metricsHandler = new QueryMetricsServiceImpl(metricsStore); - @Before + @BeforeEach public void setup() throws InterruptedException { @@ -62,7 +62,7 @@ public void setup() throws InterruptedException metricsStore.insert(new VersionQueryMetric("group1", "art1", "1.0.0")); } - @After + @AfterEach public void tearDown() { metricsStore.getCollection().drop(); @@ -73,41 +73,41 @@ public void tearDown() public void canGetMetricsSummary() { Optional metrics = metricsHandler.getSummary("group1", "art1", "2.2.0"); - Assert.assertTrue(metrics.isPresent()); - Assert.assertEquals("2.2.0", metrics.get().getVersionId()); + Assertions.assertTrue(metrics.isPresent()); + Assertions.assertEquals("2.2.0", metrics.get().getVersionId()); } @Test public void canFindMetricsUsingProjectCoordinates() { List metrics = metricsHandler.findMetricsForProjectCoordinates("group1", "art1"); - Assert.assertEquals(4, metrics.size()); + Assertions.assertEquals(4, metrics.size()); Set versionsUsed = metrics.stream().map(metric -> metric.getVersionId()).collect(Collectors.toSet()); - Assert.assertEquals(2, versionsUsed.size()); + Assertions.assertEquals(2, versionsUsed.size()); - Assert.assertTrue(versionsUsed.contains("1.0.0")); - Assert.assertTrue(versionsUsed.contains("2.2.0")); - Assert.assertFalse(versionsUsed.contains("master-SNAPSHOT")); + Assertions.assertTrue(versionsUsed.contains("1.0.0")); + Assertions.assertTrue(versionsUsed.contains("2.2.0")); + Assertions.assertFalse(versionsUsed.contains("master-SNAPSHOT")); } @Test public void canGetAllStoredCoordinates() { List projectVersions = metricsStore.getAllStoredEntitiesCoordinates(); - Assert.assertEquals(2, projectVersions.size()); - Assert.assertEquals(Arrays.asList(new ProjectVersion("group1", "art1", "1.0.0"),new ProjectVersion("group1", "art1", "2.2.0")), projectVersions); + Assertions.assertEquals(2, projectVersions.size()); + Assertions.assertEquals(Arrays.asList(new ProjectVersion("group1", "art1", "1.0.0"),new ProjectVersion("group1", "art1", "2.2.0")), projectVersions); } @Test public void canGetMostRecentlyQueriedMetrics() { - Assert.assertEquals(4, metricsStore.getAllStoredEntities().size()); + Assertions.assertEquals(4, metricsStore.getAllStoredEntities().size()); List metrics = metricsHandler.getSummaryByProjectVersion(); - Assert.assertEquals(2, metrics.size()); - Assert.assertEquals("1.0.0", metrics.get(0).getVersionId()); - Assert.assertEquals("2.2.0", metrics.get(1).getVersionId()); + Assertions.assertEquals(2, metrics.size()); + Assertions.assertEquals("1.0.0", metrics.get(0).getVersionId()); + Assertions.assertEquals("2.2.0", metrics.get(1).getVersionId()); } @Test @@ -117,20 +117,20 @@ public void canConsolidateQueryMetrics() throws InterruptedException Thread.sleep(10); metricsRegistry.record("group1", "art1", "3.0.0"); metricsHandler.persist(metricsRegistry); - Assert.assertEquals(6, metricsStore.getAllStoredEntities().size()); + Assertions.assertEquals(6, metricsStore.getAllStoredEntities().size()); List summary = metricsHandler.getSummaryByProjectVersion(); metricsHandler.consolidateMetrics(); List metrics = metricsStore.getAllStoredEntities(); - Assert.assertEquals(3, metrics.size()); - Assert.assertEquals("2.2.0", metrics.get(0).getVersionId()); - Assert.assertEquals("2.2.0", summary.get(1).getVersionId()); - Assert.assertEquals(summary.get(1).getLastQueryTime(), metrics.get(0).getLastQueryTime()); - Assert.assertEquals("1.0.0", metrics.get(1).getVersionId()); - Assert.assertEquals("1.0.0", summary.get(0).getVersionId()); - Assert.assertEquals(summary.get(0).getLastQueryTime(), metrics.get(1).getLastQueryTime()); - Assert.assertEquals("3.0.0", metrics.get(2).getVersionId()); - Assert.assertEquals("3.0.0", summary.get(2).getVersionId()); - Assert.assertEquals(summary.get(2).getLastQueryTime(), metrics.get(2).getLastQueryTime()); + Assertions.assertEquals(3, metrics.size()); + Assertions.assertEquals("2.2.0", metrics.get(0).getVersionId()); + Assertions.assertEquals("2.2.0", summary.get(1).getVersionId()); + Assertions.assertEquals(summary.get(1).getLastQueryTime(), metrics.get(0).getLastQueryTime()); + Assertions.assertEquals("1.0.0", metrics.get(1).getVersionId()); + Assertions.assertEquals("1.0.0", summary.get(0).getVersionId()); + Assertions.assertEquals(summary.get(0).getLastQueryTime(), metrics.get(1).getLastQueryTime()); + Assertions.assertEquals("3.0.0", metrics.get(2).getVersionId()); + Assertions.assertEquals("3.0.0", summary.get(2).getVersionId()); + Assertions.assertEquals(summary.get(2).getLastQueryTime(), metrics.get(2).getLastQueryTime()); } @Test @@ -139,24 +139,24 @@ public void canConsolidateMetricsAtDiffDates() metricsStore.insert(new VersionQueryMetric("group1", "art1", "3.0.0", toDate(LocalDateTime.parse("2023-03-22T14:02:49", DateTimeFormatter.ISO_DATE_TIME)))); metricsStore.insert(new VersionQueryMetric("group1", "art1", "3.0.0", toDate(LocalDateTime.parse("2023-03-21T14:02:49", DateTimeFormatter.ISO_DATE_TIME)))); - Assert.assertEquals(6, metricsStore.getAllStoredEntities().size()); + Assertions.assertEquals(6, metricsStore.getAllStoredEntities().size()); metricsHandler.consolidateMetrics(); List metrics = metricsStore.getAllStoredEntities(); - Assert.assertEquals(3, metrics.size()); - Assert.assertEquals("3.0.0", metrics.get(2).getVersionId()); - Assert.assertEquals(toDate(LocalDateTime.parse("2023-03-22T14:02:49", DateTimeFormatter.ISO_DATE_TIME)), metrics.get(2).getLastQueryTime()); + Assertions.assertEquals(3, metrics.size()); + Assertions.assertEquals("3.0.0", metrics.get(2).getVersionId()); + Assertions.assertEquals(toDate(LocalDateTime.parse("2023-03-22T14:02:49", DateTimeFormatter.ISO_DATE_TIME)), metrics.get(2).getLastQueryTime()); } @Test public void canPersistMetrics() throws InterruptedException { - Assert.assertEquals(4, metricsStore.getAllStoredEntities().size()); + Assertions.assertEquals(4, metricsStore.getAllStoredEntities().size()); metricsRegistry.record("group1", "art1", "3.0.0"); Thread.sleep(10); metricsRegistry.record("group1", "art1", "3.0.0"); metricsRegistry.record("group1", "art1", "2.0.0"); metricsHandler.persist(metricsRegistry); - Assert.assertEquals(7, metricsStore.getAllStoredEntities().size()); + Assertions.assertEquals(7, metricsStore.getAllStoredEntities().size()); } @Test @@ -183,8 +183,8 @@ public void testMetricsForThreadSafety() throws ExecutionException, InterruptedE executorService.submit(recordTask3); Future returnedElement = executorService.submit(pollTask); Thread.sleep(10); - Assert.assertEquals(returnedElement.get().getGroupId(), "examples.metadata"); - Assert.assertEquals(returnedElement.get().getArtifactId(), "test"); - Assert.assertEquals(returnedElement.get().getVersionId(), "2.0.0"); + Assertions.assertEquals(returnedElement.get().getGroupId(), "examples.metadata"); + Assertions.assertEquals(returnedElement.get().getArtifactId(), "test"); + Assertions.assertEquals(returnedElement.get().getVersionId(), "2.0.0"); } } diff --git a/legend-depot-model/src/test/java/org/finos/legend/depot/domain/DatesHandlerTest.java b/legend-depot-model/src/test/java/org/finos/legend/depot/domain/DatesHandlerTest.java index 83d498c9e..534c66ae5 100644 --- a/legend-depot-model/src/test/java/org/finos/legend/depot/domain/DatesHandlerTest.java +++ b/legend-depot-model/src/test/java/org/finos/legend/depot/domain/DatesHandlerTest.java @@ -15,8 +15,8 @@ package org.finos.legend.depot.domain; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -29,7 +29,7 @@ public void canGetEventByEpocMillis() LocalDateTime date = DatesHandler.parseDate("1679411706436"); LocalDateTime lunchTime = LocalDateTime.parse("2023-03-21T14:02:49", DateTimeFormatter.ISO_DATE_TIME); - Assert.assertNotNull(date); + Assertions.assertNotNull(date); } } diff --git a/legend-depot-model/src/test/java/org/finos/legend/depot/domain/version/TestVersionValidator.java b/legend-depot-model/src/test/java/org/finos/legend/depot/domain/version/TestVersionValidator.java index 302af5757..154968360 100644 --- a/legend-depot-model/src/test/java/org/finos/legend/depot/domain/version/TestVersionValidator.java +++ b/legend-depot-model/src/test/java/org/finos/legend/depot/domain/version/TestVersionValidator.java @@ -15,8 +15,8 @@ package org.finos.legend.depot.domain.version; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import static org.finos.legend.depot.domain.version.VersionValidator.BRANCH_SNAPSHOT; @@ -25,10 +25,10 @@ public class TestVersionValidator @Test public void testVersionsAreCorrect() { - Assert.assertTrue(VersionValidator.isValid("1.1.1")); - Assert.assertTrue(VersionValidator.isValid(BRANCH_SNAPSHOT("master"))); - Assert.assertFalse(VersionValidator.isValid("jkwhfkjasf-jhdfjks")); - Assert.assertTrue(VersionValidator.isValid("my-SNAPSHOT")); + Assertions.assertTrue(VersionValidator.isValid("1.1.1")); + Assertions.assertTrue(VersionValidator.isValid(BRANCH_SNAPSHOT("master"))); + Assertions.assertFalse(VersionValidator.isValid("jkwhfkjasf-jhdfjks")); + Assertions.assertTrue(VersionValidator.isValid("my-SNAPSHOT")); } } diff --git a/legend-depot-notifications-queue-mongo/src/test/java/org/finos/legend/depot/store/mongo/notifications/queue/TestQueueMongo.java b/legend-depot-notifications-queue-mongo/src/test/java/org/finos/legend/depot/store/mongo/notifications/queue/TestQueueMongo.java index 0f63c476b..240ff1a4e 100644 --- a/legend-depot-notifications-queue-mongo/src/test/java/org/finos/legend/depot/store/mongo/notifications/queue/TestQueueMongo.java +++ b/legend-depot-notifications-queue-mongo/src/test/java/org/finos/legend/depot/store/mongo/notifications/queue/TestQueueMongo.java @@ -21,8 +21,8 @@ import org.finos.legend.depot.services.api.notifications.queue.Queue; import org.finos.legend.depot.store.mongo.TestStoreMongo; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.Date; import java.util.List; @@ -53,8 +53,8 @@ public void canQueryContentsOfQueue() queue.push(event3); List inQueue = queue.getAll(); - Assert.assertNotNull(inQueue); - Assert.assertEquals(4, inQueue.size()); + Assertions.assertNotNull(inQueue); + Assertions.assertEquals(4, inQueue.size()); } @Test @@ -64,13 +64,13 @@ public void canRetrieveEventByIdInQueue() queue.push(event); List eventList = queue.getAll(); - Assert.assertNotNull(eventList); - Assert.assertEquals(1, eventList.size()); - Assert.assertNotNull(eventList.get(0).getEventId()); + Assertions.assertNotNull(eventList); + Assertions.assertEquals(1, eventList.size()); + Assertions.assertNotNull(eventList.get(0).getEventId()); MetadataNotification foundEvent = queue.get(eventList.get(0).getEventId()).get(); - Assert.assertNotNull(foundEvent); - Assert.assertEquals(eventList.get(0).getEventId(), foundEvent.getEventId()); + Assertions.assertNotNull(foundEvent); + Assertions.assertEquals(eventList.get(0).getEventId(), foundEvent.getEventId()); } @Test @@ -80,15 +80,15 @@ public void canStoreErrors() queue.push(event.addError("this is an error")); List eventList = queue.getAll(); - Assert.assertNotNull(eventList); - Assert.assertEquals(1, eventList.size()); - Assert.assertNotNull(eventList.get(0).getEventId()); + Assertions.assertNotNull(eventList); + Assertions.assertEquals(1, eventList.size()); + Assertions.assertNotNull(eventList.get(0).getEventId()); MetadataNotification foundEvent = queue.get(eventList.get(0).getEventId()).get(); - Assert.assertNotNull(foundEvent); - Assert.assertEquals(eventList.get(0).getEventId(), foundEvent.getEventId()); - Assert.assertNotNull(eventList.get(0).getCurrentResponse().getErrors()); - Assert.assertEquals(1, eventList.get(0).getCurrentResponse().getErrors().size()); + Assertions.assertNotNull(foundEvent); + Assertions.assertEquals(eventList.get(0).getEventId(), foundEvent.getEventId()); + Assertions.assertNotNull(eventList.get(0).getCurrentResponse().getErrors()); + Assertions.assertEquals(1, eventList.get(0).getCurrentResponse().getErrors().size()); } @@ -98,10 +98,10 @@ public void doesNotInsertDuplicateEvents() { MetadataNotification event = new MetadataNotification(TESTPROJECT, TEST, TEST,VERSION); String id = queue.push(event); - Assert.assertNotNull(id); + Assertions.assertNotNull(id); String id2 = queue.push(event); - Assert.assertNotNull(id2); - Assert.assertEquals(id, id2); + Assertions.assertNotNull(id2); + Assertions.assertEquals(id, id2); } @Test @@ -112,9 +112,9 @@ public void canGetFirstInQueue() queue.push(event); queue.push(event1); - Assert.assertTrue(queue.getFirstInQueue().isPresent()); - Assert.assertTrue(queue.getFirstInQueue().isPresent()); - Assert.assertFalse(queue.getFirstInQueue().isPresent()); + Assertions.assertTrue(queue.getFirstInQueue().isPresent()); + Assertions.assertTrue(queue.getFirstInQueue().isPresent()); + Assertions.assertFalse(queue.getFirstInQueue().isPresent()); } @@ -130,9 +130,9 @@ public void canGetFirstInQueueByFIFO() Optional first = queue.getFirstInQueue(); Optional second = queue.getFirstInQueue(); - Assert.assertEquals(VERSION,first.get().getVersionId()); - Assert.assertEquals("1.0.1",second.get().getVersionId()); - Assert.assertTrue(first.get().getCreated().before(second.get().getCreated())); + Assertions.assertEquals(VERSION,first.get().getVersionId()); + Assertions.assertEquals("1.0.1",second.get().getVersionId()); + Assertions.assertTrue(first.get().getCreated().before(second.get().getCreated())); } @Test @@ -146,8 +146,8 @@ public void canGetFirstInQueueByPriority() Optional first = queue.getFirstInQueue(); Optional second = queue.getFirstInQueue(); - Assert.assertEquals("1.0.1", first.get().getVersionId()); - Assert.assertEquals(VERSION, second.get().getVersionId()); + Assertions.assertEquals("1.0.1", first.get().getVersionId()); + Assertions.assertEquals(VERSION, second.get().getVersionId()); } @Test @@ -161,8 +161,8 @@ public void canGetFirstInQueueBySamePriorityWithDifferentCreatedTime() Optional first = queue.getFirstInQueue(); Optional second = queue.getFirstInQueue(); - Assert.assertEquals(VERSION, first.get().getVersionId()); - Assert.assertEquals("1.0.1", second.get().getVersionId()); + Assertions.assertEquals(VERSION, first.get().getVersionId()); + Assertions.assertEquals("1.0.1", second.get().getVersionId()); } @Test @@ -177,8 +177,8 @@ public void canGetFirstInQueueByDifferentPriorityWithSameTime() Optional first = queue.getFirstInQueue(); Optional second = queue.getFirstInQueue(); - Assert.assertEquals(VERSION, first.get().getVersionId()); - Assert.assertEquals("1.0.1", second.get().getVersionId()); + Assertions.assertEquals(VERSION, first.get().getVersionId()); + Assertions.assertEquals("1.0.1", second.get().getVersionId()); } @Test @@ -188,10 +188,10 @@ public void canPurgeQueue() MetadataNotification event1 = new MetadataNotification(TESTPROJECT, TEST, TEST,"1.0.1"); queue.push(event); queue.push(event1); - Assert.assertEquals(2, queue.size()); + Assertions.assertEquals(2, queue.size()); long deleted = queue.deleteAll(); - Assert.assertEquals(2, deleted); - Assert.assertEquals(0, queue.size()); + Assertions.assertEquals(2, deleted); + Assertions.assertEquals(0, queue.size()); } diff --git a/legend-depot-notifications-services/src/test/java/org/finos/legend/depot/services/notifications/TestNotificationQueueManager.java b/legend-depot-notifications-services/src/test/java/org/finos/legend/depot/services/notifications/TestNotificationQueueManager.java index 63eddf097..e62e7bfbc 100644 --- a/legend-depot-notifications-services/src/test/java/org/finos/legend/depot/services/notifications/TestNotificationQueueManager.java +++ b/legend-depot-notifications-services/src/test/java/org/finos/legend/depot/services/notifications/TestNotificationQueueManager.java @@ -29,9 +29,9 @@ import org.finos.legend.depot.store.mongo.projects.ProjectsMongo; import org.finos.legend.sdlc.domain.model.entity.Entity; -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 java.util.Arrays; import java.util.List; @@ -54,7 +54,7 @@ public class TestNotificationQueueManager extends TestStoreMongo private final NotificationsService notificationsService = new NotificationsServiceImpl(notifications); private final NotificationsQueueManager eventsManager = new NotificationsQueueManager(notifications, queue, notificationEventHandler); - @Before + @BeforeEach public void setUpData() { projectsStore.createOrUpdate(new StoreProjectData(TEST_PROJECT_ID, TEST_GROUP_ID, "test")); @@ -83,9 +83,9 @@ public void canProcessNewVersionEvent() MetadataNotification event = new MetadataNotification(TEST_PROJECT_ID, TEST_GROUP_ID, "test", VERSION_ID); queue.push(event); int result = eventsManager.handle(); - Assert.assertEquals(1, result); + Assertions.assertEquals(1, result); List entities = entitiesStore.getAllEntities(event.getGroupId(), event.getArtifactId(), event.getVersionId()); - Assert.assertNotNull(entities); + Assertions.assertNotNull(entities); checkEventResult(event); } @@ -94,14 +94,14 @@ private void checkEventResult(MetadataNotification event) { List newEvents = queue.getAllStoredEntities(); - Assert.assertEquals(0, newEvents.size()); + Assertions.assertEquals(0, newEvents.size()); List events = notifications.getAllStoredEntities(); - Assert.assertNotNull(events); - Assert.assertEquals(1, events.size()); - Assert.assertEquals(events.get(0).getGroupId(), event.getGroupId()); - Assert.assertEquals(events.get(0).getArtifactId(), event.getArtifactId()); - Assert.assertEquals(MetadataNotificationStatus.SUCCESS, events.get(0).getStatus()); + Assertions.assertNotNull(events); + Assertions.assertEquals(1, events.size()); + Assertions.assertEquals(events.get(0).getGroupId(), event.getGroupId()); + Assertions.assertEquals(events.get(0).getArtifactId(), event.getArtifactId()); + Assertions.assertEquals(MetadataNotificationStatus.SUCCESS, events.get(0).getStatus()); } @@ -110,9 +110,9 @@ public void processNewVersionEventForNonExistingVersion() { MetadataNotification event = new MetadataNotification(TEST_PROJECT_ID, TEST_GROUP_ID, "test", "10.0.0"); eventsManager.handleEvent(event); - Assert.assertTrue(queue.getAll().isEmpty()); + Assertions.assertTrue(queue.getAll().isEmpty()); MetadataNotification response = notifications.getAll().get(0); - Assert.assertTrue(response.getStatus().equals(MetadataNotificationStatus.FAILED)); + Assertions.assertTrue(response.getStatus().equals(MetadataNotificationStatus.FAILED)); } @Test @@ -120,19 +120,19 @@ public void testRetry() { MetadataNotification event = new MetadataNotification(TEST_PROJECT_ID, TEST_GROUP_ID, "test", "2.3.1"); String eventId = queue.push(event); - Assert.assertFalse(queue.getAll().isEmpty()); + Assertions.assertFalse(queue.getAll().isEmpty()); MetadataNotification mockEnt = queue.getAllStoredEntities().get(0).increaseAttempts(); when(notificationEventHandler.handleNotification(mockEnt)).thenReturn(new MetadataNotificationResponse().addError("i have failed, need to retry")); eventsManager.handle(); - Assert.assertFalse(queue.getAll().isEmpty()); + Assertions.assertFalse(queue.getAll().isEmpty()); MetadataNotification response = queue.getAll().get(0); - Assert.assertTrue(response.getStatus().equals(MetadataNotificationStatus.FAILED)); + Assertions.assertTrue(response.getStatus().equals(MetadataNotificationStatus.FAILED)); eventsManager.handle(); - Assert.assertTrue(queue.getAll().isEmpty()); + Assertions.assertTrue(queue.getAll().isEmpty()); MetadataNotification response1 = notificationsService.getProcessedEvent(eventId).get(); - Assert.assertTrue(response1.getStatus().equals(MetadataNotificationStatus.SUCCESS)); + Assertions.assertTrue(response1.getStatus().equals(MetadataNotificationStatus.SUCCESS)); } @@ -142,28 +142,28 @@ public void testMaxRetry() { MetadataNotification event = new MetadataNotification(TEST_PROJECT_ID, TEST_GROUP_ID, "test", "2.3.1"); String eventId = queue.push(event); - Assert.assertFalse(queue.getAll().isEmpty()); + Assertions.assertFalse(queue.getAll().isEmpty()); MetadataNotification mockEnt = queue.getAllStoredEntities().get(0); MetadataNotificationResponse responseTryOne = new MetadataNotificationResponse().addError("i have failed, need to retry"); when(notificationEventHandler.handleNotification(mockEnt.increaseAttempts())).thenReturn(responseTryOne); eventsManager.handle(); - Assert.assertFalse(queue.getAll().isEmpty()); + Assertions.assertFalse(queue.getAll().isEmpty()); MetadataNotification response = queue.getAll().get(0); - Assert.assertTrue(response.getStatus().equals(MetadataNotificationStatus.FAILED)); + Assertions.assertTrue(response.getStatus().equals(MetadataNotificationStatus.FAILED)); MetadataNotification updatedMockEvent = queue.getAllStoredEntities().get(0); MetadataNotificationResponse responseTryTwo = new MetadataNotificationResponse().addError("i have failed again, cant retry"); when(notificationEventHandler.handleNotification(updatedMockEvent.increaseAttempts())).thenReturn(responseTryTwo); eventsManager.handle(); - Assert.assertTrue(queue.getAll().isEmpty()); + Assertions.assertTrue(queue.getAll().isEmpty()); MetadataNotification response1 = notificationsService.getProcessedEvent(eventId).get(); - Assert.assertTrue(response1.getStatus().equals(MetadataNotificationStatus.FAILED)); + Assertions.assertTrue(response1.getStatus().equals(MetadataNotificationStatus.FAILED)); - Assert.assertFalse(notifications.getAll().isEmpty()); + Assertions.assertFalse(notifications.getAll().isEmpty()); MetadataNotification notification = notifications.getAll().get(0); - Assert.assertEquals(2,notification.getAttempt()); - Assert.assertEquals(2,notification.getResponses().size()); + Assertions.assertEquals(2,notification.getAttempt()); + Assertions.assertEquals(2,notification.getResponses().size()); } @Test @@ -171,28 +171,28 @@ public void testRetryIsSuccessfull() { MetadataNotification event = new MetadataNotification(TEST_PROJECT_ID, TEST_GROUP_ID, "test", "2.3.1"); String eventId = queue.push(event); - Assert.assertFalse(queue.getAll().isEmpty()); + Assertions.assertFalse(queue.getAll().isEmpty()); MetadataNotification mockEnt = queue.getAllStoredEntities().get(0); MetadataNotificationResponse responseTryOne = new MetadataNotificationResponse().addError("i have failed, need to retry"); when(notificationEventHandler.handleNotification(mockEnt.increaseAttempts())).thenReturn(responseTryOne); eventsManager.handle(); - Assert.assertFalse(queue.getAll().isEmpty()); + Assertions.assertFalse(queue.getAll().isEmpty()); MetadataNotification response = queue.getAll().get(0); - Assert.assertTrue(response.getStatus().equals(MetadataNotificationStatus.FAILED)); + Assertions.assertTrue(response.getStatus().equals(MetadataNotificationStatus.FAILED)); MetadataNotification updatedMockEvent = queue.getAllStoredEntities().get(0); MetadataNotificationResponse responseTryTwo = new MetadataNotificationResponse().addMessage("i am ok now , did not fail"); when(notificationEventHandler.handleNotification(updatedMockEvent.increaseAttempts())).thenReturn(responseTryTwo); eventsManager.handle(); - Assert.assertTrue(queue.getAll().isEmpty()); + Assertions.assertTrue(queue.getAll().isEmpty()); MetadataNotification response1 = notificationsService.getProcessedEvent(eventId).get(); - Assert.assertTrue(response1.getStatus().equals(MetadataNotificationStatus.SUCCESS)); + Assertions.assertTrue(response1.getStatus().equals(MetadataNotificationStatus.SUCCESS)); - Assert.assertFalse(notifications.getAll().isEmpty()); + Assertions.assertFalse(notifications.getAll().isEmpty()); MetadataNotification notification = notifications.getAll().get(0); - Assert.assertEquals(2,notification.getAttempt()); - Assert.assertEquals(2,notification.getResponses().size()); + Assertions.assertEquals(2,notification.getAttempt()); + Assertions.assertEquals(2,notification.getResponses().size()); } } diff --git a/legend-depot-notifications-services/src/test/java/org/finos/legend/depot/store/resources/notifications/TestNotificationsResource.java b/legend-depot-notifications-services/src/test/java/org/finos/legend/depot/store/resources/notifications/TestNotificationsResource.java index fa3354d8d..a8e837f15 100644 --- a/legend-depot-notifications-services/src/test/java/org/finos/legend/depot/store/resources/notifications/TestNotificationsResource.java +++ b/legend-depot-notifications-services/src/test/java/org/finos/legend/depot/store/resources/notifications/TestNotificationsResource.java @@ -20,8 +20,8 @@ import org.finos.legend.depot.services.notifications.NotificationsServiceImpl; import org.finos.legend.depot.store.mongo.TestStoreMongo; import org.finos.legend.depot.store.mongo.notifications.NotificationsMongo; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -55,13 +55,13 @@ public void canRetrieveEventsByDate() List allEvents = resource.getPastEventNotifications(null,null,null,null,null,null,aPointInTime.minusDays(100).format(DateTimeFormatter.ISO_DATE_TIME), null); - Assert.assertNotNull(allEvents); - Assert.assertEquals(4, allEvents.size()); + Assertions.assertNotNull(allEvents); + Assertions.assertEquals(4, allEvents.size()); LocalDateTime lunchTime = LocalDateTime.parse("2019-01-01T12:00:00", DateTimeFormatter.ISO_DATE_TIME); List afterLunch = resource.getPastEventNotifications(null,null,null,null,null,null,lunchTime.format(DateTimeFormatter.ISO_DATE_TIME), null); - Assert.assertNotNull(afterLunch); - Assert.assertEquals(2, afterLunch.size()); + Assertions.assertNotNull(afterLunch); + Assertions.assertEquals(2, afterLunch.size()); } @@ -74,13 +74,13 @@ public void canRetrieveEventsByDateAsEpocMillis() notificationsMongo.insert(event1); insertRaw(notificationsMongo.COLLECTION,event2.setUpdated(toDate(LocalDateTime.now().plusDays(1)))); - Assert.assertEquals(2, notificationsMongo.getAll().size()); + Assertions.assertEquals(2, notificationsMongo.getAll().size()); List found = resource.getPastEventNotifications(null,null,null,null,null,null,null, String.valueOf(System.currentTimeMillis())); - Assert.assertNotNull(found); - Assert.assertEquals(1, found.size()); - Assert.assertTrue(found.stream().anyMatch(e -> e.getProjectId().equals("1"))); + Assertions.assertNotNull(found); + Assertions.assertEquals(1, found.size()); + Assertions.assertTrue(found.stream().anyMatch(e -> e.getProjectId().equals("1"))); } @@ -91,14 +91,14 @@ public void testDeleteOldNotifications() MetadataNotification ev1 = new MetadataNotification("prod-123","test","artifacts","1.0.0"); ev1.setUpdated(toDate(LocalDateTime.now().minusDays(12))); insertRaw(NotificationsMongo.COLLECTION,ev1); - Assert.assertEquals(1, notificationsMongo.getAll().size()); + Assertions.assertEquals(1, notificationsMongo.getAll().size()); MetadataNotification ev2 = new MetadataNotification("prod-123","test","artifacts","2.0.0"); notificationsMongo.createOrUpdate(ev2); - Assert.assertEquals(2, notificationsMongo.getAll().size()); + Assertions.assertEquals(2, notificationsMongo.getAll().size()); long deleted = notificationsService.deleteOldNotifications(10); - Assert.assertEquals(1,deleted); - Assert.assertEquals(1, notificationsMongo.getAll().size()); + Assertions.assertEquals(1,deleted); + Assertions.assertEquals(1, notificationsMongo.getAll().size()); } } diff --git a/legend-depot-notifications-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/notifications/TestNotificationsMongo.java b/legend-depot-notifications-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/notifications/TestNotificationsMongo.java index daddaeda2..c77c32f04 100644 --- a/legend-depot-notifications-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/notifications/TestNotificationsMongo.java +++ b/legend-depot-notifications-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/notifications/TestNotificationsMongo.java @@ -19,8 +19,8 @@ import org.finos.legend.depot.services.api.notifications.queue.Queue; import org.finos.legend.depot.store.mongo.TestStoreMongo; import org.finos.legend.depot.store.mongo.notifications.queue.NotificationsQueueMongo; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.time.LocalDateTime; import java.util.List; @@ -54,16 +54,16 @@ public void canStoreEvents() List eventList = queue.pullAll(); - Assert.assertNotNull(eventList); - Assert.assertEquals(4, eventList.size()); + Assertions.assertNotNull(eventList); + Assertions.assertEquals(4, eventList.size()); for (MetadataNotification ev : eventList) { eventsMongo.createOrUpdate(ev); } List eventList2 = eventsMongo.getAll(); - Assert.assertNotNull(eventList2); - Assert.assertEquals(4, eventList2.size()); + Assertions.assertNotNull(eventList2); + Assertions.assertEquals(4, eventList2.size()); } @@ -74,16 +74,16 @@ public void eventIdIsKeptOnCompletion() MetadataNotification event = new MetadataNotification(TESTPROJECT, TEST, TEST,VERSION); queue.push(event); List pulled = queue.pullAll(); - Assert.assertNotNull(pulled); - Assert.assertEquals(1, pulled.size()); - Assert.assertNotNull(pulled.get(0).getEventId()); + Assertions.assertNotNull(pulled); + Assertions.assertEquals(1, pulled.size()); + Assertions.assertNotNull(pulled.get(0).getEventId()); eventsMongo.createOrUpdate(pulled.get(0)); List eventList2 = eventsMongo.getAll(); - Assert.assertNotNull(eventList2); - Assert.assertEquals(1, eventList2.size()); - Assert.assertNotNull(eventList2.get(0).getEventId()); - Assert.assertEquals(pulled.get(0).getEventId(), eventList2.get(0).getEventId()); + Assertions.assertNotNull(eventList2); + Assertions.assertEquals(1, eventList2.size()); + Assertions.assertNotNull(eventList2.get(0).getEventId()); + Assertions.assertEquals(pulled.get(0).getEventId(), eventList2.get(0).getEventId()); } @Test @@ -95,15 +95,15 @@ public void canRetrieveEventById() eventsMongo.createOrUpdate(events.get(0)); List eventList = eventsMongo.getAll(); - Assert.assertNotNull(eventList); - Assert.assertEquals(1, eventList.size()); - Assert.assertNotNull(eventList.get(0).getEventId()); + Assertions.assertNotNull(eventList); + Assertions.assertEquals(1, eventList.size()); + Assertions.assertNotNull(eventList.get(0).getEventId()); Optional foundEvent = eventsMongo.get(eventList.get(0).getEventId()); - Assert.assertEquals(eventId, eventList.get(0).getEventId()); - Assert.assertNotNull(foundEvent); - Assert.assertTrue(foundEvent.isPresent()); - Assert.assertEquals(eventList.get(0).getEventId(), foundEvent.get().getEventId()); + Assertions.assertEquals(eventId, eventList.get(0).getEventId()); + Assertions.assertNotNull(foundEvent); + Assertions.assertTrue(foundEvent.isPresent()); + Assertions.assertEquals(eventList.get(0).getEventId(), foundEvent.get().getEventId()); } @@ -123,14 +123,14 @@ public void canRetrieveEventsFromDateToDate() insertRaw(eventsMongo.COLLECTION,event4.setUpdated(toDate(aPointInTime.plusHours(2).plusMinutes(35)))); List allEvents = eventsMongo.getAll(); - Assert.assertNotNull(allEvents); - Assert.assertEquals(4, allEvents.size()); + Assertions.assertNotNull(allEvents); + Assertions.assertEquals(4, allEvents.size()); List eventsBeforeLunch = eventsMongo.find(null,null,null,null,null,null,aPointInTime.toLocalDate().atStartOfDay(), aPointInTime); - Assert.assertNotNull(eventsBeforeLunch); - Assert.assertEquals(1, eventsBeforeLunch.size()); + Assertions.assertNotNull(eventsBeforeLunch); + Assertions.assertEquals(1, eventsBeforeLunch.size()); List afterLunch = eventsMongo.find(null,null,null,null,null,null,aPointInTime.withHour(12).withMinute(0).withSecond(1), null); - Assert.assertNotNull(afterLunch); - Assert.assertEquals(3, afterLunch.size()); + Assertions.assertNotNull(afterLunch); + Assertions.assertEquals(3, afterLunch.size()); } } \ No newline at end of file diff --git a/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/server/resources/TestPureModelContextDataResource.java b/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/server/resources/TestPureModelContextDataResource.java index 489e216bf..6a28bbda3 100644 --- a/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/server/resources/TestPureModelContextDataResource.java +++ b/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/server/resources/TestPureModelContextDataResource.java @@ -33,9 +33,9 @@ import org.finos.legend.depot.services.api.notifications.queue.Queue; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class; -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 javax.ws.rs.core.Response; @@ -56,7 +56,7 @@ public class TestPureModelContextDataResource extends TestBaseServices private final PureModelContextResource resource = new PureModelContextResource(new PureModelContextServiceImpl(entitiesService,projectsService)); - @Before + @BeforeEach public void setUpData() { super.setUpData(); @@ -69,8 +69,8 @@ public void setUpData() public void loadPMCD() { Response data = resource.getPureModelContextData("test.legend", "blank-prod", "2.0.0", null, false,true, null); - Assert.assertFalse(((PureModelContextData)data.getEntity()).getElements().isEmpty()); - Assert.assertEquals(((PureModelContextData)data.getEntity()).getElements().size(), 2); + Assertions.assertFalse(((PureModelContextData)data.getEntity()).getElements().isEmpty()); + Assertions.assertEquals(((PureModelContextData)data.getEntity()).getElements().size(), 2); } @@ -78,15 +78,15 @@ public void loadPMCD() public void loadDependenciesPMCD() { Response data = resource.getPureModelContextData(List.of(new ProjectVersion("org.finos.legend","second-project","1.0.1"), new ProjectVersion("org.finos.legend","first-project","1.0.2")), null, true, true, null); - Assert.assertFalse(((PureModelContextData)data.getEntity()).getElements().isEmpty()); - Assert.assertEquals(6, ((PureModelContextData)data.getEntity()).getElements().size()); + Assertions.assertFalse(((PureModelContextData)data.getEntity()).getElements().isEmpty()); + Assertions.assertEquals(6, ((PureModelContextData)data.getEntity()).getElements().size()); Optional optionalPersonClass = ((PureModelContextData)data.getEntity()) .getElements() .stream() .filter(packageableElement -> Objects.equals(packageableElement._package, "demo::model") && packageableElement.name.equals("Person")) .map(packageableElement -> (Class) packageableElement) .findFirst(); - Assert.assertTrue(optionalPersonClass.isPresent()); - Assert.assertTrue(optionalPersonClass.get().properties.stream().anyMatch(property -> property.name.equals("lastName"))); + Assertions.assertTrue(optionalPersonClass.isPresent()); + Assertions.assertTrue(optionalPersonClass.get().properties.stream().anyMatch(property -> property.name.equals("lastName"))); } } diff --git a/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/services/pure/model/context/TestPureModelContextService.java b/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/services/pure/model/context/TestPureModelContextService.java index 9f2b8c826..e7b885e43 100644 --- a/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/services/pure/model/context/TestPureModelContextService.java +++ b/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/services/pure/model/context/TestPureModelContextService.java @@ -44,9 +44,9 @@ import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; import org.finos.legend.engine.shared.core.ObjectMapperFactory; import org.finos.legend.sdlc.domain.model.entity.Entity; -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 org.mockito.Mockito; import static org.mockito.Mockito.mock; @@ -94,12 +94,12 @@ private String toString(PureModelContextData contextData) } - @Before + @BeforeEach public void setupMetadata() { projectsStore.createOrUpdate(new StoreProjectData("PROD-1", "test.legend", "blank-prod", null, "2.0.0")); setUpProjectsVersionsFromFile(projects); - Assert.assertEquals(4, projectsService.getAllProjectCoordinates().size()); + Assertions.assertEquals(4, projectsService.getAllProjectCoordinates().size()); entityUtils.loadEntities(versionedEntities); entityUtils.loadEntities(revisionEntities); entityUtils.loadEntities(entities_16538); @@ -111,42 +111,42 @@ public void setupMetadata() public void canGetEntitiesForProjectAsPureModelContextData() throws JsonProcessingException { String modelContextDataAsString = getPureModelContextDataAsString(TEST_GROUP_ID, "test", "2.2.0", CLIENT_VERSION, false, true); - Assert.assertEquals("{\"_type\":\"data\",\"elements\":[{\"_type\":\"profile\",\"name\":\"TestProfile\",\"package\":\"examples::metadata::test\",\"stereotypes\":[],\"tags\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"ClientBasic\",\"originalMilestonedProperties\":[],\"package\":\"examples::metadata::test\",\"properties\":[{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Integer\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"EntityId\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Boolean\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IsActive\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Float\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"RiskScore\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"StrictDate\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IncorporationDate\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"OptionalAlternativeName\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"newProperty\",\"stereotypes\":[],\"taggedValues\":[]}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"profile\",\"name\":\"TestProfileTwo\",\"package\":\"examples::metadata::test::subpackage\",\"stereotypes\":[],\"tags\":[]}],\"origin\":{\"_type\":\"pointer\",\"sdlcInfo\":{\"_type\":\"alloy\",\"baseVersion\":\"2.2.0\",\"packageableElementPointers\":[],\"project\":\"examples.metadata:test\",\"version\":\"none\"},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}", modelContextDataAsString); + Assertions.assertEquals("{\"_type\":\"data\",\"elements\":[{\"_type\":\"profile\",\"name\":\"TestProfile\",\"package\":\"examples::metadata::test\",\"stereotypes\":[],\"tags\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"ClientBasic\",\"originalMilestonedProperties\":[],\"package\":\"examples::metadata::test\",\"properties\":[{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Integer\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"EntityId\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Boolean\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IsActive\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Float\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"RiskScore\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"StrictDate\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IncorporationDate\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"OptionalAlternativeName\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"newProperty\",\"stereotypes\":[],\"taggedValues\":[]}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"profile\",\"name\":\"TestProfileTwo\",\"package\":\"examples::metadata::test::subpackage\",\"stereotypes\":[],\"tags\":[]}],\"origin\":{\"_type\":\"pointer\",\"sdlcInfo\":{\"_type\":\"alloy\",\"baseVersion\":\"2.2.0\",\"packageableElementPointers\":[],\"project\":\"examples.metadata:test\",\"version\":\"none\"},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}", modelContextDataAsString); String modelContextDataAsStringNoConversion = getPureModelContextDataAsString(TEST_GROUP_ID, "test", "2.2.0", CLIENT_VERSION, false, false); - Assert.assertEquals("{\"_type\":\"data\",\"elements\":[{\"_type\":\"profile\",\"name\":\"TestProfile\",\"package\":\"examples::metadata::test\"},{\"_type\":\"class\",\"name\":\"ClientBasic\",\"package\":\"examples::metadata::test\",\"properties\":[{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"type\":\"String\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"EntityId\",\"type\":\"Integer\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IsActive\",\"type\":\"Boolean\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"RiskScore\",\"type\":\"Float\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IncorporationDate\",\"type\":\"StrictDate\"},{\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"OptionalAlternativeName\",\"type\":\"String\"},{\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"newProperty\",\"type\":\"String\"}]},{\"_type\":\"profile\",\"name\":\"TestProfileTwo\",\"package\":\"examples::metadata::test::subpackage\"}],\"origin\":{\"_type\":\"pointer\",\"sdlcInfo\":{\"_type\":\"alloy\",\"baseVersion\":\"2.2.0\",\"packageableElementPointers\":[],\"project\":\"examples.metadata:test\",\"version\":\"none\"},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}", modelContextDataAsStringNoConversion); + Assertions.assertEquals("{\"_type\":\"data\",\"elements\":[{\"_type\":\"profile\",\"name\":\"TestProfile\",\"package\":\"examples::metadata::test\"},{\"_type\":\"class\",\"name\":\"ClientBasic\",\"package\":\"examples::metadata::test\",\"properties\":[{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"type\":\"String\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"EntityId\",\"type\":\"Integer\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IsActive\",\"type\":\"Boolean\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"RiskScore\",\"type\":\"Float\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IncorporationDate\",\"type\":\"StrictDate\"},{\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"OptionalAlternativeName\",\"type\":\"String\"},{\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"newProperty\",\"type\":\"String\"}]},{\"_type\":\"profile\",\"name\":\"TestProfileTwo\",\"package\":\"examples::metadata::test::subpackage\"}],\"origin\":{\"_type\":\"pointer\",\"sdlcInfo\":{\"_type\":\"alloy\",\"baseVersion\":\"2.2.0\",\"packageableElementPointers\":[],\"project\":\"examples.metadata:test\",\"version\":\"none\"},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}", modelContextDataAsStringNoConversion); ObjectMapper mapper = ObjectMapperFactory.getNewStandardObjectMapperWithPureProtocolExtensionSupports(); String roundTripWithConversion = mapper.writeValueAsString(mapper.readValue(modelContextDataAsStringNoConversion, PureModelContextData.class)); - Assert.assertEquals(modelContextDataAsString, roundTripWithConversion); + Assertions.assertEquals(modelContextDataAsString, roundTripWithConversion); } - @Test(expected = RuntimeException.class) + @Test public void testNonExistentProjectOrVersion() { - getPureModelContextDataAsString("non-existent-project", "tst", "2.0.0", CLIENT_VERSION, false, true); + Assertions.assertThrows(RuntimeException.class, () -> getPureModelContextDataAsString("non-existent-project", "tst", "2.0.0", CLIENT_VERSION, false, true)); } - @Test(expected = RuntimeException.class) + @Test public void testNonExistentProjectOrVersion1() { - getPureModelContextDataAsString(TEST_GROUP_ID, "non-existent-version", "test", CLIENT_VERSION, false, true); + Assertions.assertThrows(RuntimeException.class, () -> getPureModelContextDataAsString(TEST_GROUP_ID, "non-existent-version", "test", CLIENT_VERSION, false, true)); } @Test public void canGetEntitiesAsPureModelContextData() { String modelContextDataAsString = getPureModelContextDataAsString(TEST_GROUP_ID, "test", BRANCH_SNAPSHOT("master"), CLIENT_VERSION, false, true); - Assert.assertEquals("{\"_type\":\"data\",\"elements\":[{\"_type\":\"class\",\"constraints\":[],\"name\":\"ClassWithDependency\",\"originalMilestonedProperties\":[],\"package\":\"examples::metadata::test\",\"properties\":[{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"stereotypes\":[],\"taggedValues\":[]}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"profile\",\"name\":\"TestProfile\",\"package\":\"examples::metadata::test\",\"stereotypes\":[],\"tags\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"ClientBasic\",\"originalMilestonedProperties\":[],\"package\":\"examples::metadata::test\",\"properties\":[{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Integer\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"EntityId\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Boolean\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IsActive\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Float\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"RiskScore\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"StrictDate\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IncorporationDate\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"OptionalAlternativeName\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"newProperty\",\"stereotypes\":[],\"taggedValues\":[]}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"profile\",\"name\":\"TestProfileTwo\",\"package\":\"examples::metadata::test::subpackage\",\"stereotypes\":[],\"tags\":[]}],\"origin\":{\"_type\":\"pointer\",\"sdlcInfo\":{\"_type\":\"alloy\",\"baseVersion\":\"master-SNAPSHOT\",\"packageableElementPointers\":[],\"project\":\"examples.metadata:test\",\"version\":\"none\"},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}", modelContextDataAsString); + Assertions.assertEquals("{\"_type\":\"data\",\"elements\":[{\"_type\":\"class\",\"constraints\":[],\"name\":\"ClassWithDependency\",\"originalMilestonedProperties\":[],\"package\":\"examples::metadata::test\",\"properties\":[{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"stereotypes\":[],\"taggedValues\":[]}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"profile\",\"name\":\"TestProfile\",\"package\":\"examples::metadata::test\",\"stereotypes\":[],\"tags\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"ClientBasic\",\"originalMilestonedProperties\":[],\"package\":\"examples::metadata::test\",\"properties\":[{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Integer\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"EntityId\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Boolean\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IsActive\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Float\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"RiskScore\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"StrictDate\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IncorporationDate\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"OptionalAlternativeName\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"newProperty\",\"stereotypes\":[],\"taggedValues\":[]}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"profile\",\"name\":\"TestProfileTwo\",\"package\":\"examples::metadata::test::subpackage\",\"stereotypes\":[],\"tags\":[]}],\"origin\":{\"_type\":\"pointer\",\"sdlcInfo\":{\"_type\":\"alloy\",\"baseVersion\":\"master-SNAPSHOT\",\"packageableElementPointers\":[],\"project\":\"examples.metadata:test\",\"version\":\"none\"},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}", modelContextDataAsString); String modelContextDataAsStringOld = getPureModelContextDataAsString(TEST_GROUP_ID, "test", BRANCH_SNAPSHOT("master"), CLIENT_VERSION, false, false); - Assert.assertEquals("{\"_type\":\"data\",\"elements\":[{\"_type\":\"class\",\"name\":\"ClassWithDependency\",\"package\":\"examples::metadata::test\",\"properties\":[{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"type\":\"String\"}]},{\"_type\":\"profile\",\"name\":\"TestProfile\",\"package\":\"examples::metadata::test\"},{\"_type\":\"class\",\"name\":\"ClientBasic\",\"package\":\"examples::metadata::test\",\"properties\":[{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"type\":\"String\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"EntityId\",\"type\":\"Integer\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IsActive\",\"type\":\"Boolean\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"RiskScore\",\"type\":\"Float\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IncorporationDate\",\"type\":\"StrictDate\"},{\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"OptionalAlternativeName\",\"type\":\"String\"},{\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"newProperty\",\"type\":\"String\"}]},{\"_type\":\"profile\",\"name\":\"TestProfileTwo\",\"package\":\"examples::metadata::test::subpackage\"}],\"origin\":{\"_type\":\"pointer\",\"sdlcInfo\":{\"_type\":\"alloy\",\"baseVersion\":\"master-SNAPSHOT\",\"packageableElementPointers\":[],\"project\":\"examples.metadata:test\",\"version\":\"none\"},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}", modelContextDataAsStringOld); + Assertions.assertEquals("{\"_type\":\"data\",\"elements\":[{\"_type\":\"class\",\"name\":\"ClassWithDependency\",\"package\":\"examples::metadata::test\",\"properties\":[{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"type\":\"String\"}]},{\"_type\":\"profile\",\"name\":\"TestProfile\",\"package\":\"examples::metadata::test\"},{\"_type\":\"class\",\"name\":\"ClientBasic\",\"package\":\"examples::metadata::test\",\"properties\":[{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"type\":\"String\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"EntityId\",\"type\":\"Integer\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IsActive\",\"type\":\"Boolean\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"RiskScore\",\"type\":\"Float\"},{\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IncorporationDate\",\"type\":\"StrictDate\"},{\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"OptionalAlternativeName\",\"type\":\"String\"},{\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"newProperty\",\"type\":\"String\"}]},{\"_type\":\"profile\",\"name\":\"TestProfileTwo\",\"package\":\"examples::metadata::test::subpackage\"}],\"origin\":{\"_type\":\"pointer\",\"sdlcInfo\":{\"_type\":\"alloy\",\"baseVersion\":\"master-SNAPSHOT\",\"packageableElementPointers\":[],\"project\":\"examples.metadata:test\",\"version\":\"none\"},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}", modelContextDataAsStringOld); } - @Test(expected = IllegalArgumentException.class) + @Test public void testNonExistentProject() { - getPureModelContextDataAsString("non.existent.project", "test", BRANCH_SNAPSHOT("master"), CLIENT_VERSION, false, true); + Assertions.assertThrows(RuntimeException.class, () -> getPureModelContextDataAsString("non.existent.project", "test", BRANCH_SNAPSHOT("master"), CLIENT_VERSION, false, true)); } @Test @@ -155,7 +155,7 @@ public void testErrorThrownWhenNoProjectVersionFound() EntitiesService mockVersions = Mockito.mock(EntitiesService.class); PureModelContextService newService = new PureModelContextServiceImpl(mockVersions, projectsService); - Assert.assertThrows("project version not found for test.legend-blank-prod-master-SNAPSHOT", IllegalArgumentException.class, () -> getPureModelContextDataAsString("test.legend", "blank-prod", BRANCH_SNAPSHOT("master"), CLIENT_VERSION, false, true)); + Assertions.assertThrows(IllegalArgumentException.class, () -> getPureModelContextDataAsString("test.legend", "blank-prod", BRANCH_SNAPSHOT("master"), CLIENT_VERSION, false, true), "project version not found for test.legend-blank-prod-master-SNAPSHOT"); } @Test @@ -166,33 +166,33 @@ public void canGetEntitiesForProjectAsPureModelContextData_WithDependencies() List entityList1 = entitiesStore.getAllEntities("test.legend", "blank-prod", "2.0.0"); List entityList2 = entitiesStore.getAllEntities("examples.metadata", "test", "3.0.0"); List entityList3 = entitiesStore.getAllEntities("examples.metadata", "test-dependencies", "2.0.0"); - Assert.assertNotNull(entityList1); - Assert.assertNotNull(entityList2); - Assert.assertNotNull(entityList3); - Assert.assertEquals(2, entityList1.size()); - Assert.assertEquals(5, entityList2.size()); - Assert.assertEquals(6, entityList3.size()); + Assertions.assertNotNull(entityList1); + Assertions.assertNotNull(entityList2); + Assertions.assertNotNull(entityList3); + Assertions.assertEquals(2, entityList1.size()); + Assertions.assertEquals(5, entityList2.size()); + Assertions.assertEquals(6, entityList3.size()); String modelContextDataAsString = getPureModelContextDataAsString("test.legend", "blank-prod", "2.0.0", CLIENT_VERSION, true, true); - Assert.assertNotNull(modelContextDataAsString); - Assert.assertEquals("{\"_type\":\"data\",\"elements\":[{\"_type\":\"service\",\"autoActivateUpdates\":true,\"documentation\":\"\",\"execution\":{\"_type\":\"pureMultiExecution\",\"executionKey\":\"env\",\"executionParameters\":[{\"key\":\"PROD\",\"mapping\":\"mapping::SomeMapping\",\"runtime\":{\"_type\":\"runtimePointer\",\"runtime\":\"runtime::H2Runtime\"}},{\"key\":\"DEV\",\"mapping\":\"mapping::SomeMapping\",\"runtime\":{\"_type\":\"runtimePointer\",\"runtime\":\"runtime::H2Runtime\"}}],\"func\":{\"_type\":\"lambda\",\"body\":[{\"_type\":\"func\",\"function\":\"project\",\"parameters\":[{\"_type\":\"func\",\"function\":\"getAll\",\"parameters\":[{\"_type\":\"packageableElementPtr\",\"fullPath\":\"domain::COVIDData\"}]},{\"_type\":\"collection\",\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"values\":[{\"_type\":\"lambda\",\"body\":[{\"_type\":\"property\",\"parameters\":[{\"_type\":\"var\",\"name\":\"x\"}],\"property\":\"cases\"}],\"parameters\":[{\"_type\":\"var\",\"name\":\"x\"}]}]},{\"_type\":\"collection\",\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"values\":[{\"_type\":\"string\",\"value\":\"Cases\"}]}]}],\"parameters\":[]}},\"name\":\"SomeService\",\"owners\":[\"anonymous\",\"akphi\"],\"package\":\"service\",\"pattern\":\"/9566f101-2108-408f-863f-6d7e154dc17a\",\"postValidations\":[],\"stereotypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"Person\",\"originalMilestonedProperties\":[],\"package\":\"test::legend::blank_prod::v2_0_0::blank\",\"properties\":[],\"qualifiedProperties\":[],\"sourceInformation\":{\"endColumn\":1,\"endLine\":3,\"sourceId\":\"\",\"startColumn\":1,\"startLine\":1},\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"test\",\"originalMilestonedProperties\":[],\"package\":\"test::legend::metadata::test::v3_0_0::com\",\"properties\":[],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"ClassWithDependency\",\"originalMilestonedProperties\":[],\"package\":\"test::legend::metadata::test::v3_0_0::test::legend::metadata::test\",\"properties\":[{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"stereotypes\":[],\"taggedValues\":[]}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"ClientBasic\",\"originalMilestonedProperties\":[],\"package\":\"test::legend::metadata::test::v3_0_0::test::legend::metadata::test\",\"properties\":[{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Integer\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"EntityId\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Boolean\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IsActive\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Float\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"RiskScore\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"StrictDate\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IncorporationDate\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"OptionalAlternativeName\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"newProperty\",\"stereotypes\":[],\"taggedValues\":[]}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"profile\",\"name\":\"TestProfile\",\"package\":\"test::legend::metadata::test::v3_0_0::test::legend::metadata::test\",\"stereotypes\":[],\"tags\":[]},{\"_type\":\"profile\",\"name\":\"TestProfileTwo\",\"package\":\"test::legend::metadata::test::v3_0_0::test::legend::metadata::test::subpackage\",\"stereotypes\":[],\"tags\":[]}],\"origin\":{\"_type\":\"pointer\",\"sdlcInfo\":{\"_type\":\"alloy\",\"baseVersion\":\"2.0.0\",\"packageableElementPointers\":[],\"project\":\"test.legend:blank-prod\",\"version\":\"none\"},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}", modelContextDataAsString); + Assertions.assertNotNull(modelContextDataAsString); + Assertions.assertEquals("{\"_type\":\"data\",\"elements\":[{\"_type\":\"service\",\"autoActivateUpdates\":true,\"documentation\":\"\",\"execution\":{\"_type\":\"pureMultiExecution\",\"executionKey\":\"env\",\"executionParameters\":[{\"key\":\"PROD\",\"mapping\":\"mapping::SomeMapping\",\"runtime\":{\"_type\":\"runtimePointer\",\"runtime\":\"runtime::H2Runtime\"}},{\"key\":\"DEV\",\"mapping\":\"mapping::SomeMapping\",\"runtime\":{\"_type\":\"runtimePointer\",\"runtime\":\"runtime::H2Runtime\"}}],\"func\":{\"_type\":\"lambda\",\"body\":[{\"_type\":\"func\",\"function\":\"project\",\"parameters\":[{\"_type\":\"func\",\"function\":\"getAll\",\"parameters\":[{\"_type\":\"packageableElementPtr\",\"fullPath\":\"domain::COVIDData\"}]},{\"_type\":\"collection\",\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"values\":[{\"_type\":\"lambda\",\"body\":[{\"_type\":\"property\",\"parameters\":[{\"_type\":\"var\",\"name\":\"x\"}],\"property\":\"cases\"}],\"parameters\":[{\"_type\":\"var\",\"name\":\"x\"}]}]},{\"_type\":\"collection\",\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"values\":[{\"_type\":\"string\",\"value\":\"Cases\"}]}]}],\"parameters\":[]}},\"name\":\"SomeService\",\"owners\":[\"anonymous\",\"akphi\"],\"package\":\"service\",\"pattern\":\"/9566f101-2108-408f-863f-6d7e154dc17a\",\"postValidations\":[],\"stereotypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"Person\",\"originalMilestonedProperties\":[],\"package\":\"test::legend::blank_prod::v2_0_0::blank\",\"properties\":[],\"qualifiedProperties\":[],\"sourceInformation\":{\"endColumn\":1,\"endLine\":3,\"sourceId\":\"\",\"startColumn\":1,\"startLine\":1},\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"test\",\"originalMilestonedProperties\":[],\"package\":\"test::legend::metadata::test::v3_0_0::com\",\"properties\":[],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"ClassWithDependency\",\"originalMilestonedProperties\":[],\"package\":\"test::legend::metadata::test::v3_0_0::test::legend::metadata::test\",\"properties\":[{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"stereotypes\":[],\"taggedValues\":[]}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"ClientBasic\",\"originalMilestonedProperties\":[],\"package\":\"test::legend::metadata::test::v3_0_0::test::legend::metadata::test\",\"properties\":[{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Integer\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"EntityId\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Boolean\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IsActive\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Float\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"RiskScore\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"StrictDate\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IncorporationDate\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"OptionalAlternativeName\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"newProperty\",\"stereotypes\":[],\"taggedValues\":[]}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"profile\",\"name\":\"TestProfile\",\"package\":\"test::legend::metadata::test::v3_0_0::test::legend::metadata::test\",\"stereotypes\":[],\"tags\":[]},{\"_type\":\"profile\",\"name\":\"TestProfileTwo\",\"package\":\"test::legend::metadata::test::v3_0_0::test::legend::metadata::test::subpackage\",\"stereotypes\":[],\"tags\":[]}],\"origin\":{\"_type\":\"pointer\",\"sdlcInfo\":{\"_type\":\"alloy\",\"baseVersion\":\"2.0.0\",\"packageableElementPointers\":[],\"project\":\"test.legend:blank-prod\",\"version\":\"none\"},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}", modelContextDataAsString); PureModelContextData pureModelContextData = service.getPureModelContextData("test.legend", "blank-prod", "2.0.0", CLIENT_VERSION, true, true); - Assert.assertNotNull(pureModelContextData); - Assert.assertEquals("2.0.0", pureModelContextData.origin.sdlcInfo.baseVersion); - Assert.assertEquals("test.legend:blank-prod", ((AlloySDLC) pureModelContextData.origin.sdlcInfo).project); + Assertions.assertNotNull(pureModelContextData); + Assertions.assertEquals("2.0.0", pureModelContextData.origin.sdlcInfo.baseVersion); + Assertions.assertEquals("test.legend:blank-prod", ((AlloySDLC) pureModelContextData.origin.sdlcInfo).project); } @Test public void canGetEntitiesForProjectAsPureModelContextDataWithLatestAsVersion() { List entityList1 = entitiesStore.getAllEntities("test.legend", "blank-prod", "2.0.0"); - Assert.assertNotNull(entityList1); - Assert.assertEquals(2, entityList1.size()); + Assertions.assertNotNull(entityList1); + Assertions.assertEquals(2, entityList1.size()); String modelContextDataAsString = getPureModelContextDataAsString("test.legend", "blank-prod", "latest", CLIENT_VERSION, false, true); - Assert.assertNotNull(modelContextDataAsString); - Assert.assertEquals("{\"_type\":\"data\",\"elements\":[{\"_type\":\"service\",\"autoActivateUpdates\":true,\"documentation\":\"\",\"execution\":{\"_type\":\"pureMultiExecution\",\"executionKey\":\"env\",\"executionParameters\":[{\"key\":\"PROD\",\"mapping\":\"mapping::SomeMapping\",\"runtime\":{\"_type\":\"runtimePointer\",\"runtime\":\"runtime::H2Runtime\"}},{\"key\":\"DEV\",\"mapping\":\"mapping::SomeMapping\",\"runtime\":{\"_type\":\"runtimePointer\",\"runtime\":\"runtime::H2Runtime\"}}],\"func\":{\"_type\":\"lambda\",\"body\":[{\"_type\":\"func\",\"function\":\"project\",\"parameters\":[{\"_type\":\"func\",\"function\":\"getAll\",\"parameters\":[{\"_type\":\"packageableElementPtr\",\"fullPath\":\"domain::COVIDData\"}]},{\"_type\":\"collection\",\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"values\":[{\"_type\":\"lambda\",\"body\":[{\"_type\":\"property\",\"parameters\":[{\"_type\":\"var\",\"name\":\"x\"}],\"property\":\"cases\"}],\"parameters\":[{\"_type\":\"var\",\"name\":\"x\"}]}]},{\"_type\":\"collection\",\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"values\":[{\"_type\":\"string\",\"value\":\"Cases\"}]}]}],\"parameters\":[]}},\"name\":\"SomeService\",\"owners\":[\"anonymous\",\"akphi\"],\"package\":\"service\",\"pattern\":\"/9566f101-2108-408f-863f-6d7e154dc17a\",\"postValidations\":[],\"stereotypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"Person\",\"originalMilestonedProperties\":[],\"package\":\"test::legend::blank_prod::v2_0_0::blank\",\"properties\":[],\"qualifiedProperties\":[],\"sourceInformation\":{\"endColumn\":1,\"endLine\":3,\"sourceId\":\"\",\"startColumn\":1,\"startLine\":1},\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]}],\"origin\":{\"_type\":\"pointer\",\"sdlcInfo\":{\"_type\":\"alloy\",\"baseVersion\":\"2.0.0\",\"packageableElementPointers\":[],\"project\":\"test.legend:blank-prod\",\"version\":\"none\"},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}", modelContextDataAsString); + Assertions.assertNotNull(modelContextDataAsString); + Assertions.assertEquals("{\"_type\":\"data\",\"elements\":[{\"_type\":\"service\",\"autoActivateUpdates\":true,\"documentation\":\"\",\"execution\":{\"_type\":\"pureMultiExecution\",\"executionKey\":\"env\",\"executionParameters\":[{\"key\":\"PROD\",\"mapping\":\"mapping::SomeMapping\",\"runtime\":{\"_type\":\"runtimePointer\",\"runtime\":\"runtime::H2Runtime\"}},{\"key\":\"DEV\",\"mapping\":\"mapping::SomeMapping\",\"runtime\":{\"_type\":\"runtimePointer\",\"runtime\":\"runtime::H2Runtime\"}}],\"func\":{\"_type\":\"lambda\",\"body\":[{\"_type\":\"func\",\"function\":\"project\",\"parameters\":[{\"_type\":\"func\",\"function\":\"getAll\",\"parameters\":[{\"_type\":\"packageableElementPtr\",\"fullPath\":\"domain::COVIDData\"}]},{\"_type\":\"collection\",\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"values\":[{\"_type\":\"lambda\",\"body\":[{\"_type\":\"property\",\"parameters\":[{\"_type\":\"var\",\"name\":\"x\"}],\"property\":\"cases\"}],\"parameters\":[{\"_type\":\"var\",\"name\":\"x\"}]}]},{\"_type\":\"collection\",\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"values\":[{\"_type\":\"string\",\"value\":\"Cases\"}]}]}],\"parameters\":[]}},\"name\":\"SomeService\",\"owners\":[\"anonymous\",\"akphi\"],\"package\":\"service\",\"pattern\":\"/9566f101-2108-408f-863f-6d7e154dc17a\",\"postValidations\":[],\"stereotypes\":[],\"taggedValues\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"Person\",\"originalMilestonedProperties\":[],\"package\":\"test::legend::blank_prod::v2_0_0::blank\",\"properties\":[],\"qualifiedProperties\":[],\"sourceInformation\":{\"endColumn\":1,\"endLine\":3,\"sourceId\":\"\",\"startColumn\":1,\"startLine\":1},\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]}],\"origin\":{\"_type\":\"pointer\",\"sdlcInfo\":{\"_type\":\"alloy\",\"baseVersion\":\"2.0.0\",\"packageableElementPointers\":[],\"project\":\"test.legend:blank-prod\",\"version\":\"none\"},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}", modelContextDataAsString); } @Test @@ -200,22 +200,22 @@ public void canGetEntitiesForProjectAsPureModelContextDataWithMetricsStored() { getPureModelContextDataAsString("examples.metadata", "test", "2.3.1", CLIENT_VERSION, true, true); metricsHandler.persist(metricsRegistry); - Assert.assertEquals(metrics.getAll().size(), 4); - Assert.assertNotNull(metrics.get("examples.metadata", "test-dependencies", "1.0.0").get(0).getLastQueryTime()); - Assert.assertNotNull(metrics.get("examples.metadata", "test", "2.3.1").get(0).getLastQueryTime()); + Assertions.assertEquals(metrics.getAll().size(), 4); + Assertions.assertNotNull(metrics.get("examples.metadata", "test-dependencies", "1.0.0").get(0).getLastQueryTime()); + Assertions.assertNotNull(metrics.get("examples.metadata", "test", "2.3.1").get(0).getLastQueryTime()); } @Test public void canGetEntitiesAsPureModelContextDataWithHeadVersionAlias() { String modelContextDataAsString = getPureModelContextDataAsString(TEST_GROUP_ID, "test", "head", CLIENT_VERSION, false, true); - Assert.assertNotNull(modelContextDataAsString); - Assert.assertEquals("{\"_type\":\"data\",\"elements\":[{\"_type\":\"class\",\"constraints\":[],\"name\":\"ClassWithDependency\",\"originalMilestonedProperties\":[],\"package\":\"examples::metadata::test\",\"properties\":[{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"stereotypes\":[],\"taggedValues\":[]}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"profile\",\"name\":\"TestProfile\",\"package\":\"examples::metadata::test\",\"stereotypes\":[],\"tags\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"ClientBasic\",\"originalMilestonedProperties\":[],\"package\":\"examples::metadata::test\",\"properties\":[{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Integer\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"EntityId\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Boolean\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IsActive\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Float\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"RiskScore\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"StrictDate\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IncorporationDate\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"OptionalAlternativeName\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"newProperty\",\"stereotypes\":[],\"taggedValues\":[]}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"profile\",\"name\":\"TestProfileTwo\",\"package\":\"examples::metadata::test::subpackage\",\"stereotypes\":[],\"tags\":[]}],\"origin\":{\"_type\":\"pointer\",\"sdlcInfo\":{\"_type\":\"alloy\",\"baseVersion\":\"master-SNAPSHOT\",\"packageableElementPointers\":[],\"project\":\"examples.metadata:test\",\"version\":\"none\"},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}", modelContextDataAsString); + Assertions.assertNotNull(modelContextDataAsString); + Assertions.assertEquals("{\"_type\":\"data\",\"elements\":[{\"_type\":\"class\",\"constraints\":[],\"name\":\"ClassWithDependency\",\"originalMilestonedProperties\":[],\"package\":\"examples::metadata::test\",\"properties\":[{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"stereotypes\":[],\"taggedValues\":[]}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"profile\",\"name\":\"TestProfile\",\"package\":\"examples::metadata::test\",\"stereotypes\":[],\"tags\":[]},{\"_type\":\"class\",\"constraints\":[],\"name\":\"ClientBasic\",\"originalMilestonedProperties\":[],\"package\":\"examples::metadata::test\",\"properties\":[{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"Name\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Integer\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"EntityId\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Boolean\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IsActive\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"Float\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"RiskScore\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"StrictDate\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":1,\"upperBound\":1},\"name\":\"IncorporationDate\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"OptionalAlternativeName\",\"stereotypes\":[],\"taggedValues\":[]},{\"genericType\":{\"multiplicityArguments\":[],\"rawType\":{\"_type\":\"packageableType\",\"fullPath\":\"String\"},\"typeArguments\":[],\"typeVariableValues\":[]},\"multiplicity\":{\"lowerBound\":0,\"upperBound\":1},\"name\":\"newProperty\",\"stereotypes\":[],\"taggedValues\":[]}],\"qualifiedProperties\":[],\"stereotypes\":[],\"superTypes\":[],\"taggedValues\":[]},{\"_type\":\"profile\",\"name\":\"TestProfileTwo\",\"package\":\"examples::metadata::test::subpackage\",\"stereotypes\":[],\"tags\":[]}],\"origin\":{\"_type\":\"pointer\",\"sdlcInfo\":{\"_type\":\"alloy\",\"baseVersion\":\"master-SNAPSHOT\",\"packageableElementPointers\":[],\"project\":\"examples.metadata:test\",\"version\":\"none\"},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}},\"serializer\":{\"name\":\"pure\",\"version\":\"vX_X_X\"}}", modelContextDataAsString); } @Test public void testErrorThrownWhenIncorrectClientVersionProvided() { - Assert.assertThrows(IllegalArgumentException.class, () -> getPureModelContextDataAsString("examples.metadata", "test", "lastest", "dummy_version", false, true)); + Assertions.assertThrows(IllegalArgumentException.class, () -> getPureModelContextDataAsString("examples.metadata", "test", "lastest", "dummy_version", false, true)); } } diff --git a/legend-depot-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/TestStoreMongo.java b/legend-depot-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/TestStoreMongo.java index 5077dd749..403490215 100644 --- a/legend-depot-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/TestStoreMongo.java +++ b/legend-depot-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/TestStoreMongo.java @@ -22,7 +22,7 @@ import de.bwaldvogel.mongo.backend.memory.MemoryBackend; import org.finos.legend.depot.store.model.HasIdentifier; import org.finos.legend.depot.store.mongo.core.BaseMongo; -import org.junit.After; +import org.junit.jupiter.api.AfterEach; public abstract class TestStoreMongo { @@ -30,7 +30,7 @@ public abstract class TestStoreMongo private MongoClient mongoClient = new MongoClient(new ServerAddress(server.bind())); protected MongoDatabase mongoProvider = mongoClient.getDatabase("test-db"); - @After + @AfterEach public void tearDownData() { this.mongoProvider.drop(); diff --git a/pom.xml b/pom.xml index 90a84c006..350e920a5 100644 --- a/pom.xml +++ b/pom.xml @@ -136,8 +136,9 @@ 2.4.2 4.13.1 - junit - junit + org.junit.jupiter + junit-jupiter-engine + 5.9.3 3.9.0 3.8.3 @@ -1229,6 +1230,12 @@ ${junit.groupId} ${junit.artifactId} + ${junit5-version} + test + + + junit + junit ${junit.version} test