use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities in project hub-alert by blackducksoftware.
the class BlackDuckComponentVulnerabilityDetailsCreatorTest method toComponentVulnerabilitiesHasVulnerabilitiesFalseTest.
@Test
public void toComponentVulnerabilitiesHasVulnerabilitiesFalseTest() {
BlackDuckComponentVulnerabilityDetailsCreator vulnerabilityDetailsCreator = new BlackDuckComponentVulnerabilityDetailsCreator();
ComponentVulnerabilities vulns = vulnerabilityDetailsCreator.toComponentVulnerabilities(List.of());
assertFalse(vulns.hasVulnerabilities(), EXPECTED_VULNERABILITIES_MESSAGE);
}
use of com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities in project hub-alert by blackducksoftware.
the class BlackDuckComponentVulnerabilityDetailsCreatorTest method toComponentVulnerabilitiesTest.
@Test
public void toComponentVulnerabilitiesTest() throws IntegrationException {
BlackDuckComponentVulnerabilityDetailsCreator vulnerabilityDetailsCreator = new BlackDuckComponentVulnerabilityDetailsCreator();
BlackDuckProjectVersionComponentVulnerabilitiesView withCriticals = createVulnsView(ProjectVersionComponentVersionVulnerabilityRemediationCvss2SeverityType.CRITICAL);
ComponentVulnerabilities criticalVulns = vulnerabilityDetailsCreator.toComponentVulnerabilities(List.of(withCriticals));
assertTrue(criticalVulns.hasVulnerabilities(), EXPECTED_VULNERABILITIES_MESSAGE);
assertEquals(1, criticalVulns.getCritical().size());
assertEquals(0, criticalVulns.getHigh().size());
assertEquals(0, criticalVulns.getMedium().size());
assertEquals(0, criticalVulns.getLow().size());
BlackDuckProjectVersionComponentVulnerabilitiesView withHighs = createVulnsView(ProjectVersionComponentVersionVulnerabilityRemediationCvss2SeverityType.HIGH);
ComponentVulnerabilities highVulns = vulnerabilityDetailsCreator.toComponentVulnerabilities(List.of(withHighs));
assertTrue(highVulns.hasVulnerabilities(), EXPECTED_VULNERABILITIES_MESSAGE);
assertEquals(0, highVulns.getCritical().size());
assertEquals(1, highVulns.getHigh().size());
assertEquals(0, highVulns.getMedium().size());
assertEquals(0, highVulns.getLow().size());
BlackDuckProjectVersionComponentVulnerabilitiesView withMediums = createVulnsView(ProjectVersionComponentVersionVulnerabilityRemediationCvss2SeverityType.MEDIUM);
ComponentVulnerabilities mediumVulns = vulnerabilityDetailsCreator.toComponentVulnerabilities(List.of(withMediums));
assertTrue(mediumVulns.hasVulnerabilities(), EXPECTED_VULNERABILITIES_MESSAGE);
assertEquals(0, mediumVulns.getCritical().size());
assertEquals(0, mediumVulns.getHigh().size());
assertEquals(1, mediumVulns.getMedium().size());
assertEquals(0, mediumVulns.getLow().size());
BlackDuckProjectVersionComponentVulnerabilitiesView withLows = createVulnsView(ProjectVersionComponentVersionVulnerabilityRemediationCvss2SeverityType.LOW);
ComponentVulnerabilities lowVulns = vulnerabilityDetailsCreator.toComponentVulnerabilities(List.of(withLows));
assertTrue(lowVulns.hasVulnerabilities(), EXPECTED_VULNERABILITIES_MESSAGE);
assertEquals(0, lowVulns.getCritical().size());
assertEquals(0, lowVulns.getHigh().size());
assertEquals(0, lowVulns.getMedium().size());
assertEquals(1, lowVulns.getLow().size());
ComponentVulnerabilities allVulns = vulnerabilityDetailsCreator.toComponentVulnerabilities(List.of(withCriticals, withHighs, withMediums, withLows));
assertTrue(allVulns.hasVulnerabilities(), EXPECTED_VULNERABILITIES_MESSAGE);
assertEquals(1, allVulns.getCritical().size());
assertEquals(1, allVulns.getHigh().size());
assertEquals(1, allVulns.getMedium().size());
assertEquals(1, allVulns.getLow().size());
}
Aggregations