use of com.synopsys.integration.detect.workflow.report.output.FormattedOutput 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);
}
use of com.synopsys.integration.detect.workflow.report.output.FormattedOutput in project synopsys-detect by blackducksoftware.
the class DockerAssertions method projectVersion.
public void projectVersion(String project, String version) {
FormattedOutput statusJson = locateStatusJson();
Assertions.assertEquals(project, statusJson.projectName);
Assertions.assertEquals(version, statusJson.projectVersion);
// Should we rely solely on the status json?
logContains("Project name: " + project);
logContains("Project version: " + version);
}
use of com.synopsys.integration.detect.workflow.report.output.FormattedOutput 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);
}
use of com.synopsys.integration.detect.workflow.report.output.FormattedOutput in project synopsys-detect by blackducksoftware.
the class DockerAssertions method successfulOperationStatusJson.
public void successfulOperationStatusJson(String operationKey) {
FormattedOutput statusJson = locateStatusJson();
Optional<FormattedOperationOutput> detector = statusJson.operations.stream().filter(it -> it.descriptionKey.equals(operationKey)).findFirst();
Assertions.assertTrue(detector.isPresent(), "Could not find required operation '" + operationKey + "' in status json detector list.");
Assertions.assertEquals("SUCCESS", detector.get().status);
}
use of com.synopsys.integration.detect.workflow.report.output.FormattedOutput in project synopsys-detect by blackducksoftware.
the class DockerAssertions method locateStatusJson.
private FormattedOutput locateStatusJson() {
if (statusJson != null)
return statusJson;
File runs = new File(outputDirectory, "runs");
File[] runDirectories = runs.listFiles();
Assertions.assertNotNull(runDirectories, "Could not find any run directories, looked in: " + runs);
Assertions.assertEquals(1, runDirectories.length, "There should be exactly one run directory (from this latest run).");
File run = runDirectories[0];
File status = new File(run, "status");
Assertions.assertTrue(status.exists(), "Could not find status directory in the run directory!");
File statusJsonFile = new File(status, "status.json");
Assertions.assertTrue(statusJsonFile.exists(), "Could not find status json in the status directory!");
try {
statusJson = new Gson().fromJson(new FileReader(statusJsonFile), FormattedOutput.class);
} catch (FileNotFoundException e) {
Assertions.fail("Unable to parse status json with gson.", e);
}
return statusJson;
}
Aggregations