use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory in project hub-detect by blackducksoftware.
the class MavenCodeLocationPackagerTest method testParseProject.
@Test
public void testParseProject() {
final MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(new ExternalIdFactory());
Dependency dependency = mavenCodeLocationPackager.textToProject("stuff:things:jar:0.0.1");
assertNotNull(dependency);
dependency = mavenCodeLocationPackager.textToProject("stuff:things:jar:classifier:0.0.1");
assertNotNull(dependency);
dependency = mavenCodeLocationPackager.textToProject("stuff:things:jar");
assertNull(dependency);
dependency = mavenCodeLocationPackager.textToProject("stuff:things:jar:classifier:0.0.1:monkey");
assertNull(dependency);
}
use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory in project hub-detect by blackducksoftware.
the class MavenCodeLocationPackagerTest method testLineWithUnknownScope.
@Test
public void testLineWithUnknownScope() {
final MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(new ExternalIdFactory());
String line = "[INFO] | | | \\- org.eclipse.scout.sdk.deps:org.eclipse.core.jobs:jar:3.8.0.v20160509-0411:pants (version selected from constraint [3.8.0,3.8.1))";
line = mavenCodeLocationPackager.trimLogLevel(line);
final String cleanedLine = mavenCodeLocationPackager.calculateCurrentLevelAndCleanLine(line);
final ScopedDependency scopedDependency = mavenCodeLocationPackager.textToDependency(cleanedLine);
assertEquals("org.eclipse.scout.sdk.deps:org.eclipse.core.jobs:3.8.0.v20160509-0411", scopedDependency.externalId.createExternalId());
}
use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory in project hub-detect by blackducksoftware.
the class MavenCodeLocationPackagerTest method createNewCodeLocationTest.
private void createNewCodeLocationTest(final String mavenOutputText, final String expectedResourcePath, final int numberOfCodeLocations, final String excludedModules, final String includedModules, int codeLocationIndex, final String scope) {
final MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(new ExternalIdFactory());
final List<MavenParseResult> result = mavenCodeLocationPackager.extractCodeLocations("/test/path", mavenOutputText, scope, excludedModules, includedModules);
assertEquals(numberOfCodeLocations, result.size());
final DetectCodeLocation codeLocation = result.get(codeLocationIndex).codeLocation;
testUtil.testJsonResource(expectedResourcePath, codeLocation);
}
use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory in project hub-detect by blackducksoftware.
the class NpmOutputParserTest method npmCliDependencyFinder.
@Test
public void npmCliDependencyFinder() throws IOException {
final NpmCliParser parser = new NpmCliParser(new ExternalIdFactory());
final String testIn = testUtil.getResourceAsUTF8String("/npm/packman_proj_dependencies.json");
final NpmParseResult result = parser.convertNpmJsonFileToCodeLocation("source", testIn);
Assert.assertEquals(result.projectName, "node-js");
Assert.assertEquals(result.projectVersion, "0.2.0");
DependencyGraphResourceTestUtil.assertGraph("/npm/npmParseOutput_graph.json", result.codeLocation.getDependencyGraph());
}
use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory in project hub-detect by blackducksoftware.
the class ClangExtractorTest method testMultipleCommandsDependenciesPackages.
@Test
public void testMultipleCommandsDependenciesPackages() throws ExecutableRunnerException {
Assume.assumeFalse(SystemUtils.IS_OS_WINDOWS);
final CompileCommand compileCommandWrapperHelloWorld = createCompileCommand("src/test/resources/clang/source/hello_world.cpp", "gcc hello_world.cpp", null);
final CompileCommand compileCommandWrapperGoodbyeWorld = createCompileCommand("src/test/resources/clang/source/goodbye_world.cpp", "gcc goodbye_world.cpp", null);
final Set<String> dependencyFilePathsHelloWorld = createDependencyFilePaths(new File("src/test/resources/clang/source/myinclude.h"), new File("/usr/include/nonexistentfile1.h"), new File("/usr/include/nonexistentfile2.h"));
final Set<String> dependencyFilePathsGoodbyeWorld = createDependencyFilePaths(new File("/usr/include/nonexistentfile4.h"), new File("/usr/include/nonexistentfile3.h"));
final ExecutableRunner executableRunner = Mockito.mock(ExecutableRunner.class);
final DirectoryManager directoryManager = Mockito.mock(DirectoryManager.class);
final DependenciesListFileManager dependenciesListFileManager = Mockito.mock(DependenciesListFileManager.class);
Mockito.when(dependenciesListFileManager.generateDependencyFilePaths(outputDir, compileCommandWrapperHelloWorld, true)).thenReturn(dependencyFilePathsHelloWorld);
Mockito.when(dependenciesListFileManager.generateDependencyFilePaths(outputDir, compileCommandWrapperGoodbyeWorld, true)).thenReturn(dependencyFilePathsGoodbyeWorld);
Mockito.when(executableRunner.executeFromDirQuietly(Mockito.any(File.class), Mockito.anyString(), Mockito.anyList())).thenReturn(new ExecutableOutput(0, "", ""));
final ExternalIdFactory externalIdFactory = new ExternalIdFactory();
final CodeLocationAssembler codeLocationAssembler = new CodeLocationAssembler(externalIdFactory);
final ClangExtractor extractor = new ClangExtractor(null, executableRunner, gson, new DetectFileFinder(), directoryManager, dependenciesListFileManager, codeLocationAssembler);
final ClangLinuxPackageManager pkgMgr = Mockito.mock(ClangLinuxPackageManager.class);
final File givenDir = new File("src/test/resources/clang/source/build");
final int depth = 1;
final ExtractionId extractionId = new ExtractionId(DetectorType.CLANG, EXTRACTION_ID);
final File jsonCompilationDatabaseFile = new File("src/test/resources/clang/source/build/compile_commands.json");
Mockito.when(directoryManager.getExtractionOutputDirectory(Mockito.any(ExtractionId.class))).thenReturn(outputDir);
final List<PackageDetails> packages = new ArrayList<>();
packages.add(new PackageDetails("testPackageName1", "testPackageVersion1", "testPackageArch1"));
packages.add(new PackageDetails("testPackageName2", "testPackageVersion2", "testPackageArch2"));
Mockito.when(pkgMgr.getDefaultForge()).thenReturn(Forge.CENTOS);
Mockito.when(pkgMgr.getPackages(Mockito.any(File.class), Mockito.any(ExecutableRunner.class), Mockito.any(Set.class), Mockito.any(DependencyFileDetails.class))).thenReturn(packages);
Mockito.when(pkgMgr.getForges()).thenReturn(Arrays.asList(Forge.CENTOS, Forge.FEDORA, Forge.REDHAT));
final Extraction extraction = extractor.extract(pkgMgr, givenDir, depth, extractionId, jsonCompilationDatabaseFile);
checkGeneratedDependenciesComplex(extraction);
}
Aggregations