Search in sources :

Example 6 with DeveloperScanComponentResultView

use of com.synopsys.integration.blackduck.api.manual.view.DeveloperScanComponentResultView in project synopsys-detect by blackducksoftware.

the class RapidScanResultAggregatorTest method createResultList.

private List<DeveloperScanComponentResultView> createResultList() {
    List<DeveloperScanComponentResultView> resultList = new ArrayList<>();
    DeveloperScanComponentResultView view = createView();
    resultList.add(view);
    return resultList;
}
Also used : DeveloperScanComponentResultView(com.synopsys.integration.blackduck.api.manual.view.DeveloperScanComponentResultView) ArrayList(java.util.ArrayList)

Example 7 with DeveloperScanComponentResultView

use of com.synopsys.integration.blackduck.api.manual.view.DeveloperScanComponentResultView in project synopsys-detect by blackducksoftware.

the class RapidScanResultAggregatorTest method createView.

private DeveloperScanComponentResultView createView() {
    return new DeveloperScanComponentResultView() {

        @Override
        public String getComponentName() {
            return "component_1";
        }

        @Override
        public String getVersionName() {
            return "component_version_1";
        }

        @Override
        public String getComponentIdentifier() {
            return "component_1:component_version_1";
        }

        @Override
        public Set<String> getViolatingPolicyNames() {
            Set<String> policyNames = new HashSet<>();
            policyNames.add("component_policy");
            policyNames.add("vulnerability_policy");
            policyNames.add("license_policy");
            return policyNames;
        }

        @Override
        public Set<PolicyViolationVulnerabilityView> getPolicyViolationVulnerabilities() {
            Set<PolicyViolationVulnerabilityView> vulnerabilities = new HashSet<>();
            PolicyViolationVulnerabilityView view = new PolicyViolationVulnerabilityView() {

                @Override
                public String getName() {
                    return "Vulnerability violation";
                }

                @Override
                public String getDescription() {
                    return "Violation Description";
                }

                @Override
                public Set<String> getViolatingPolicyNames() {
                    return Collections.singleton("vulnerability_policy");
                }

                @Override
                public String getErrorMessage() {
                    return "vulnerability_error_1";
                }

                @Override
                public String getWarningMessage() {
                    return "vulnerability_warning_1";
                }
            };
            vulnerabilities.add(view);
            return vulnerabilities;
        }

        @Override
        public Set<PolicyViolationLicenseView> getPolicyViolationLicenses() {
            Set<PolicyViolationLicenseView> licenses = new HashSet<>();
            PolicyViolationLicenseView view = new PolicyViolationLicenseView() {

                @Override
                public String getLicenseName() {
                    return "License name";
                }

                @Override
                public Set<String> getViolatingPolicyNames() {
                    return Collections.singleton("license_policy");
                }

                @Override
                public String getErrorMessage() {
                    return "license_error_1";
                }

                @Override
                public String getWarningMessage() {
                    return "license_warning_1";
                }
            };
            licenses.add(view);
            return licenses;
        }

        @Override
        public String getErrorMessage() {
            return "component_1_error_message";
        }

        @Override
        public String getWarningMessage() {
            return "component_1_warning_message";
        }
    };
}
Also used : DeveloperScanComponentResultView(com.synopsys.integration.blackduck.api.manual.view.DeveloperScanComponentResultView) PolicyViolationVulnerabilityView(com.synopsys.integration.blackduck.api.manual.view.PolicyViolationVulnerabilityView) HashSet(java.util.HashSet) PolicyViolationLicenseView(com.synopsys.integration.blackduck.api.manual.view.PolicyViolationLicenseView)

Example 8 with DeveloperScanComponentResultView

use of com.synopsys.integration.blackduck.api.manual.view.DeveloperScanComponentResultView 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)

Aggregations

DeveloperScanComponentResultView (com.synopsys.integration.blackduck.api.manual.view.DeveloperScanComponentResultView)8 RapidScanResultSummary (com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanResultSummary)4 Test (org.junit.jupiter.api.Test)4 RapidScanAggregateResult (com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanAggregateResult)3 RapidScanResultAggregator (com.synopsys.integration.detect.workflow.blackduck.developer.aggregate.RapidScanResultAggregator)3 LinkedList (java.util.LinkedList)3 PolicyViolationLicenseView (com.synopsys.integration.blackduck.api.manual.view.PolicyViolationLicenseView)2 PolicyViolationVulnerabilityView (com.synopsys.integration.blackduck.api.manual.view.PolicyViolationVulnerabilityView)2 BufferedIntLogger (com.synopsys.integration.log.BufferedIntLogger)2 File (java.io.File)2 HashSet (java.util.HashSet)2 Gson (com.google.gson.Gson)1 ExitCodePublisher (com.synopsys.integration.detect.lifecycle.shutdown.ExitCodePublisher)1 DetectRunId (com.synopsys.integration.detect.workflow.DetectRunId)1 DirectoryManager (com.synopsys.integration.detect.workflow.file.DirectoryManager)1 DirectoryOptions (com.synopsys.integration.detect.workflow.file.DirectoryOptions)1 HttpUrl (com.synopsys.integration.rest.HttpUrl)1 NameVersion (com.synopsys.integration.util.NameVersion)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1