Search in sources :

Example 1 with ExecutableNotFoundDetectableResult

use of com.synopsys.integration.detectable.detectable.result.ExecutableNotFoundDetectableResult in project synopsys-detect by blackducksoftware.

the class GradleDetectable method extractable.

@Override
public DetectableResult extractable() throws DetectableException {
    List<Explanation> explanations = new ArrayList<>();
    gradleExe = gradleResolver.resolveGradle(environment);
    if (gradleExe == null) {
        return new ExecutableNotFoundDetectableResult("gradle");
    } else {
        explanations.add(new FoundExecutable(gradleExe));
    }
    gradleInspector = gradleInspectorResolver.resolveGradleInspector();
    if (gradleInspector == null) {
        return new InspectorNotFoundDetectableResult("gradle");
    } else {
        explanations.add(new FoundInspector(gradleInspector));
    }
    return new PassedDetectableResult(explanations);
}
Also used : ExecutableNotFoundDetectableResult(com.synopsys.integration.detectable.detectable.result.ExecutableNotFoundDetectableResult) FoundExecutable(com.synopsys.integration.detectable.detectable.explanation.FoundExecutable) Explanation(com.synopsys.integration.detectable.detectable.explanation.Explanation) ArrayList(java.util.ArrayList) FoundInspector(com.synopsys.integration.detectable.detectable.explanation.FoundInspector) PassedDetectableResult(com.synopsys.integration.detectable.detectable.result.PassedDetectableResult) InspectorNotFoundDetectableResult(com.synopsys.integration.detectable.detectable.result.InspectorNotFoundDetectableResult)

Example 2 with ExecutableNotFoundDetectableResult

use of com.synopsys.integration.detectable.detectable.result.ExecutableNotFoundDetectableResult in project synopsys-detect by blackducksoftware.

the class FormattedOutputManagerTest method detectorOutputStatusDataTest.

@Test
public <T extends Detectable> void detectorOutputStatusDataTest() throws IllegalAccessException {
    EventSystem eventSystem = new EventSystem();
    FormattedOutputManager formattedOutputManager = new FormattedOutputManager(eventSystem);
    DetectorRule rule = Mockito.mock(DetectorRule.class);
    Mockito.when(rule.getDescriptiveName()).thenReturn("");
    Mockito.when(rule.getName()).thenReturn("");
    Mockito.when(rule.getDetectorType()).thenReturn(DetectorType.GO_MOD);
    DetectorEvaluation detectorEvaluation = new DetectorEvaluation(rule);
    ExecutableNotFoundDetectableResult result = new ExecutableNotFoundDetectableResult("go");
    DetectorResult extractableResult = new DetectorResult(result.getPassed(), result.toDescription(), result.getClass(), Collections.emptyList(), Collections.emptyList());
    detectorEvaluation.setExtractable(extractableResult);
    detectorEvaluation.setApplicable(new DetectorResult(true, "", Collections.emptyList(), Collections.emptyList()));
    detectorEvaluation.setSearchable(new DetectorResult(true, "", Collections.emptyList(), Collections.emptyList()));
    detectorEvaluation.setDetectableEnvironment(new DetectableEnvironment(new File("")));
    DetectorToolResult detectorToolResult = new DetectorToolResult(null, null, null, new HashSet<>(), new DetectorEvaluationTree(null, 0, null, Collections.singletonList(detectorEvaluation), new HashSet<>()), null);
    eventSystem.publishEvent(Event.DetectorsComplete, detectorToolResult);
    DetectInfo detectInfo = new DetectInfo("", null, "");
    FormattedOutput formattedOutput = formattedOutputManager.createFormattedOutput(detectInfo);
    FormattedDetectorOutput detectorOutput = formattedOutput.detectors.get(0);
    Assertions.assertEquals("FAILURE", detectorOutput.status);
    Assertions.assertEquals(DetectorStatusCode.EXECUTABLE_NOT_FOUND, detectorOutput.statusCode);
    Assertions.assertEquals("No go executable was found.", detectorOutput.statusReason);
}
Also used : ExecutableNotFoundDetectableResult(com.synopsys.integration.detectable.detectable.result.ExecutableNotFoundDetectableResult) DetectInfo(com.synopsys.integration.detect.configuration.DetectInfo) DetectorEvaluation(com.synopsys.integration.detector.base.DetectorEvaluation) FormattedOutputManager(com.synopsys.integration.detect.workflow.report.output.FormattedOutputManager) DetectableEnvironment(com.synopsys.integration.detectable.DetectableEnvironment) FormattedOutput(com.synopsys.integration.detect.workflow.report.output.FormattedOutput) DetectorToolResult(com.synopsys.integration.detect.tool.detector.DetectorToolResult) DetectorEvaluationTree(com.synopsys.integration.detector.base.DetectorEvaluationTree) FormattedDetectorOutput(com.synopsys.integration.detect.workflow.report.output.FormattedDetectorOutput) DetectorRule(com.synopsys.integration.detector.rule.DetectorRule) EventSystem(com.synopsys.integration.detect.workflow.event.EventSystem) DetectorResult(com.synopsys.integration.detector.result.DetectorResult) File(java.io.File) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 3 with ExecutableNotFoundDetectableResult

use of com.synopsys.integration.detectable.detectable.result.ExecutableNotFoundDetectableResult in project synopsys-detect by blackducksoftware.

the class SbtDetectable method sbtPluginExtractable.

