Search in sources :

Example 11 with PassedDetectableResult

use of com.synopsys.integration.detectable.detectable.result.PassedDetectableResult 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());
}
Also used : DetectableResult(com.synopsys.integration.detectable.detectable.result.DetectableResult) PassedDetectableResult(com.synopsys.integration.detectable.detectable.result.PassedDetectableResult) Extraction(com.synopsys.integration.detectable.extraction.Extraction) PassedDetectableResult(com.synopsys.integration.detectable.detectable.result.PassedDetectableResult) Test(org.junit.jupiter.api.Test)

Example 12 with PassedDetectableResult

use of com.synopsys.integration.detectable.detectable.result.PassedDetectableResult 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());
}
Also used : DetectableResult(com.synopsys.integration.detectable.detectable.result.DetectableResult) PassedDetectableResult(com.synopsys.integration.detectable.detectable.result.PassedDetectableResult) Extraction(com.synopsys.integration.detectable.extraction.Extraction) PassedDetectableResult(com.synopsys.integration.detectable.detectable.result.PassedDetectableResult) Test(org.junit.jupiter.api.Test)

Example 13 with PassedDetectableResult

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

the class DetectorToolTest method createDetectable.

private GoModCliDetectable createDetectable(Extraction extraction, DetectableResult extractionResult) throws DetectableException, ExecutableFailedException {
    File relevantFile = new File("go.mod");
    List<File> relevantFiles = Collections.singletonList(relevantFile);
    GoModCliDetectable detectable = Mockito.mock(GoModCliDetectable.class);
    Mockito.when(detectable.extractable()).thenReturn(extractionResult);
    Mockito.when(detectable.applicable()).thenReturn(new PassedDetectableResult(Collections.emptyList(), relevantFiles));
    Mockito.when(detectable.extract(Mockito.any())).thenReturn(extraction);
    return detectable;
}
Also used : GoModCliDetectable(com.synopsys.integration.detectable.detectables.go.gomod.GoModCliDetectable) File(java.io.File) PassedDetectableResult(com.synopsys.integration.detectable.detectable.result.PassedDetectableResult)

Example 14 with PassedDetectableResult

use of com.synopsys.integration.detectable.detectable.result.PassedDetectableResult 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());
}
Also used : DetectableResult(com.synopsys.integration.detectable.detectable.result.DetectableResult) PassedDetectableResult(com.synopsys.integration.detectable.detectable.result.PassedDetectableResult) Extraction(com.synopsys.integration.detectable.extraction.Extraction) PassedDetectableResult(com.synopsys.integration.detectable.detectable.result.PassedDetectableResult) Test(org.junit.jupiter.api.Test)

Aggregations

PassedDetectableResult (com.synopsys.integration.detectable.detectable.result.PassedDetectableResult)14 DetectableResult (com.synopsys.integration.detectable.detectable.result.DetectableResult)6 Test (org.junit.jupiter.api.Test)6 Extraction (com.synopsys.integration.detectable.extraction.Extraction)5 File (java.io.File)5 FoundFile (com.synopsys.integration.detectable.detectable.explanation.FoundFile)4 DetectableException (com.synopsys.integration.detectable.detectable.exception.DetectableException)3 FoundExecutable (com.synopsys.integration.detectable.detectable.explanation.FoundExecutable)3 Detectable (com.synopsys.integration.detectable.Detectable)2 DetectableEnvironment (com.synopsys.integration.detectable.DetectableEnvironment)2 Explanation (com.synopsys.integration.detectable.detectable.explanation.Explanation)2 ExecutableNotFoundDetectableResult (com.synopsys.integration.detectable.detectable.result.ExecutableNotFoundDetectableResult)2 ExtractionEnvironment (com.synopsys.integration.detectable.extraction.ExtractionEnvironment)2 DetectorEvaluation (com.synopsys.integration.detector.base.DetectorEvaluation)2 DetectorEvaluationTree (com.synopsys.integration.detector.base.DetectorEvaluationTree)2 DetectorRule (com.synopsys.integration.detector.rule.DetectorRule)2 DetectorRuleSet (com.synopsys.integration.detector.rule.DetectorRuleSet)2 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2