use of com.synopsys.integration.detect.battery.docker.util.DetectCommandBuilder in project synopsys-detect by blackducksoftware.
the class DetectOnDetectTest method riskReportPopulatedAtCustomPath.
@Test
public // Tests that a new project has an empty report, run detect to fill it, tests the report is filled, in a custom location
void riskReportPopulatedAtCustomPath() throws Exception {
try (DetectDockerTestRunner test = new DetectDockerTestRunner("detect-on-detect-riskreport-custom", "detect-7.1.0:1.0.0")) {
test.withImageProvider(BuildDockerImageProvider.forDockerfilResourceNamed("Detect-7.1.0.dockerfile"));
BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
ReportService reportService = blackDuckTestConnection.createReportService();
BlackDuckAssertions blackDuckAssertions = blackDuckTestConnection.projectVersionAssertions("synopsys-detect-junit", "risk-report-custom");
ProjectVersionWrapper projectVersionWrapper = blackDuckAssertions.emptyOnBlackDuck();
String reportDirectoryImagePath = "/opt/report";
File reportDirectory = test.directories().createResultDirectory("report");
test.directories().withBinding(reportDirectory, reportDirectoryImagePath);
long initialFileLength = assertEmptyRiskReport(reportDirectory, projectVersionWrapper, reportService);
DetectCommandBuilder commandBuilder = new DetectCommandBuilder().defaults().defaultDirectories(test);
commandBuilder.connectToBlackDuck(blackDuckTestConnection);
commandBuilder.projectNameVersion(blackDuckAssertions.getProjectNameVersion());
commandBuilder.property(DetectProperties.DETECT_RISK_REPORT_PDF, "true");
commandBuilder.property(DetectProperties.DETECT_TIMEOUT, "1200");
commandBuilder.property(DetectProperties.DETECT_RISK_REPORT_PDF_PATH, reportDirectoryImagePath);
commandBuilder.tools(DetectTool.DETECTOR);
DockerAssertions dockerAssertions = test.run(commandBuilder);
dockerAssertions.resultProducedAtLocation("/opt/report/synopsys_detect_junit_risk_report_custom_BlackDuck_RiskReport.pdf");
List<File> pdfFiles = getPdfFiles(reportDirectory);
assertEquals(1, pdfFiles.size());
long postLength = pdfFiles.get(0).length();
assertTrue(postLength > initialFileLength);
}
}
use of com.synopsys.integration.detect.battery.docker.util.DetectCommandBuilder in project synopsys-detect by blackducksoftware.
the class RiskReportTests method anyProjectWithRiskReportResultsInBlackDuck.
// create any bom for a risk report
SharedDockerTestRunner anyProjectWithRiskReportResultsInBlackDuck(String testId, NameVersion projectNameVersion) throws IOException, IntegrationException {
try (DetectDockerTestRunner runner = new DetectDockerTestRunner(testId, "gradle-simple:1.0.0")) {
runner.withImageProvider(BuildDockerImageProvider.forDockerfilResourceNamed("SimpleGradle.dockerfile"));
BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
BlackDuckAssertions blackduckAssertions = blackDuckTestConnection.projectVersionAssertions(projectNameVersion);
blackduckAssertions.emptyOnBlackDuck();
DetectCommandBuilder commandBuilder = new DetectCommandBuilder().defaults().defaultDirectories(runner);
commandBuilder.connectToBlackDuck(blackDuckTestConnection);
commandBuilder.projectNameVersion(blackduckAssertions);
// All that is needed for a BOM in black duck.
commandBuilder.tools(DetectTool.DETECTOR);
return new SharedDockerTestRunner(runner, blackDuckTestConnection, blackduckAssertions, commandBuilder);
}
}
Aggregations