Search in sources :

Example 11 with BufferedIntLogger

use of com.synopsys.integration.log.BufferedIntLogger in project synopsys-detect by blackducksoftware.

the class RapidScanResultAggregatorTest method testEmptyResults.

@Test
public void testEmptyResults() {
    List<DeveloperScanComponentResultView> results = Collections.emptyList();
    RapidScanResultAggregator aggregator = new RapidScanResultAggregator();
    RapidScanAggregateResult aggregateResult = aggregator.aggregateData(results);
    BufferedIntLogger logger = new BufferedIntLogger();
    aggregateResult.logResult(logger);
    RapidScanResultSummary summary = aggregateResult.getSummary();
    assertEquals(0, summary.getPolicyErrorCount());
    assertEquals(0, summary.getPolicyWarningCount());
    assertEquals(0, summary.getSecurityErrorCount());
    assertEquals(0, summary.getSecurityWarningCount());
    assertEquals(0, summary.getLicenseErrorCount());
    assertEquals(0, summary.getLicenseWarningCount());
    assertFalse(logger.getOutputList(LogLevel.INFO).isEmpty());
}
Also used : DeveloperScanComponentResultView(com.synopsys.integration.blackduck.api.manual.view.DeveloperScanComponentResultView) RapidScanResultAggregator(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanResultAggregator) RapidScanResultSummary(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanResultSummary) BufferedIntLogger(com.synopsys.integration.log.BufferedIntLogger) RapidScanAggregateResult(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanAggregateResult) Test(org.junit.jupiter.api.Test)

Example 12 with BufferedIntLogger

use of com.synopsys.integration.log.BufferedIntLogger in project synopsys-detect by blackducksoftware.

the class BlackDuckTestConnection method fromEnvironment.

public static BlackDuckTestConnection fromEnvironment() {
    Assertions.assertTrue(System.getenv().containsKey(BLACKDUCK_URL), "Integration tests require BLACKDUCK_URL is set in the environment");
    Assertions.assertTrue(System.getenv().containsKey(BLACKDUCK_API_TOKEN), "Integration tests require BLACKDUCK_API_TOKEN is set in the environment");
    String blackduckUrl = System.getenv().get(BLACKDUCK_URL);
    String blackduckApiToken = System.getenv().get(BLACKDUCK_API_TOKEN);
    BlackDuckServerConfigBuilder blackDuckServerConfigBuilder = BlackDuckServerConfig.newApiTokenBuilder();
    blackDuckServerConfigBuilder.setProperties(System.getenv().entrySet());
    blackDuckServerConfigBuilder.setUrl(blackduckUrl);
    blackDuckServerConfigBuilder.setApiToken(blackduckApiToken);
    blackDuckServerConfigBuilder.setTrustCert(trustCert);
    blackDuckServerConfigBuilder.setTimeoutInSeconds(5 * 60);
    BlackDuckServicesFactory blackDuckServicesFactory = blackDuckServerConfigBuilder.build().createBlackDuckServicesFactory(new BufferedIntLogger());
    return new BlackDuckTestConnection(blackduckUrl, blackduckApiToken, blackDuckServicesFactory);
}
Also used : BlackDuckServerConfigBuilder(com.synopsys.integration.blackduck.configuration.BlackDuckServerConfigBuilder) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) BufferedIntLogger(com.synopsys.integration.log.BufferedIntLogger)

Example 13 with BufferedIntLogger

use of com.synopsys.integration.log.BufferedIntLogger in project synopsys-detect by blackducksoftware.

the class BlackDuckTestConnection method createReportService.

public ReportService createReportService() {
    HttpUrl blackDuckUrl = blackDuckServicesFactory.getBlackDuckHttpClient().getBlackDuckUrl();
    IntegrationEscapeUtil integrationEscapeUtil = blackDuckServicesFactory.createIntegrationEscapeUtil();
    long reportServiceTimeout = 120 * 1000;
    return new ReportService(blackDuckServicesFactory.getGson(), blackDuckUrl, blackDuckServicesFactory.getBlackDuckApiClient(), blackDuckServicesFactory.getApiDiscovery(), new BufferedIntLogger(), integrationEscapeUtil, reportServiceTimeout);
}
Also used : IntegrationEscapeUtil(com.synopsys.integration.util.IntegrationEscapeUtil) ReportService(com.synopsys.integration.detect.workflow.blackduck.report.service.ReportService) BufferedIntLogger(com.synopsys.integration.log.BufferedIntLogger) HttpUrl(com.synopsys.integration.rest.HttpUrl)

Example 14 with BufferedIntLogger

use of com.synopsys.integration.log.BufferedIntLogger in project synopsys-detect by blackducksoftware.

