use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory 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);
}
use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory 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);
}
use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory in project hub-detect by blackducksoftware.
the class BazelCodeLocationBuilderTest method test.
@Test
public void test() {
BazelCodeLocationBuilder bdioBuilder = new BazelCodeLocationBuilder(new ExternalIdFactory());
final List<DetectCodeLocation> codeLocations = bdioBuilder.setWorkspaceDir(new File("src/test/resources/bazel/multiLevel")).addDependency(BazelExternalId.fromBazelArtifactString("testGroup:testArtifact:testVersion", ":")).build();
assertEquals(1, codeLocations.size());
assertEquals("src/test/resources/bazel/multiLevel", codeLocations.get(0).getExternalId().path);
assertEquals(1, codeLocations.get(0).getDependencyGraph().getRootDependencies().size());
Dependency dep = codeLocations.get(0).getDependencyGraph().getRootDependencies().iterator().next();
assertEquals("testArtifact", dep.name);
assertEquals("testVersion", dep.version);
assertEquals("testGroup", dep.externalId.group);
}
use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory in project hub-detect by blackducksoftware.
the class DependencyGraphAssertions method mavenGavToExternalId.
private static ExternalId mavenGavToExternalId(final String gav) {
final String[] split = gav.split(":");
final ExternalIdFactory externalIdFactory = new ExternalIdFactory();
return externalIdFactory.createMavenExternalId(split[0], split[1], split[2]);
}
use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory in project hub-detect by blackducksoftware.
the class DependencyGraphAssertions method assertHasMavenGav.
public static void assertHasMavenGav(final DependencyGraph dependencyGraph, final String org, final String name, final String version) {
final ExternalIdFactory externalIdFactory = new ExternalIdFactory();
final ExternalId id = externalIdFactory.createMavenExternalId(org, name, version);
final Dependency dep = dependencyGraph.getDependency(id);
assertNotNull("Expected dependency '" + org + ":" + name + ":" + version + "' to exist in graph but it was null.", dep);
}
Aggregations