diff --git a/dependencies/src/test/java/com/google/cloud/tools/opensource/dependencies/RepositoryUtilityTest.java b/dependencies/src/test/java/com/google/cloud/tools/opensource/dependencies/RepositoryUtilityTest.java index 6c8635772a..bff8373465 100644 --- a/dependencies/src/test/java/com/google/cloud/tools/opensource/dependencies/RepositoryUtilityTest.java +++ b/dependencies/src/test/java/com/google/cloud/tools/opensource/dependencies/RepositoryUtilityTest.java @@ -22,6 +22,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; + import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.Artifact; @@ -57,16 +58,25 @@ public void testReadBom_coordinates() throws ArtifactDescriptorException { } @Test - public void testReadBom_path() throws MavenRepositoryException { + public void testReadBom_path() throws MavenRepositoryException, ArtifactDescriptorException { Path pomFile = Paths.get("..", "boms", "cloud-oss-bom", "pom.xml"); - Bom bom = RepositoryUtility.readBom(pomFile); + Bom currentBom = RepositoryUtility.readBom(pomFile); + Bom oldBom = RepositoryUtility.readBom("com.google.cloud:libraries-bom:2.6.0"); + ImmutableList currentArtifacts = currentBom.getManagedDependencies(); + ImmutableList oldArtifacts = oldBom.getManagedDependencies(); + + String coordinates = currentBom.getCoordinates(); + Truth.assertThat(coordinates).startsWith("com.google.cloud:libraries-bom:"); + Truth.assertThat(coordinates).endsWith("-SNAPSHOT"); - ImmutableList artifacts = bom.getManagedDependencies(); - Assert.assertEquals(219, artifacts.size()); - String coordinates = bom.getCoordinates(); - Assert.assertTrue(coordinates.startsWith("com.google.cloud:libraries-bom:")); - Assert.assertTrue(coordinates.endsWith("-SNAPSHOT")); + // This is a characterization test to verify that the managed dependencies haven't changed. + // However sometimes this list does change. If so, we want to + // output the specific difference so we can manually verify whether + // the changes make sense. When they do make sense, we update the test. + if (currentArtifacts.size() != 217) { + Truth.assertThat(currentArtifacts).containsExactlyElementsIn(oldArtifacts); + } } @Test @@ -74,7 +84,9 @@ public void testFindVersions() throws MavenRepositoryException { RepositorySystem system = RepositoryUtility.newRepositorySystem(); ImmutableList versions = RepositoryUtility.findVersions(system, "com.google.cloud", "libraries-bom"); - Truth.assertThat(versions).containsAtLeast("1.1.0", "1.1.1", "1.2.0", "2.0.0").inOrder(); + Truth.assertThat(versions) + .containsAtLeast("1.1.0", "1.1.1", "1.2.0", "2.0.0", "2.4.0", "2.5.0", "2.6.0") + .inOrder(); } @Test