Search in sources :

Example 1 with BlackDuckTestConnection

use of com.synopsys.integration.detect.battery.docker.integration.BlackDuckTestConnection in project synopsys-detect by blackducksoftware.

the class RiskReportServiceTestIT method createReportPdfFileTest.

@Test
@ExtendWith(TempDirectory.class)
public void createReportPdfFileTest(@TempDirectory.TempDir Path folderForReport) throws IntegrationException {
    BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
    ReportService reportService = blackDuckTestConnection.createReportService();
    ProjectVersionWrapper projectVersionWrapper = blackDuckTestConnection.projectVersionAssertions(PROJECT_NAME, PROJECT_VERSION_NAME).retrieveProjectVersionWrapper();
    File folder = folderForReport.toFile();
    File pdfFile = reportService.createReportPdfFile(folder, projectVersionWrapper.getProjectView(), projectVersionWrapper.getProjectVersionView());
    Assertions.assertNotNull(pdfFile);
    Assertions.assertTrue(pdfFile.exists());
}
Also used : ReportService(com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService) BlackDuckTestConnection(com.synopsys.integration.detect.battery.docker.integration.BlackDuckTestConnection) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) File(java.io.File) Test(org.junit.jupiter.api.Test) ExtendWith(org.junit.jupiter.api.extension.ExtendWith)

Example 2 with BlackDuckTestConnection

use of com.synopsys.integration.detect.battery.docker.integration.BlackDuckTestConnection in project synopsys-detect by blackducksoftware.

the class RiskReportServiceTestIT method createNoticesReportFileTest.

@Test
@ExtendWith(TempDirectory.class)
public void createNoticesReportFileTest(@TempDirectory.TempDir Path folderForReport) throws IntegrationException, InterruptedException {
    BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
    ReportService reportService = blackDuckTestConnection.createReportService();
    ProjectVersionWrapper projectVersionWrapper = blackDuckTestConnection.projectVersionAssertions(PROJECT_NAME, PROJECT_VERSION_NAME).retrieveProjectVersionWrapper();
    File noticeReportFile = reportService.createNoticesReportFile(folderForReport.toFile(), projectVersionWrapper.getProjectView(), projectVersionWrapper.getProjectVersionView());
    Assertions.assertNotNull(noticeReportFile);
    Assertions.assertTrue(noticeReportFile.exists());
}
Also used : ReportService(com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService) BlackDuckTestConnection(com.synopsys.integration.detect.battery.docker.integration.BlackDuckTestConnection) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) File(java.io.File) Test(org.junit.jupiter.api.Test) ExtendWith(org.junit.jupiter.api.extension.ExtendWith)

Example 3 with BlackDuckTestConnection

use of com.synopsys.integration.detect.battery.docker.integration.BlackDuckTestConnection in project synopsys-detect by blackducksoftware.

the class ImpactAnalysisTestIT method testImpactAnalysisForDetect.

@Test
public void testImpactAnalysisForDetect() throws IOException, IntegrationException {
    BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
    NameVersion projectNameVersion = new NameVersion("synopsys-detect-junit", "impact-analysis");
    BlackDuckServicesFactory blackDuckServicesFactory = blackDuckTestConnection.getBlackDuckServicesFactory();
    File toScan = new File("./");
    Path outputDirectory = outputDirAsPath.toPath();
    ImpactAnalysisNamingOperation impactAnalysisNamingOperation = new ImpactAnalysisNamingOperation(codeLocationNameManager);
    String impactAnalysisCodeLocationName = impactAnalysisNamingOperation.createCodeLocationName(toScan, projectNameVersion);
    GenerateImpactAnalysisOperation generateImpactAnalysisOperation = new GenerateImpactAnalysisOperation();
    Path impactAnalysisFile = generateImpactAnalysisOperation.generateImpactAnalysis(toScan, impactAnalysisCodeLocationName, outputDirectory);
    ImpactAnalysisBatchRunner impactAnalysisBatchRunner = new ImpactAnalysisBatchRunner(logger, blackDuckServicesFactory.getBlackDuckApiClient(), blackDuckServicesFactory.getApiDiscovery(), new NoThreadExecutorService(), blackDuckServicesFactory.getGson());
    ImpactAnalysisUploadService impactAnalysisUploadService = new ImpactAnalysisUploadService(impactAnalysisBatchRunner, blackDuckServicesFactory.createCodeLocationCreationService());
    ImpactAnalysisUploadOperation impactAnalysisUploadOperation = new ImpactAnalysisUploadOperation(impactAnalysisUploadService);
    CodeLocationCreationData<ImpactAnalysisBatchOutput> creationData = impactAnalysisUploadOperation.uploadImpactAnalysis(impactAnalysisFile, projectNameVersion, impactAnalysisCodeLocationName);
    assertEquals(1, creationData.getOutput().getOutputs().size());
    assertEquals(Result.SUCCESS, creationData.getOutput().getOutputs().get(0).getResult());
}
Also used : Path(java.nio.file.Path) NameVersion(com.synopsys.integration.util.NameVersion) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) ImpactAnalysisUploadService(com.synopsys.integration.detect.tool.impactanalysis.service.ImpactAnalysisUploadService) NoThreadExecutorService(com.synopsys.integration.util.NoThreadExecutorService) ImpactAnalysisBatchRunner(com.synopsys.integration.detect.tool.impactanalysis.service.ImpactAnalysisBatchRunner) ImpactAnalysisBatchOutput(com.synopsys.integration.detect.tool.impactanalysis.service.ImpactAnalysisBatchOutput) BlackDuckTestConnection(com.synopsys.integration.detect.battery.docker.integration.BlackDuckTestConnection) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 4 with BlackDuckTestConnection

