Search in sources :

Example 11 with DetectableResult

use of com.synopsys.integration.detectable.detectable.result.DetectableResult 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 12 with DetectableResult

use of com.synopsys.integration.detectable.detectable.result.DetectableResult 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)

Example 13 with DetectableResult

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

the class DetectableFunctionalTest method run.

@Test
public void run() throws IOException, DetectableException, ExecutableFailedException, MissingExternalIdException, CycleDetectedException, ExecutableRunnerException, ParserConfigurationException, SAXException {
    System.out.println(String.format("Function Test (%s) is using temp directory: %s", name, tempDirectory.toAbsolutePath().toString()));
    setup();
    DetectableEnvironment detectableEnvironment = new DetectableEnvironment(sourceDirectory.toFile());
    Detectable detectable = create(detectableEnvironment);
    DetectableResult applicable = detectable.applicable();
    Assertions.assertTrue(applicable.getPassed(), String.format("Applicable should have passed but was: %s", applicable.toDescription()));
    DetectableResult extractable = detectable.extractable();
    Assertions.assertTrue(extractable.getPassed(), String.format("Extractable should have passed but was: %s", extractable.toDescription()));
    ExtractionEnvironment extractionEnvironment = new ExtractionEnvironment(outputDirectory.toFile());
    Extraction extraction = detectable.extract(extractionEnvironment);
    Assertions.assertNotNull(extraction, "Detectable did not return an extraction!");
    assertExtraction(extraction);
    FileUtils.deleteDirectory(tempDirectory.toFile());
}
Also used : Detectable(com.synopsys.integration.detectable.Detectable) ExtractionEnvironment(com.synopsys.integration.detectable.extraction.ExtractionEnvironment) DetectableResult(com.synopsys.integration.detectable.detectable.result.DetectableResult) Extraction(com.synopsys.integration.detectable.extraction.Extraction) DetectableEnvironment(com.synopsys.integration.detectable.DetectableEnvironment) Test(org.junit.jupiter.api.Test)

Example 14 with DetectableResult

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

the class DockerDetectableTest method testApplicable.

@Test
public void testApplicable() {
    DetectableEnvironment environment = null;
    DockerInspectorResolver dockerInspectorResolver = null;
    JavaResolver javaResolver = null;
    DockerResolver dockerResolver = null;
    DockerExtractor dockerExtractor = null;
    DockerDetectableOptions dockerDetectableOptions = Mockito.mock(DockerDetectableOptions.class);
    Mockito.when(dockerDetectableOptions.hasDockerImageOrTar()).thenReturn(Boolean.TRUE);
    DockerDetectable detectable = new DockerDetectable(environment, dockerInspectorResolver, javaResolver, dockerResolver, dockerExtractor, dockerDetectableOptions);
    DetectableResult result = detectable.applicable();
    assertTrue(result.getPassed() || result instanceof WrongOperatingSystemResult);
}
Also used : JavaResolver(com.synopsys.integration.detectable.detectable.executable.resolver.JavaResolver) WrongOperatingSystemResult(com.synopsys.integration.detectable.detectable.result.WrongOperatingSystemResult) DockerDetectable(com.synopsys.integration.detectable.detectables.docker.DockerDetectable) DetectableResult(com.synopsys.integration.detectable.detectable.result.DetectableResult) DockerExtractor(com.synopsys.integration.detectable.detectables.docker.DockerExtractor) DetectableEnvironment(com.synopsys.integration.detectable.DetectableEnvironment) DockerInspectorResolver(com.synopsys.integration.detectable.detectables.docker.DockerInspectorResolver) DockerResolver(com.synopsys.integration.detectable.detectable.executable.resolver.DockerResolver) DockerDetectableOptions(com.synopsys.integration.detectable.detectables.docker.DockerDetectableOptions) Test(org.junit.jupiter.api.Test)

Aggregations

DetectableResult (com.synopsys.integration.detectable.detectable.result.DetectableResult)14 Test (org.junit.jupiter.api.Test)9 DetectableEnvironment (com.synopsys.integration.detectable.DetectableEnvironment)8 Extraction (com.synopsys.integration.detectable.extraction.Extraction)8 PassedDetectableResult (com.synopsys.integration.detectable.detectable.result.PassedDetectableResult)6 Detectable (com.synopsys.integration.detectable.Detectable)5 ExtractionEnvironment (com.synopsys.integration.detectable.extraction.ExtractionEnvironment)5 DetectorEvaluation (com.synopsys.integration.detector.base.DetectorEvaluation)4 DetectorEvaluationTree (com.synopsys.integration.detector.base.DetectorEvaluationTree)4 File (java.io.File)4 DetectableException (com.synopsys.integration.detectable.detectable.exception.DetectableException)3 ExceptionDetectableResult (com.synopsys.integration.detectable.detectable.result.ExceptionDetectableResult)3 DetectorResult (com.synopsys.integration.detector.result.DetectorResult)3 DetectorRule (com.synopsys.integration.detector.rule.DetectorRule)3 IOException (java.io.IOException)3 List (java.util.List)3 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)3 SAXException (org.xml.sax.SAXException)3 MissingExternalIdException (com.synopsys.integration.bdio.graph.builder.MissingExternalIdException)2 FileFinder (com.synopsys.integration.common.util.finder.FileFinder)2