Search in sources :

Example 1 with FormattedDetectorOutput

use of com.synopsys.integration.detect.workflow.report.output.FormattedDetectorOutput 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 2 with FormattedDetectorOutput

use of com.synopsys.integration.detect.workflow.report.output.FormattedDetectorOutput in project synopsys-detect by blackducksoftware.

the class DockerAssertions method successfulDetectorTypeStatusJson.

public void successfulDetectorTypeStatusJson(String detectorType) {
    FormattedOutput statusJson = locateStatusJson();
    Optional<FormattedDetectorOutput> detector = statusJson.detectors.stream().filter(it -> it.detectorType.equals(detectorType)).findFirst();
    Assertions.assertTrue(detector.isPresent(), "Could not find required detector in status json detector list.");
    Assertions.assertEquals("SUCCESS", detector.get().status);
}
Also used : Arrays(java.util.Arrays) FormattedDetectorOutput(com.synopsys.integration.detect.workflow.report.output.FormattedDetectorOutput) FormattedOutput(com.synopsys.integration.detect.workflow.report.output.FormattedOutput) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) FormattedStatusOutput(com.synopsys.integration.detect.workflow.report.output.FormattedStatusOutput) Objects(java.util.Objects) NameVersion(com.synopsys.integration.util.NameVersion) FormattedOperationOutput(com.synopsys.integration.detect.workflow.report.output.FormattedOperationOutput) Gson(com.google.gson.Gson) Assertions(org.junit.jupiter.api.Assertions) Optional(java.util.Optional) FileReader(java.io.FileReader) Pattern(java.util.regex.Pattern) FormattedDetectorOutput(com.synopsys.integration.detect.workflow.report.output.FormattedDetectorOutput) FormattedOutput(com.synopsys.integration.detect.workflow.report.output.FormattedOutput)

Aggregations

FormattedDetectorOutput (com.synopsys.integration.detect.workflow.report.output.FormattedDetectorOutput)2 FormattedOutput (com.synopsys.integration.detect.workflow.report.output.FormattedOutput)2 File (java.io.File)2 Gson (com.google.gson.Gson)1 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 FormattedOperationOutput (com.synopsys.integration.detect.workflow.report.output.FormattedOperationOutput)1 FormattedOutputManager (com.synopsys.integration.detect.workflow.report.output.FormattedOutputManager)1 FormattedStatusOutput (com.synopsys.integration.detect.workflow.report.output.FormattedStatusOutput)1 DetectableEnvironment (com.synopsys.integration.detectable.DetectableEnvironment)1 ExecutableNotFoundDetectableResult (com.synopsys.integration.detectable.detectable.result.ExecutableNotFoundDetectableResult)1 DetectorEvaluation (com.synopsys.integration.detector.base.DetectorEvaluation)1 DetectorEvaluationTree (com.synopsys.integration.detector.base.DetectorEvaluationTree)1 DetectorResult (com.synopsys.integration.detector.result.DetectorResult)1 DetectorRule (com.synopsys.integration.detector.rule.DetectorRule)1 NameVersion (com.synopsys.integration.util.NameVersion)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 Arrays (java.util.Arrays)1