use of com.synopsys.integration.detect.battery.docker.integration.BlackDuckTestConnection in project synopsys-detect by blackducksoftware.

the class RiskReportServiceTestIT method createProjectFirst.

@BeforeAll
public static void createProjectFirst() throws IntegrationException {
    String testPhase = ProjectVersionPhaseType.DEVELOPMENT.name();
    String testDistribution = ProjectVersionDistributionType.OPENSOURCE.name();
    ProjectSyncModel projectSyncModel = new ProjectSyncModel(PROJECT_NAME, PROJECT_VERSION_NAME);
    projectSyncModel.setPhase(ProjectVersionPhaseType.valueOf(testPhase));
    projectSyncModel.setDistribution(ProjectVersionDistributionType.valueOf(testDistribution));
    BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
    blackDuckTestConnection.createProjectService().syncProjectAndVersion(projectSyncModel);
}
Also used : ProjectSyncModel(com.synopsys.integration.blackduck.service.model.ProjectSyncModel) BlackDuckTestConnection(com.synopsys.integration.detect.battery.docker.integration.BlackDuckTestConnection) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 5 with BlackDuckTestConnection

use of com.synopsys.integration.detect.battery.docker.integration.BlackDuckTestConnection in project synopsys-detect by blackducksoftware.

the class RiskReportServiceTestIT method createReportFilesManually.

@Test
@Disabled
public void createReportFilesManually() throws IntegrationException, InterruptedException {
    BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
    ReportService reportService = blackDuckTestConnection.createReportService();
    // fill these values in with your particulars
    final String projectName = "docker.pkg.github.com_maja-nord_java-eap-app_java-eap-app";
    final String projectVersionName = "latest";
    final String localPathForPdfReport = "/Users/ekerwin/Documents/working/riskreport_pdf";
    final String localPathForNoticesReport = "/Users/ekerwin/Documents/working/notices";
    ProjectVersionWrapper projectVersionWrapper = blackDuckTestConnection.projectVersionAssertions(PROJECT_NAME, PROJECT_VERSION_NAME).retrieveProjectVersionWrapper();
    File pdfReportFolder = new File(localPathForPdfReport);
    File noticesReportFolder = new File(localPathForNoticesReport);
    pdfReportFolder.mkdirs();
    noticesReportFolder.mkdirs();
    reportService.createReportPdfFile(pdfReportFolder, projectVersionWrapper.getProjectView(), projectVersionWrapper.getProjectVersionView());
    reportService.createNoticesReportFile(noticesReportFolder, projectVersionWrapper.getProjectView(), projectVersionWrapper.getProjectVersionView());
}
Also used : ReportService(com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService) BlackDuckTestConnection(com.synopsys.integration.detect.battery.docker.integration.BlackDuckTestConnection) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) File(java.io.File) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

BlackDuckTestConnection (com.synopsys.integration.detect.battery.docker.integration.BlackDuckTestConnection)5 File (java.io.File)4 Test (org.junit.jupiter.api.Test)4 ProjectVersionWrapper (com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper)3 ReportService (com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService)3 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)2 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)1 ProjectSyncModel (com.synopsys.integration.blackduck.service.model.ProjectSyncModel)1 ImpactAnalysisBatchOutput (com.synopsys.integration.detect.tool.impactanalysis.service.ImpactAnalysisBatchOutput)1 ImpactAnalysisBatchRunner (com.synopsys.integration.detect.tool.impactanalysis.service.ImpactAnalysisBatchRunner)1 ImpactAnalysisUploadService (com.synopsys.integration.detect.tool.impactanalysis.service.ImpactAnalysisUploadService)1 NameVersion (com.synopsys.integration.util.NameVersion)1 NoThreadExecutorService (com.synopsys.integration.util.NoThreadExecutorService)1 Path (java.nio.file.Path)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 Disabled (org.junit.jupiter.api.Disabled)1