Search in sources :

Example 26 with GraphAssert

use of com.synopsys.integration.detectable.util.graph.GraphAssert in project synopsys-detect by blackducksoftware.

the class GradleReportParserFunctionalTest method testUnresolvedConfigurations.

@Test
void testUnresolvedConfigurations() {
    Optional<CodeLocation> codeLocation = buildCodeLocation("/gradle/gradle_implementations_dependencyGraph.txt", false);
    Assertions.assertTrue(codeLocation.isPresent());
    DependencyGraph dependencyGraph = codeLocation.get().getDependencyGraph();
    GraphAssert graphAssert = new GraphAssert(Forge.MAVEN, dependencyGraph);
    graphAssert.hasRootSize(0);
    System.out.println(new GsonBuilder().setPrettyPrinting().create().toJson(codeLocation.get()));
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) MavenGraphAssert(com.synopsys.integration.detectable.util.graph.MavenGraphAssert) GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) GsonBuilder(com.google.gson.GsonBuilder) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 27 with GraphAssert

use of com.synopsys.integration.detectable.util.graph.GraphAssert in project synopsys-detect by blackducksoftware.

the class GradleReportParserFunctionalTest method testImplementationsGraph.

@Test
void testImplementationsGraph() {
    Optional<CodeLocation> codeLocation = buildCodeLocation("/gradle/gradle_implementations_dependencyGraph.txt", true);
    Assertions.assertTrue(codeLocation.isPresent());
    DependencyGraph dependencyGraph = codeLocation.get().getDependencyGraph();
    GraphAssert graphAssert = new GraphAssert(Forge.MAVEN, dependencyGraph);
    graphAssert.hasRootSize(7);
    System.out.println(new GsonBuilder().setPrettyPrinting().create().toJson(codeLocation.get()));
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) MavenGraphAssert(com.synopsys.integration.detectable.util.graph.MavenGraphAssert) GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) GsonBuilder(com.google.gson.GsonBuilder) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 28 with GraphAssert

use of com.synopsys.integration.detectable.util.graph.GraphAssert in project synopsys-detect by blackducksoftware.

the class FinalStepTransformJsonProtoHaskellCabalLibrariesToHackageTest method testStep.

@Test
public void testStep() throws IntegrationException, IOException {
    File jsonProtoFile = new File("src/test/resources/detectables/functional/bazel/jsonProtoForHaskellCabalLibraries.txt");
    String jsonProtoHaskellCabalLibrary = FileUtils.readFileToString(jsonProtoFile, StandardCharsets.UTF_8);
    FinalStepTransformJsonProtoHaskellCabalLibrariesToHackage step = new FinalStepTransformJsonProtoHaskellCabalLibrariesToHackage(new HaskellCabalLibraryJsonProtoParser(new Gson()), new ExternalIdFactory());
    List<String> input = new ArrayList<>(1);
    input.add(jsonProtoHaskellCabalLibrary);
    List<Dependency> dependencies = step.finish(input);
    DependencyGraph dependencyGraph = new BasicDependencyGraph();
    for (Dependency dependency : dependencies) {
        dependencyGraph.addChildToRoot(dependency);
    }
    Forge hackageForge = new Forge("/", "hackage");
    GraphAssert graphAssert = new GraphAssert(hackageForge, dependencyGraph);
    graphAssert.hasRootSize(1);
    ExternalId expectedExternalId = new ExternalIdFactory().createNameVersionExternalId(hackageForge, "colour", "2.3.5");
    graphAssert.hasRootDependency(expectedExternalId);
}
Also used : GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) Forge(com.synopsys.integration.bdio.model.Forge) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) HaskellCabalLibraryJsonProtoParser(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.HaskellCabalLibraryJsonProtoParser) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) FinalStepTransformJsonProtoHaskellCabalLibrariesToHackage(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.FinalStepTransformJsonProtoHaskellCabalLibrariesToHackage) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 29 with GraphAssert

use of com.synopsys.integration.detectable.util.graph.GraphAssert in project synopsys-detect by blackducksoftware.

the class PackageResolvedTransformerTest method testHttpWithGit.

