Search in sources :

Example 1 with Artifacts

use of com.google.cloud.tools.opensource.dependencies.Artifacts in project cloud-opensource-java by GoogleCloudPlatform.

the class LinkageMonitorTest method testBuildModelWithSnapshotBom_BomSnapshotUpdate.

@Test
public void testBuildModelWithSnapshotBom_BomSnapshotUpdate() throws ModelBuildingException, ArtifactResolutionException {
    // Linkage Monitor should update a BOM in Google Cloud Libraries BOM when it's available local
    // repository. This test case simulates the issue below where
    // google-cloud-bom:0.106.0-alpha-SNAPSHOT should provide gax:1.48.0.
    // https://github.com/GoogleCloudPlatform/cloud-opensource-java/issues/853
    // Libraries-bom:2.2.1 has google-cloud-bom:0.91.0-alpha, which has gax:1.44.0
    Model model = LinkageMonitor.buildModelWithSnapshotBom(system, session, "com.google.cloud:libraries-bom:2.2.1", ImmutableMap.of("com.google.cloud:google-cloud-bom", "0.106.0-alpha"));
    List<Dependency> dependencies = model.getDependencyManagement().getDependencies();
    // google-cloud-bom:0.106.0 has new artifacts such as google-cloud-gameservices
    assertEquals(224, dependencies.size());
    // google-cloud-bom:0.106.0-alpha has gax:1.48.0
    assertTrue(dependencies.stream().anyMatch(dependency -> "gax".equals(dependency.getArtifactId()) && "1.48.0".equals(dependency.getVersion())));
}
Also used : MavenRepositoryException(com.google.cloud.tools.opensource.dependencies.MavenRepositoryException) Bom(com.google.cloud.tools.opensource.dependencies.Bom) SymbolNotFoundProblem(com.google.cloud.tools.opensource.classpath.SymbolNotFoundProblem) Dependency(org.apache.maven.model.Dependency) AnnotatedClassPath(com.google.cloud.tools.opensource.classpath.AnnotatedClassPath) LinkageProblem(com.google.cloud.tools.opensource.classpath.LinkageProblem) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) ClassSymbol(com.google.cloud.tools.opensource.classpath.ClassSymbol) Correspondence.transforming(com.google.common.truth.Correspondence.transforming) ArtifactDescriptorException(org.eclipse.aether.resolution.ArtifactDescriptorException) Truth(com.google.common.truth.Truth) ImmutableList(com.google.common.collect.ImmutableList) Iterables.skip(com.google.common.collect.Iterables.skip) ClassFile(com.google.cloud.tools.opensource.classpath.ClassFile) Assert.fail(org.junit.Assert.fail) RepositoryUtility(com.google.cloud.tools.opensource.dependencies.RepositoryUtility) Path(java.nio.file.Path) ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) Before(org.junit.Before) ClassNotFoundProblem(com.google.cloud.tools.opensource.classpath.ClassNotFoundProblem) Artifacts(com.google.cloud.tools.opensource.dependencies.Artifacts) ImmutableSet(com.google.common.collect.ImmutableSet) Artifacts.toCoordinates(com.google.cloud.tools.opensource.dependencies.Artifacts.toCoordinates) Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) ImmutableMap(com.google.common.collect.ImmutableMap) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Assert.assertNotNull(org.junit.Assert.assertNotNull) ModelBuildingException(org.apache.maven.model.building.ModelBuildingException) ClassPathResult(com.google.cloud.tools.opensource.classpath.ClassPathResult) Assert.assertTrue(org.junit.Assert.assertTrue) MethodSymbol(com.google.cloud.tools.opensource.classpath.MethodSymbol) Set(java.util.Set) Artifact(org.eclipse.aether.artifact.Artifact) IOException(java.io.IOException) Test(org.junit.Test) File(java.io.File) DependencyPath(com.google.cloud.tools.opensource.dependencies.DependencyPath) List(java.util.List) RepositoryException(org.eclipse.aether.RepositoryException) Paths(java.nio.file.Paths) ClassPathEntry(com.google.cloud.tools.opensource.classpath.ClassPathEntry) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) Assert.assertEquals(org.junit.Assert.assertEquals) Model(org.apache.maven.model.Model) RepositorySystem(org.eclipse.aether.RepositorySystem) Model(org.apache.maven.model.Model) Dependency(org.apache.maven.model.Dependency) Test(org.junit.Test)

Aggregations

AnnotatedClassPath (com.google.cloud.tools.opensource.classpath.AnnotatedClassPath)1 ClassFile (com.google.cloud.tools.opensource.classpath.ClassFile)1 ClassNotFoundProblem (com.google.cloud.tools.opensource.classpath.ClassNotFoundProblem)1 ClassPathEntry (com.google.cloud.tools.opensource.classpath.ClassPathEntry)1 ClassPathResult (com.google.cloud.tools.opensource.classpath.ClassPathResult)1 ClassSymbol (com.google.cloud.tools.opensource.classpath.ClassSymbol)1 LinkageProblem (com.google.cloud.tools.opensource.classpath.LinkageProblem)1 MethodSymbol (com.google.cloud.tools.opensource.classpath.MethodSymbol)1 SymbolNotFoundProblem (com.google.cloud.tools.opensource.classpath.SymbolNotFoundProblem)1 Artifacts (com.google.cloud.tools.opensource.dependencies.Artifacts)1 Artifacts.toCoordinates (com.google.cloud.tools.opensource.dependencies.Artifacts.toCoordinates)1 Bom (com.google.cloud.tools.opensource.dependencies.Bom)1 DependencyPath (com.google.cloud.tools.opensource.dependencies.DependencyPath)1 MavenRepositoryException (com.google.cloud.tools.opensource.dependencies.MavenRepositoryException)1 RepositoryUtility (com.google.cloud.tools.opensource.dependencies.RepositoryUtility)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables.skip (com.google.common.collect.Iterables.skip)1