use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory 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);
}
use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory in project hub-detect by blackducksoftware.
the class PackagistTest method packagistParserTest.
@Test
public void packagistParserTest() throws IOException {
final DetectConfiguration detectConfiguration = Mockito.mock(DetectConfiguration.class);
Mockito.when(detectConfiguration.getBooleanProperty(DetectProperty.DETECT_PACKAGIST_INCLUDE_DEV_DEPENDENCIES, PropertyAuthority.None)).thenReturn(true);
final PackagistParser packagistParser = new PackagistParser(new ExternalIdFactory(), detectConfiguration);
final String composerLockText = testUtil.getResourceAsUTF8String("/packagist/composer.lock");
final String composerJsonText = testUtil.getResourceAsUTF8String("/packagist/composer.json");
final PackagistParseResult result = packagistParser.getDependencyGraphFromProject("source", composerJsonText, composerLockText);
Assert.assertEquals(result.projectName, "clue/graph-composer");
Assert.assertEquals(result.projectVersion, "1.0.0");
DependencyGraphResourceTestUtil.assertGraph("/packagist/PackagistTestDependencyNode_graph.json", result.codeLocation.getDependencyGraph());
}
use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory 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);
}
use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory 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);
}
use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory 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);
}
Aggregations