Skip to content

Commit

Permalink
Replace junit4 with junit5.jupiter.api for tests (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
yash0024 authored Jan 9, 2025
1 parent 1251ee8 commit 27bd8bc
Show file tree
Hide file tree
Showing 53 changed files with 1,353 additions and 1,346 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand All @@ -76,7 +76,7 @@ public void returnsNoVersionsIfTheyDontExists()
}
catch (Exception e)
{
Assert.assertTrue(e instanceof ArtifactNotFoundException);
Assertions.assertTrue(e instanceof ArtifactNotFoundException);
}
}

Expand All @@ -85,39 +85,39 @@ public void returnsNoVersionsIfTheyDontExists()
public void canGetDependencies()
{
Set<ArtifactDependency> 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<ArtifactDependency> 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<ArtifactDependency> 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<File> 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<File> 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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -47,8 +47,8 @@ List<File> 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());

}

Expand All @@ -57,8 +57,8 @@ public void canResolveEntitiesInJar()
{

List<Entity> 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());

}

Expand All @@ -67,16 +67,16 @@ public void canResolveEntitiesInJar()
public void canResolveDependencies()
{
Set<ArtifactDependency> dependencies = repository.findDependenciesByArtifactType(ArtifactType.ENTITIES, TEST_GROUP_ID, "test", "2.0.0");
Assert.assertEquals(1, dependencies.size());
Assertions.assertEquals(1, dependencies.size());
List<File> 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<ArtifactDependency> dependenciesForVersionedEntities = repository.findDependenciesByArtifactType(ArtifactType.VERSIONED_ENTITIES, TEST_GROUP_ID, "test", "2.0.0");
Assert.assertEquals(1, dependenciesForVersionedEntities.size());
Assertions.assertEquals(1, dependenciesForVersionedEntities.size());
List<File> 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());


}
Expand All @@ -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);
}
}
Loading

0 comments on commit 27bd8bc

Please sign in to comment.