use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class ConanCliExtractor method extract.
public Extraction extract(File projectDir, ExecutableTarget conanExe) {
toolVersionLogger.log(projectDir, conanExe);
ExecutableOutput conanInfoOutput;
try {
conanInfoOutput = conanCommandRunner.runConanInfoCommand(projectDir, conanExe);
} catch (Exception e) {
logger.error(String.format("Exception thrown executing conan info command: %s", e.getMessage()));
return new Extraction.Builder().exception(e).build();
}
if (!conanCommandRunner.wasSuccess(conanInfoOutput)) {
return new Extraction.Builder().failure("Conan info command reported errors").build();
}
if (!conanCommandRunner.producedOutput(conanInfoOutput)) {
return new Extraction.Builder().failure("Conan info command produced no output").build();
}
try {
ConanDetectableResult result = conanInfoParser.generateCodeLocationFromConanInfoOutput(conanInfoOutput.getStandardOutput());
return new Extraction.Builder().success(result.getCodeLocation()).projectName(result.getProjectName()).projectVersion(result.getProjectVersion()).build();
} catch (DetectableException e) {
return new Extraction.Builder().failure(e.getMessage()).build();
}
}
use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class DetectorToolTest method testPreferredDetectorMissingSuccess.
@Test
public void testPreferredDetectorMissingSuccess() throws DetectableException, ExecutableFailedException {
Extraction extraction = createSuccessExtraction();
DetectableResult extractionResult = new PassedDetectableResult();
String projectBomTool = "testBomTool";
DetectorToolResult result = executeToolTest(extraction, extractionResult, projectBomTool);
assertFalse(result.getApplicableDetectorTypes().isEmpty());
assertTrue(result.getBomToolCodeLocations().isEmpty());
assertTrue(result.getBomToolProjectNameVersion().isPresent());
assertTrue(result.getCodeLocationMap().isEmpty());
assertTrue(result.getFailedDetectorTypes().isEmpty());
assertTrue(result.getRootDetectorEvaluationTree().isPresent());
}
use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class DetectorToolTest method testExtractionFailed.
@Test
public void testExtractionFailed() throws DetectableException, ExecutableFailedException {
Extraction extraction = createFailExtraction();
DetectableResult extractionResult = new PassedDetectableResult();
String projectBomTool = DetectorType.GO_MOD.name();
DetectorToolResult result = executeToolTest(extraction, extractionResult, projectBomTool);
assertFalse(result.getApplicableDetectorTypes().isEmpty());
assertTrue(result.getBomToolCodeLocations().isEmpty());
assertFalse(result.getBomToolProjectNameVersion().isPresent());
assertTrue(result.getCodeLocationMap().isEmpty());
assertTrue(result.getFailedDetectorTypes().isEmpty());
assertTrue(result.getRootDetectorEvaluationTree().isPresent());
}
use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class DetectorToolTest method testSuccess.
@Test
public void testSuccess() throws DetectableException, ExecutableFailedException {
Extraction extraction = createSuccessExtraction();
DetectableResult extractionResult = new PassedDetectableResult();
String projectBomTool = DetectorType.GO_MOD.name();
DetectorToolResult result = executeToolTest(extraction, extractionResult, projectBomTool);
assertFalse(result.getApplicableDetectorTypes().isEmpty());
assertTrue(result.getBomToolCodeLocations().isEmpty());
assertTrue(result.getBomToolProjectNameVersion().isPresent());
assertTrue(result.getCodeLocationMap().isEmpty());
assertTrue(result.getFailedDetectorTypes().isEmpty());
assertTrue(result.getRootDetectorEvaluationTree().isPresent());
}
use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class PackageJsonExtractorFunctionalTest method extractWithPeerDependencies.
@Test
void extractWithPeerDependencies() {
Extraction extraction = createExtractor(NpmDependencyType.DEV).extract(packageJsonInputStream);
assertEquals(1, extraction.getCodeLocations().size());
CodeLocation codeLocation = extraction.getCodeLocations().get(0);
DependencyGraph dependencyGraph = codeLocation.getDependencyGraph();
GraphAssert graphAssert = new GraphAssert(Forge.RUBYGEMS, dependencyGraph);
graphAssert.hasRootDependency(testDep1);
graphAssert.hasRootDependency(testDep2);
graphAssert.hasRootDependency(testPeerDep1);
graphAssert.hasRootDependency(testPeerDep2);
graphAssert.hasNoDependency(testDevDep1);
graphAssert.hasNoDependency(testDevDep2);
graphAssert.hasRootSize(4);
}
Aggregations