Search in sources :

Example 21 with DependencyGraph

use of com.synopsys.integration.bdio.graph.DependencyGraph in project hub-detect by blackducksoftware.

the class GradleReportParserTest method complexTest.

@Test
public void complexTest() throws IOException {
    final DetectCodeLocation codeLocation = build("src/test/resources/gradle/parse-tests/complex_dependencyGraph.txt");
    final DependencyGraph graph = codeLocation.getDependencyGraph();
    assertHasMavenGav(graph, "non-project:with-nested:1.0.0");
    assertHasMavenGav(graph, "solo:component:4.12");
    assertHasMavenGav(graph, "some.group:child:2.2.2");
    assertHasMavenGav(graph, "terminal:child:6.2.3");
    assertDoesNotHave(graph, "child-project");
    assertDoesNotHave(graph, "nested-parent");
    assertDoesNotHave(graph, "spring-webflux");
    assertDoesNotHave(graph, "spring-beans");
    assertDoesNotHave(graph, "spring-core");
    assertDoesNotHave(graph, "spring-web");
    assertDoesNotHave(graph, "should-suppress");
    assertHasRootMavenGavs(graph, "solo:component:4.12", "non-project:with-nested:1.0.0", "some.group:parent:5.0.0", "terminal:child:6.2.3");
    assertParentHasChildMavenGav("some.group:parent:5.0.0", graph, "some.group:child:2.2.2");
}
Also used : DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

Example 22 with DependencyGraph

use of com.synopsys.integration.bdio.graph.DependencyGraph in project hub-detect by blackducksoftware.

the class CocoapodsPackagerTest method complexTest.

@Test
public void complexTest() throws IOException {
    final String podlockText = testUtil.getResourceAsUTF8String("/cocoapods/complexPodfile.lock");
    final DependencyGraph projectDependencies = podlockParser.extractDependencyGraph(podlockText);
    DependencyGraphResourceTestUtil.assertGraph("/cocoapods/complexExpected_graph.json", projectDependencies);
}
Also used : DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

Example 23 with DependencyGraph

use of com.synopsys.integration.bdio.graph.DependencyGraph in project hub-detect by blackducksoftware.

the class GopkgLockParserTest method gopkgParserTest.

@Test
public void gopkgParserTest() throws IOException {
    final GopkgLockParser gopkgLockParser = new GopkgLockParser(new ExternalIdFactory());
    final String gopkgLockContents = IOUtils.toString(getClass().getResourceAsStream("/go/Gopkg.lock"), StandardCharsets.UTF_8);
    final DependencyGraph dependencyGraph = gopkgLockParser.parseDepLock(gopkgLockContents);
    Assert.assertNotNull(dependencyGraph);
    DependencyGraphResourceTestUtil.assertGraph("/go/Go_GopkgExpected_graph.json", dependencyGraph);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

Example 24 with DependencyGraph

use of com.synopsys.integration.bdio.graph.DependencyGraph in project hub-detect by blackducksoftware.

the class CpanListParserTest method makeDependencyNodesTest.

@Test
public void makeDependencyNodesTest() {
    final DependencyGraph dependencyGraph = cpanListParser.parse(cpanListText, showDepsText);
    DependencyGraphResourceTestUtil.assertGraph("/cpan/expectedDependencyNodes_graph.json", dependencyGraph);
}
Also used : DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

Example 25 with DependencyGraph

use of com.synopsys.integration.bdio.graph.DependencyGraph in project hub-detect by blackducksoftware.

the class GoVendorJsonParserTest method test.

@Test
public void test() throws IOException {
    ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    GoVendorJsonParser parser = new GoVendorJsonParser(externalIdFactory);
    File vendorJsonFile = new File("src/test/resources/go/vendor/vendor.json");
    String vendorJsonContents = FileUtils.readFileToString(vendorJsonFile, StandardCharsets.UTF_8);
    DependencyGraph graph = parser.parseVendorJson(new Gson(), vendorJsonContents);
    assertEquals(2, graph.getRootDependencies().size());
    boolean foundErrorsPkg = false;
    boolean foundMathPkg = false;
    for (Dependency dep : graph.getRootDependencies()) {
        if ("github.com/pkg/errors".equals(dep.name)) {
            foundErrorsPkg = true;
            assertEquals("github.com/pkg/errors", dep.externalId.name);
            assertEquals("059132a15dd08d6704c67711dae0cf35ab991756", dep.externalId.version);
        }
        if ("github.com/pkg/math".equals(dep.name)) {
            foundMathPkg = true;
            assertEquals("github.com/pkg/math", dep.externalId.name);
            assertEquals("f2ed9e40e245cdeec72c4b642d27ed4553f90667", dep.externalId.version);
        }
    }
    assertTrue(foundErrorsPkg);
    assertTrue(foundMathPkg);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) Gson(com.google.gson.Gson) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) File(java.io.File) Test(org.junit.Test)

Aggregations

DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)46 Test (org.junit.Test)26 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)21 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)19 DetectCodeLocation (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation)15 ArrayList (java.util.ArrayList)13 Extraction (com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction)12 File (java.io.File)9 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)6 Forge (com.synopsys.integration.bdio.model.Forge)5 ExecutableOutput (com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput)4 MutableMapDependencyGraph (com.synopsys.integration.bdio.graph.MutableMapDependencyGraph)4 MutableDependencyGraph (com.synopsys.integration.bdio.graph.MutableDependencyGraph)3 LazyExternalIdDependencyGraphBuilder (com.synopsys.integration.bdio.graph.builder.LazyExternalIdDependencyGraphBuilder)3 SimpleBdioDocument (com.synopsys.integration.bdio.model.SimpleBdioDocument)3 NameDependencyId (com.synopsys.integration.bdio.model.dependencyid.NameDependencyId)3 NameVersion (com.synopsys.integration.util.NameVersion)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 Executable (com.blackducksoftware.integration.hub.detect.util.executable.Executable)2