// Check if SBT & a plugin can be found
private DetectableResult sbtPluginExtractable() throws DetectableException {
    List<Explanation> explanations = new ArrayList<>();
    sbt = sbtResolver.resolveSbt();
    if (sbt == null) {
        return new ExecutableNotFoundDetectableResult("sbt");
    } else {
        explanations.add(new FoundExecutable(sbt));
    }
    foundPlugin = sbtPluginFinder.isPluginInstalled(environment.getDirectory(), sbt, sbtResolutionCacheOptions.getSbtCommandAdditionalArguments());
    if (!foundPlugin) {
        return new SbtMissingPluginDetectableResult(environment.getDirectory().toString());
    } else {
        explanations.add(new FoundSbtPlugin("Dependency Graph"));
    }
    return new PassedDetectableResult(explanations);
}
Also used : ExecutableNotFoundDetectableResult(com.synopsys.integration.detectable.detectable.result.ExecutableNotFoundDetectableResult) FoundExecutable(com.synopsys.integration.detectable.detectable.explanation.FoundExecutable) Explanation(com.synopsys.integration.detectable.detectable.explanation.Explanation) SbtMissingPluginDetectableResult(com.synopsys.integration.detectable.detectable.result.SbtMissingPluginDetectableResult) ArrayList(java.util.ArrayList) FoundSbtPlugin(com.synopsys.integration.detectable.detectable.explanation.FoundSbtPlugin) PassedDetectableResult(com.synopsys.integration.detectable.detectable.result.PassedDetectableResult)

Example 4 with ExecutableNotFoundDetectableResult

use of com.synopsys.integration.detectable.detectable.result.ExecutableNotFoundDetectableResult in project synopsys-detect by blackducksoftware.

the class DockerDetectable method extractable.

@Override
public DetectableResult extractable() throws DetectableException {
    // TODO: Can this be improved with a Requirements object? - jp
    PassedResultBuilder passedResultBuilder = new PassedResultBuilder();
    javaExe = javaResolver.resolveJava();
    if (javaExe == null) {
        return new ExecutableNotFoundDetectableResult("java");
    } else {
        passedResultBuilder.foundExecutable(javaExe);
    }
    try {
        dockerExe = dockerResolver.resolveDocker();
    } catch (Exception e) {
        dockerExe = null;
    }
    if (dockerExe == null) {
        if (dockerDetectableOptions.isDockerPathRequired()) {
            return new ExecutableNotFoundDetectableResult("docker");
        } else {
            logger.debug("Docker executable not found, but it has been configured as not-required; proceeding with execution of Docker tool. Running in air-gap mode will not work without a Docker executable.");
        }
    } else {
        passedResultBuilder.foundExecutable(dockerExe);
    }
    dockerInspectorInfo = dockerInspectorResolver.resolveDockerInspector();
    if (dockerInspectorInfo == null) {
        return new InspectorNotFoundDetectableResult("docker");
    } else {
        passedResultBuilder.foundInspector(dockerInspectorInfo.getDockerInspectorJar());
    }
    return passedResultBuilder.build();
}
Also used : ExecutableNotFoundDetectableResult(com.synopsys.integration.detectable.detectable.result.ExecutableNotFoundDetectableResult) PassedResultBuilder(com.synopsys.integration.detectable.detectable.PassedResultBuilder) IOException(java.io.IOException) ExecutableRunnerException(com.synopsys.integration.executable.ExecutableRunnerException) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException) InspectorNotFoundDetectableResult(com.synopsys.integration.detectable.detectable.result.InspectorNotFoundDetectableResult)

Aggregations

ExecutableNotFoundDetectableResult (com.synopsys.integration.detectable.detectable.result.ExecutableNotFoundDetectableResult)4 Explanation (com.synopsys.integration.detectable.detectable.explanation.Explanation)2 FoundExecutable (com.synopsys.integration.detectable.detectable.explanation.FoundExecutable)2 InspectorNotFoundDetectableResult (com.synopsys.integration.detectable.detectable.result.InspectorNotFoundDetectableResult)2 PassedDetectableResult (com.synopsys.integration.detectable.detectable.result.PassedDetectableResult)2 ArrayList (java.util.ArrayList)2 DetectInfo (com.synopsys.integration.detect.configuration.DetectInfo)1 DetectorToolResult (com.synopsys.integration.detect.tool.detector.DetectorToolResult)1 EventSystem (com.synopsys.integration.detect.workflow.event.EventSystem)1 FormattedDetectorOutput (com.synopsys.integration.detect.workflow.report.output.FormattedDetectorOutput)1 FormattedOutput (com.synopsys.integration.detect.workflow.report.output.FormattedOutput)1 FormattedOutputManager (com.synopsys.integration.detect.workflow.report.output.FormattedOutputManager)1 DetectableEnvironment (com.synopsys.integration.detectable.DetectableEnvironment)1 PassedResultBuilder (com.synopsys.integration.detectable.detectable.PassedResultBuilder)1 DetectableException (com.synopsys.integration.detectable.detectable.exception.DetectableException)1 FoundInspector (com.synopsys.integration.detectable.detectable.explanation.FoundInspector)1 FoundSbtPlugin (com.synopsys.integration.detectable.detectable.explanation.FoundSbtPlugin)1 SbtMissingPluginDetectableResult (com.synopsys.integration.detectable.detectable.result.SbtMissingPluginDetectableResult)1 DetectorEvaluation (com.synopsys.integration.detector.base.DetectorEvaluation)1 DetectorEvaluationTree (com.synopsys.integration.detector.base.DetectorEvaluationTree)1