Search in sources :

Example 1 with Truth8

use of com.google.common.truth.Truth8 in project cloud-opensource-java by GoogleCloudPlatform.

the class ClassPathBuilderTest method testResolve_removingDuplicates.

@Test
public void testResolve_removingDuplicates() throws InvalidVersionSpecificationException {
    Artifact grpcArtifact = new DefaultArtifact("io.grpc:grpc-auth:1.15.1");
    ClassPathResult result = classPathBuilder.resolve(ImmutableList.of(grpcArtifact), true, DependencyMediation.MAVEN);
    ImmutableList<ClassPathEntry> classPath = result.getClassPath();
    long jsr305Count = classPath.stream().filter(path -> path.toString().contains("jsr305")).count();
    Truth.assertWithMessage("There should not be duplicated versions of jsr305").that(jsr305Count).isEqualTo(1);
    Optional<ClassPathEntry> opencensusApiPathFound = classPath.stream().filter(path -> path.toString().contains("opencensus-api")).findFirst();
    Truth8.assertThat(opencensusApiPathFound).isPresent();
    ClassPathEntry opencensusApiPath = opencensusApiPathFound.get();
    Truth.assertWithMessage("Opencensus API should have multiple dependency paths").that(result.getDependencyPaths(opencensusApiPath).size()).isGreaterThan(1);
}
Also used : Bom(com.google.cloud.tools.opensource.dependencies.Bom) ImmutableSet(com.google.common.collect.ImmutableSet) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Assert.assertNotNull(org.junit.Assert.assertNotNull) Artifact(org.eclipse.aether.artifact.Artifact) IOException(java.io.IOException) Test(org.junit.Test) Truth.assertThat(com.google.common.truth.Truth.assertThat) Collectors(java.util.stream.Collectors) Correspondence(com.google.common.truth.Correspondence) InvalidVersionSpecificationException(org.eclipse.aether.version.InvalidVersionSpecificationException) Truth(com.google.common.truth.Truth) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) RepositoryException(org.eclipse.aether.RepositoryException) Truth8(com.google.common.truth.Truth8) Optional(java.util.Optional) Assert.fail(org.junit.Assert.fail) UnresolvableArtifactProblem(com.google.cloud.tools.opensource.dependencies.UnresolvableArtifactProblem) Assert.assertEquals(org.junit.Assert.assertEquals) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Test(org.junit.Test)

Aggregations

Bom (com.google.cloud.tools.opensource.dependencies.Bom)1 UnresolvableArtifactProblem (com.google.cloud.tools.opensource.dependencies.UnresolvableArtifactProblem)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Correspondence (com.google.common.truth.Correspondence)1 Truth (com.google.common.truth.Truth)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 Truth8 (com.google.common.truth.Truth8)1 IOException (java.io.IOException)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 RepositoryException (org.eclipse.aether.RepositoryException)1 Artifact (org.eclipse.aether.artifact.Artifact)1 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)1 InvalidVersionSpecificationException (org.eclipse.aether.version.InvalidVersionSpecificationException)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Assert.fail (org.junit.Assert.fail)1 Test (org.junit.Test)1