use of com.google.cloud.tools.opensource.dependencies.Bom 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())));
}
use of com.google.cloud.tools.opensource.dependencies.Bom in project cloud-opensource-java by GoogleCloudPlatform.
the class FreemarkerTest method testCountFailures.
@Test
public void testCountFailures() throws IOException, TemplateException, ParsingException {
Configuration configuration = DashboardMain.configureFreemarker();
Artifact artifact1 = new DefaultArtifact("io.grpc:grpc-context:1.15.0");
ArtifactResults results1 = new ArtifactResults(artifact1);
results1.addResult("Linkage Errors", 56);
Artifact artifact2 = new DefaultArtifact("grpc:grpc:1.15.0");
ArtifactResults results2 = new ArtifactResults(artifact2);
results2.addResult("Linkage Errors", 0);
List<ArtifactResults> table = ImmutableList.of(results1, results2);
List<DependencyGraph> globalDependencies = ImmutableList.of();
DashboardMain.generateDashboard(configuration, outputDirectory, table, globalDependencies, symbolProblemTable, new ClassPathResult(new AnnotatedClassPath(), ImmutableList.of()), new Bom("mock:artifact:1.6.7", null));
Path dashboardHtml = outputDirectory.resolve("index.html");
Assert.assertTrue(Files.isRegularFile(dashboardHtml));
Document document = builder.build(dashboardHtml.toFile());
// xom's query cannot specify partial class field, e.g., 'statistic-item'
Nodes counts = document.query("//div[@class='container']/div/h2");
Assert.assertTrue(counts.size() > 0);
for (int i = 0; i < counts.size(); i++) {
Integer.parseInt(counts.get(i).getValue().trim());
}
// Linkage Errors
Truth.assertThat(counts.get(1).getValue().trim()).isEqualTo("1");
}
use of com.google.cloud.tools.opensource.dependencies.Bom in project cloud-opensource-java by GoogleCloudPlatform.
the class BomContentTest method checkBom.
private void checkBom(Path bomPath) throws Exception {
Bom bom = Bom.readBom(bomPath);
List<Artifact> artifacts = bom.getManagedDependencies();
for (Artifact artifact : artifacts) {
assertReachable(buildMavenCentralUrl(artifact));
}
assertNoDowngradeRule(bom);
assertUniqueClasses(artifacts);
assertBomIsImported(bom);
}
use of com.google.cloud.tools.opensource.dependencies.Bom in project cloud-opensource-java by GoogleCloudPlatform.
the class ClassPathBuilderTest method testArtifactsWithClassifiers.
@Test
public void testArtifactsWithClassifiers() throws Exception {
String pomFile = "bom-with-classifier-artifacts.pom";
Bom bom = Bom.readBom(TestHelper.absolutePathOfResource(pomFile));
ClassPathResult classPathResult = classPathBuilder.resolve(bom.getManagedDependencies(), true, DependencyMediation.MAVEN);
Truth.assertThat(classPathResult.getClassPath()).comparingElementsUsing(Correspondence.transforming((ClassPathEntry entry) -> entry.getArtifact().toString(), "has artifact coordinates")).contains("com.google.cloud:google-cloud-core:jar:tests:1.96.0");
}
use of com.google.cloud.tools.opensource.dependencies.Bom in project cloud-opensource-java by GoogleCloudPlatform.
the class GradleDependencyMediationTest method testMediation_withEnforcedPlatform.
@Test
public void testMediation_withEnforcedPlatform() throws InvalidVersionSpecificationException {
DependencyGraph graph = new DependencyGraph(null);
// The old version comes first in the graph.list
graph.addPath(new DependencyPath(null).append(new Dependency(artifactA1, "compile")));
graph.addPath(new DependencyPath(null).append(new Dependency(artifactA2, "compile")));
// The duplicate shouldn't appear in the class path
graph.addPath(new DependencyPath(null).append(new Dependency(artifactB1, "compile")));
GradleDependencyMediation mediation = GradleDependencyMediation.withEnforcedPlatform(new Bom("g:bom:1.0.0", ImmutableList.of(artifactA1)));
AnnotatedClassPath result = mediation.mediate(graph);
Truth.assertThat(result.getClassPath()).comparingElementsUsing(CLASS_PATH_ENTRY_TO_ARTIFACT).containsExactly(artifactA1, artifactB1).inOrder();
}
Aggregations