Search in sources :

Example 26 with DependencyGraph

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

the class CondaListParserTest method largeParseTest.

@Test
public void largeParseTest() {
    final String condaInfoJson = testUtil.getResourceAsUTF8String("/conda/condaInfo.json");
    final String condaListJson = testUtil.getResourceAsUTF8String("/conda/condaListLarge.json");
    final DependencyGraph dependencyGraph = condaListParser.parse(condaListJson, condaInfoJson);
    DependencyGraphResourceTestUtil.assertGraph("/conda/condaListLargeExpected_graph.json", dependencyGraph);
}
Also used : DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

Example 27 with DependencyGraph

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

the class CondaListParserTest method smallParseTest.

@Test
public void smallParseTest() {
    final String condaInfoJson = testUtil.getResourceAsUTF8String("/conda/condaInfo.json");
    final String condaListJson = testUtil.getResourceAsUTF8String("/conda/condaListSmall.json");
    final DependencyGraph dependencyGraph = condaListParser.parse(condaListJson, condaInfoJson);
    DependencyGraphResourceTestUtil.assertGraph("/conda/condaListSmallExpected_graph.json", dependencyGraph);
}
Also used : DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

Example 28 with DependencyGraph

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

the class GoVendorExtractorTest method test.

@Test
public void test() {
    GoVendorExtractor extractor = new GoVendorExtractor(new Gson(), new ExternalIdFactory());
    Extraction extraction = extractor.extract(new File("src/test/resources/go"), new File("src/test/resources/go/vendor/vendor.json"));
    DependencyGraph graph = extraction.codeLocations.get(0).getDependencyGraph();
    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) Extraction(com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) File(java.io.File) Test(org.junit.Test)

Example 29 with DependencyGraph

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

the class GemlockNodeParserTest method testParsingGemfileLock.

@Test
public void testParsingGemfileLock() {
    final String text = testUtils.getResourceAsUTF8String("/rubygems/Gemfile.lock");
    final List<String> gemfileLockContents = Arrays.asList(text.split("\n"));
    final GemlockParser gemlockNodeParser = new GemlockParser(new ExternalIdFactory());
    final DependencyGraph dependencyGraph = gemlockNodeParser.parseProjectDependencies(gemfileLockContents);
    DependencyGraphResourceTestUtil.assertGraph("/rubygems/expectedParser_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 30 with DependencyGraph

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

the class GemlockNodeParserTest method testParsingSmallGemfileLock.

@Test
public void testParsingSmallGemfileLock() {
    final String text = testUtils.getResourceAsUTF8String("/rubygems/small_gemfile_lock");
    final List<String> gemfileLockContents = Arrays.asList(text.split("\n"));
    final GemlockParser gemlockNodeParser = new GemlockParser(new ExternalIdFactory());
    final DependencyGraph dependencyGraph = gemlockNodeParser.parseProjectDependencies(gemfileLockContents);
    DependencyGraphResourceTestUtil.assertGraph("/rubygems/expectedSmallParser_graph.json", dependencyGraph);
}
Also used : 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