Search in sources :

Example 31 with DependencyGraph

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

the class YarnListParserTest method testThatYarnListWithOnlyTopLevelDependenciesIsParsedCorrectly.

@Test
public void testThatYarnListWithOnlyTopLevelDependenciesIsParsedCorrectly() {
    final List<String> designedYarnLock = new ArrayList<>();
    designedYarnLock.add("esprima@5.5.2:");
    designedYarnLock.add("  version \"5.5.2\"");
    designedYarnLock.add("");
    designedYarnLock.add("extsprintf@5.5.2:");
    designedYarnLock.add("  version \"5.5.2\"");
    designedYarnLock.add("");
    final List<String> testLines = new ArrayList<>();
    testLines.add("├─ esprima@3.1.3");
    testLines.add("└─ extsprintf@1.3.0");
    final ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    final YarnLockParser yarnLockParser = new YarnLockParser();
    final YarnListParser yarnListParser = new YarnListParser(externalIdFactory, yarnLockParser);
    final DependencyGraph dependencyGraph = yarnListParser.parseYarnList(designedYarnLock, testLines);
    final List<ExternalId> tempList = new ArrayList<>(dependencyGraph.getRootDependencyExternalIds());
    assertListContainsDependency("esprima", "3.1.3", tempList);
    assertListContainsDependency("extsprintf", "1.3.0", tempList);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) ArrayList(java.util.ArrayList) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

Example 32 with DependencyGraph

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

the class YarnListParserTest method testThatYarnListWithGreatGrandchildrenIsParsedCorrectly.

@Test
public void testThatYarnListWithGreatGrandchildrenIsParsedCorrectly() {
    final List<String> designedYarnLock = new ArrayList<>();
    designedYarnLock.add("yargs-parser@5.5.2:");
    designedYarnLock.add("  version \"5.5.2\"");
    designedYarnLock.add("");
    designedYarnLock.add("camelcase@^3.0.0:");
    designedYarnLock.add("  version \"5.5.2\"");
    designedYarnLock.add("");
    designedYarnLock.add("ms@5.5.2:");
    designedYarnLock.add("  version \"5.5.2\"");
    designedYarnLock.add("");
    final List<String> testLines = new ArrayList<>();
    testLines.add("├─ yargs-parser@4.2.1");
    testLines.add("│  └─ camelcase@^3.0.0");
    testLines.add("│  │  └─ ms@0.7.2");
    final ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    final YarnLockParser yarnLockParser = new YarnLockParser();
    final YarnListParser yarnListParser = new YarnListParser(externalIdFactory, yarnLockParser);
    final DependencyGraph dependencyGraph = yarnListParser.parseYarnList(designedYarnLock, testLines);
    final List<ExternalId> rootDependencies = new ArrayList<>(dependencyGraph.getRootDependencyExternalIds());
    assertListContainsDependency("yargs-parser", "4.2.1", rootDependencies);
    final List<ExternalId> childDependencies = new ArrayList<>(dependencyGraph.getChildrenExternalIdsForParent(rootDependencies.get(0)));
    assertListContainsDependency("camelcase", "5.5.2", childDependencies);
    final List<ExternalId> grandchildDependencies = new ArrayList<>(dependencyGraph.getChildrenExternalIdsForParent(childDependencies.get(0)));
    assertListContainsDependency("ms", "0.7.2", grandchildDependencies);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) ArrayList(java.util.ArrayList) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

Example 33 with DependencyGraph

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

the class YarnListParserTest method parseYarnListWithResolvableVersions.

@Test
public void parseYarnListWithResolvableVersions() {
    final List<String> designedYarnLock = new ArrayList<>();
    designedYarnLock.add("ajv@5.5.2:");
    designedYarnLock.add("  version \"5.5.2\"");
    designedYarnLock.add("  resolved \"http://nexus/nexus3/repository/npm-all/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536\"");
    designedYarnLock.add("  dependencies:");
    designedYarnLock.add("    co \"^4.6.0\"");
    designedYarnLock.add("    tr46 \"~0.0.3\"");
    designedYarnLock.add("    cssstyle \">= 0.2.37 < 0.3.0\"");
    designedYarnLock.add("");
    designedYarnLock.add("co@^4.6.0:");
    designedYarnLock.add("  version \"4.6.0\"");
    designedYarnLock.add("  resolved \"http://nexus/nexus3/repository/npm-all/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184\"");
    designedYarnLock.add("  dependencies:");
    designedYarnLock.add("    hoek \"4.x.x\"");
    designedYarnLock.add("");
    designedYarnLock.add("tr46@~0.0.3:");
    designedYarnLock.add("  version \"0.0.3\"");
    designedYarnLock.add("  resolved \"http://nexus/nexus3/repository/npm-all/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a\"");
    designedYarnLock.add("");
    designedYarnLock.add("\"cssstyle@>= 0.2.37 < 0.3.0\":");
    designedYarnLock.add("  version \"0.2.37\"");
    designedYarnLock.add("  resolved \"http://nexus/nexus3/repository/npm-all/cssstyle/-/cssstyle-0.2.37.tgz#541097234cb2513c83ceed3acddc27ff27987d54\"");
    designedYarnLock.add("  dependencies:");
    designedYarnLock.add("    cssom \"0.3.x\"");
    designedYarnLock.add("hoek@4.x.x:");
    designedYarnLock.add("  version \"4.2.1\"");
    designedYarnLock.add("  resolved \"http://nexus/nexus3/repository/npm-all/hoek/-/hoek-4.2.1.tgz#9634502aa12c445dd5a7c5734b572bb8738aacbb\"");
    final ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    final YarnLockParser yarnLockParser = new YarnLockParser();
    final YarnListParser yarnListParser = new YarnListParser(externalIdFactory, yarnLockParser);
    final String yarnListText = testUtil.getResourceAsUTF8String("/yarn/yarn.list.res.txt");
    final DependencyGraph dependencyGraph = yarnListParser.parseYarnList(designedYarnLock, Arrays.asList(yarnListText.split(System.lineSeparator())));
    DependencyGraphResourceTestUtil.assertGraph("/yarn/list_expected_graph_2.json", dependencyGraph);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ArrayList(java.util.ArrayList) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

Example 34 with DependencyGraph

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

the class GraphParserTransformerTest method transform.

@Test
public void transform() throws IOException {
    final GraphParserTransformer graphParserTransformer = new GraphParserTransformer();
    final InputStream inputStream = new ClassPathResource("/bitbake/recipe-depends.dot").getInputStream();
    final GraphParser graphParser = new GraphParser(inputStream);
    final DependencyGraph dependencyGraph = graphParserTransformer.transform(graphParser, "i586-poky-linux");
    assert dependencyGraph.getRootDependencies().size() == 480;
}
Also used : InputStream(java.io.InputStream) GraphParser(com.paypal.digraph.parser.GraphParser) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.Test)

Example 35 with DependencyGraph

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

the class CocoapodsPackagerTest method simpleTest.

@Test
public void simpleTest() throws IOException {
    final String podlockText = testUtil.getResourceAsUTF8String("/cocoapods/simplePodfile.lock");
    final DependencyGraph projectDependencies = podlockParser.extractDependencyGraph(podlockText);
    DependencyGraphResourceTestUtil.assertGraph("/cocoapods/simpleExpected_graph.json", projectDependencies);
}
Also used : 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