Search in sources :

Example 16 with DependencyGraph

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

the class RebarParserTest method testParseRebarTreeOutput.

@Test
public void testParseRebarTreeOutput() {
    final MutableMapDependencyGraph expectedGraph = new MutableMapDependencyGraph();
    final Dependency gitInnerParentDependency = buildDependency("git_inner_parent_dependency", "0.0.2");
    final Dependency hexInnerChildDependency = buildDependency("hex_inner_child_dependency", "0.3.0");
    final Dependency hexGrandchildDependency = buildDependency("hex_grandchild_dependency", "4.0.0");
    final Dependency gitInnerChildDependency = buildDependency("git_inner_child_dependency", "0.5.0");
    final Dependency gitGrandchildDependency = buildDependency("git_grandchild_dependency", "6.0.0");
    final Dependency gitOuterParentDependency = buildDependency("git_outer_parent_dependency", "0.0.7");
    final Dependency gitOuterChildDependency = buildDependency("git_outer_child_dependency", "0.8.0");
    expectedGraph.addChildrenToRoot(gitInnerParentDependency, gitOuterParentDependency);
    expectedGraph.addChildWithParent(hexInnerChildDependency, gitInnerParentDependency);
    expectedGraph.addChildWithParents(hexGrandchildDependency, hexInnerChildDependency);
    expectedGraph.addChildWithParent(gitInnerChildDependency, gitInnerParentDependency);
    expectedGraph.addChildWithParents(gitGrandchildDependency, gitInnerChildDependency);
    expectedGraph.addChildWithParents(gitOuterChildDependency, gitOuterParentDependency);
    final DetectCodeLocation codeLocation = build("/hex/dependencyTree.txt");
    final DependencyGraph actualGraph = codeLocation.getDependencyGraph();
    assertGraph(expectedGraph, actualGraph);
}
Also used : DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) Test(org.junit.Test)

Example 17 with DependencyGraph

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

the class PearDependencyTest method createPearDependencyNodeFromListTest.

@Test
public void createPearDependencyNodeFromListTest() {
    final String installedPackages = testUtil.getResourceAsUTF8String("/pear/installed-packages.txt");
    final ExecutableOutput exeOutput = new ExecutableOutput(installedPackages, "");
    final List<String> dependencyNames = Arrays.asList("Archive_Tar", "Console_Getopt", "Structures_Graph");
    final DependencyGraph actual = pearParser.createPearDependencyGraphFromList(exeOutput.getStandardOutputAsList(), dependencyNames);
    DependencyGraphResourceTestUtil.assertGraph("/pear/dependency-node-list_graph.json", actual);
}
Also used : ExecutableOutput(com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

Example 18 with DependencyGraph

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

the class RubygemsNodePackagerTest method findsAllVersions.

@Test
public void findsAllVersions() {
    // Finds all versions of the package not just the first matching architecture.
    final List<String> actualText = Arrays.asList(testUtils.getResourceAsUTF8String("/rubygems/Gemfile-rails.lock").split("\n"));
    final GemlockParser rubygemsNodePackager = new GemlockParser(new ExternalIdFactory());
    final DependencyGraph graph = rubygemsNodePackager.parseProjectDependencies(actualText);
    assertNoDependency("nokogiri", "", graph);
    assertDependency("nokogiri", "1.8.2", graph);
    assertDependency("nokogiri", "1.8.2-java", graph);
    assertDependency("nokogiri", "1.8.2-x86-mingw32", graph);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

Example 19 with DependencyGraph

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

the class RubygemsNodePackagerTest method packagerTest.

@Test
public void packagerTest() {
    final List<String> actualText = Arrays.asList(testUtils.getResourceAsUTF8String("/rubygems/Gemfile.lock").split("\n"));
    final GemlockParser rubygemsNodePackager = new GemlockParser(new ExternalIdFactory());
    final DependencyGraph projects = rubygemsNodePackager.parseProjectDependencies(actualText);
    Assert.assertEquals(8, projects.getRootDependencies().size());
    DependencyGraphResourceTestUtil.assertGraph("/rubygems/expectedPackager_graph.json", projects);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

Example 20 with DependencyGraph

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

the class VndrParserTest method vndrParserTest.

@Test
public void vndrParserTest() throws IOException {
    final TestUtil testUtil = new TestUtil();
    final VndrParser vndrParser = new VndrParser(new ExternalIdFactory());
    final String text = testUtil.getResourceAsUTF8String("/go/vendor.conf");
    final List<String> vendorConfContents = Arrays.asList(text.split("\r?\n"));
    final DependencyGraph dependencyGraph = vndrParser.parseVendorConf(vendorConfContents);
    Assert.assertNotNull(dependencyGraph);
    DependencyGraphResourceTestUtil.assertGraph("/go/Go_VndrExpected_graph.json", dependencyGraph);
}
Also used : DependencyGraphResourceTestUtil(com.blackducksoftware.integration.hub.detect.testutils.DependencyGraphResourceTestUtil) TestUtil(com.blackducksoftware.integration.hub.detect.testutils.TestUtil) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) 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