the class RapidScanResultAggregatorTest method testResults.

@Test
public void testResults() {
    List<DeveloperScanComponentResultView> results = createResultList();
    RapidScanResultAggregator aggregator = new RapidScanResultAggregator();
    RapidScanAggregateResult aggregateResult = aggregator.aggregateData(results);
    BufferedIntLogger logger = new BufferedIntLogger();
    aggregateResult.logResult(logger);
    RapidScanResultSummary summary = aggregateResult.getSummary();
    assertEquals(1, summary.getPolicyErrorCount());
    assertEquals(1, summary.getPolicyWarningCount());
    assertEquals(1, summary.getSecurityErrorCount());
    assertEquals(1, summary.getSecurityWarningCount());
    assertEquals(1, summary.getLicenseErrorCount());
    assertEquals(1, summary.getLicenseWarningCount());
    assertFalse(logger.getOutputList(LogLevel.INFO).isEmpty());
}
Also used : DeveloperScanComponentResultView(com.synopsys.integration.blackduck.api.manual.view.DeveloperScanComponentResultView) RapidScanResultAggregator(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanResultAggregator) RapidScanResultSummary(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanResultSummary) BufferedIntLogger(com.synopsys.integration.log.BufferedIntLogger) RapidScanAggregateResult(com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanAggregateResult) Test(org.junit.jupiter.api.Test)

Example 15 with BufferedIntLogger

use of com.synopsys.integration.log.BufferedIntLogger in project synopsys-detect by blackducksoftware.

the class DetectStatusLoggerTest method testContent.

@Test
public void testContent() throws IOException {
    File expectedOutputFile = new File("src/test/resources/workflow/status/expectedStatusLoggerOutput.txt");
    String expectedOutput = FileUtils.readFileToString(expectedOutputFile, StandardCharsets.UTF_8);
    BufferedIntLogger loggerActual = new BufferedIntLogger();
    DetectStatusLogger statusLogger = new DetectStatusLogger();
    List<Status> statusSummaries = createStatus();
    List<DetectResult> detectResults = createResults();
    List<DetectIssue> detectIssues = createIssues();
    List<Operation> detectOperations = createOperations();
    statusLogger.logDetectStatus(loggerActual, statusSummaries, detectResults, detectIssues, detectOperations, ExitCodeType.SUCCESS);
    String actualOutput = loggerActual.getOutputString(LogLevel.INFO);
    assertEquals(expectedOutput.trim().replaceAll("\r?\n", "\n"), actualOutput.trim().replaceAll("\r?\n", "\n"));
}
Also used : AirGapDetectResult(com.synopsys.integration.detect.workflow.result.AirGapDetectResult) DetectResult(com.synopsys.integration.detect.workflow.result.DetectResult) ReportDetectResult(com.synopsys.integration.detect.workflow.result.ReportDetectResult) BlackDuckBomDetectResult(com.synopsys.integration.detect.workflow.result.BlackDuckBomDetectResult) BufferedIntLogger(com.synopsys.integration.log.BufferedIntLogger) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

BufferedIntLogger (com.synopsys.integration.log.BufferedIntLogger)26 Test (org.junit.jupiter.api.Test)20 IntLogger (com.synopsys.integration.log.IntLogger)8 File (java.io.File)7 UserView (com.synopsys.integration.blackduck.api.generated.view.UserView)6 NotificationTaskRange (com.synopsys.integration.blackduck.service.model.NotificationTaskRange)6 HttpUrl (com.synopsys.integration.rest.HttpUrl)6 CodeLocationView (com.synopsys.integration.blackduck.api.generated.view.CodeLocationView)5 NotificationUserView (com.synopsys.integration.blackduck.api.manual.view.NotificationUserView)5 VersionBomCodeLocationBomComputedNotificationUserView (com.synopsys.integration.blackduck.api.manual.view.VersionBomCodeLocationBomComputedNotificationUserView)5 BlackDuckHttpClient (com.synopsys.integration.blackduck.http.client.BlackDuckHttpClient)5 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)5 NotificationService (com.synopsys.integration.blackduck.service.dataservice.NotificationService)5 HashSet (java.util.HashSet)5 ProjectVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView)4 BlackDuckServerConfigBuilder (com.synopsys.integration.blackduck.configuration.BlackDuckServerConfigBuilder)4 BlackDuckResponseResolver (com.synopsys.integration.blackduck.http.transform.subclass.BlackDuckResponseResolver)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Gson (com.google.gson.Gson)3 UploadBatchRunner (com.synopsys.integration.blackduck.codelocation.bdiolegacy.UploadBatchRunner)3