@Test
void testHttpWithGit() {
    ResolvedPackage auth0Package = new ResolvedPackage("Auth0", "http://github.com/auth0/Auth0.swift.git", new PackageState(null, "8e8a6b0337a27a3342beb72b5407141fdd4a7860", "1.35.0"));
    PackageResolved packageResolved = createPackageResolved(auth0Package);
    PackageResolvedTransformer transformer = new PackageResolvedTransformer(externalIdFactory);
    DependencyGraph dependencyGraph = transformer.transform(packageResolved);
    GraphAssert graphAssert = new GraphAssert(Forge.GITHUB, dependencyGraph);
    ExternalId auth0 = externalIdFactory.createNameVersionExternalId(Forge.GITHUB, "auth0/Auth0.swift", "1.35.0");
    graphAssert.hasRootDependency(auth0);
    graphAssert.hasRootSize(1);
}
Also used : PackageResolved(com.synopsys.integration.detectable.detectables.xcode.model.PackageResolved) PackageResolvedTransformer(com.synopsys.integration.detectable.detectables.xcode.process.PackageResolvedTransformer) GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) PackageState(com.synopsys.integration.detectable.detectables.xcode.model.PackageState) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) ResolvedPackage(com.synopsys.integration.detectable.detectables.xcode.model.ResolvedPackage) Test(org.junit.jupiter.api.Test)

Example 30 with GraphAssert

use of com.synopsys.integration.detectable.util.graph.GraphAssert in project synopsys-detect by blackducksoftware.

the class PackageResolvedTransformerTest method testHttpsWithGit.

@Test
void testHttpsWithGit() {
    ResolvedPackage swiftCollectionsPackage = new ResolvedPackage("swift-collections", "https://github.com/apple/swift-collections.git", new PackageState(null, "2d33a0ea89c961dcb2b3da2157963d9c0370347e", "1.0.1"));
    PackageResolved packageResolved = createPackageResolved(swiftCollectionsPackage);
    PackageResolvedTransformer transformer = new PackageResolvedTransformer(externalIdFactory);
    DependencyGraph dependencyGraph = transformer.transform(packageResolved);
    GraphAssert graphAssert = new GraphAssert(Forge.GITHUB, dependencyGraph);
    ExternalId swiftCollections = externalIdFactory.createNameVersionExternalId(Forge.GITHUB, "apple/swift-collections", "1.0.1");
    graphAssert.hasRootDependency(swiftCollections);
    graphAssert.hasRootSize(1);
}
Also used : PackageResolved(com.synopsys.integration.detectable.detectables.xcode.model.PackageResolved) PackageResolvedTransformer(com.synopsys.integration.detectable.detectables.xcode.process.PackageResolvedTransformer) GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) PackageState(com.synopsys.integration.detectable.detectables.xcode.model.PackageState) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) ResolvedPackage(com.synopsys.integration.detectable.detectables.xcode.model.ResolvedPackage) Test(org.junit.jupiter.api.Test)

Aggregations

GraphAssert (com.synopsys.integration.detectable.util.graph.GraphAssert)30 Test (org.junit.jupiter.api.Test)30 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)26 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)9 FunctionalTest (com.synopsys.integration.detectable.annotations.FunctionalTest)7 UnitTest (com.synopsys.integration.detectable.annotations.UnitTest)7 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)7 PackageResolved (com.synopsys.integration.detectable.detectables.swift.lock.data.PackageResolved)5 PackageState (com.synopsys.integration.detectable.detectables.swift.lock.data.PackageState)5 ResolvedPackage (com.synopsys.integration.detectable.detectables.swift.lock.data.ResolvedPackage)5 PackageResolved (com.synopsys.integration.detectable.detectables.xcode.model.PackageResolved)5 PackageState (com.synopsys.integration.detectable.detectables.xcode.model.PackageState)5 ResolvedPackage (com.synopsys.integration.detectable.detectables.xcode.model.ResolvedPackage)5 PackageResolvedTransformer (com.synopsys.integration.detectable.detectables.xcode.process.PackageResolvedTransformer)5 Extraction (com.synopsys.integration.detectable.extraction.Extraction)5 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)4 NpmPackagerResult (com.synopsys.integration.detectable.detectables.npm.lockfile.result.NpmPackagerResult)4 InputStream (java.io.InputStream)4 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)3 GsonBuilder (com.google.gson.GsonBuilder)2