use of com.synopsys.integration.alert.provider.blackduck.processor.model.ComponentUnknownVersionWithStatusNotificationContent in project hub-alert by blackducksoftware.
the class ComponentUnknownVersionNotificationDetailExtractor method extractDetailedContent.
@Override
public List<DetailedNotificationContent> extractDetailedContent(AlertNotificationModel alertNotificationModel, ComponentUnknownVersionNotificationView notificationView) {
ComponentUnknownVersionNotificationContent notificationContent = notificationView.getContent();
ComponentUnknownVersionWithStatusNotificationContent componentUnknownVersionNotificationContent = extractContents(notificationContent);
return List.of(DetailedNotificationContent.project(alertNotificationModel, componentUnknownVersionNotificationContent, notificationContent.getProjectName(), notificationContent.getProjectVersionName()));
}
use of com.synopsys.integration.alert.provider.blackduck.processor.model.ComponentUnknownVersionWithStatusNotificationContent in project hub-alert by blackducksoftware.
the class ComponentUnknownVersionNotificationDetailExtractorTest method extractDetailedContentTest.
@Test
public void extractDetailedContentTest() throws IOException {
String jsonContent = TestResourceUtils.readFileToString(NOTIFICATION_JSON_PATH);
ComponentUnknownVersionNotificationView notificationView = gson.fromJson(jsonContent, ComponentUnknownVersionNotificationView.class);
ComponentUnknownVersionNotificationContent notificationContent = notificationView.getContent();
AlertNotificationModel notification = new AlertNotificationModel(0L, 0L, "BlackDuck", "Config 1", null, null, null, null, false);
ComponentUnknownVersionNotificationDetailExtractor extractor = new ComponentUnknownVersionNotificationDetailExtractor();
List<DetailedNotificationContent> detailedNotificationContents = extractor.extractDetailedContent(notification, notificationView);
assertEquals(1, detailedNotificationContents.size());
for (DetailedNotificationContent detailedContent : detailedNotificationContents) {
Optional<String> optionalProjectName = detailedContent.getProjectName();
assertTrue(optionalProjectName.isPresent(), "Expect project name to be present");
assertEquals(notificationContent.getProjectName(), optionalProjectName.get());
assertTrue(detailedContent.getPolicyName().isEmpty(), "Expected no policy name to be present");
assertEquals(0, detailedContent.getVulnerabilitySeverities().size());
assertEquals(ComponentUnknownVersionWithStatusNotificationContent.class, detailedContent.getNotificationContentWrapper().getNotificationContentClass());
ComponentUnknownVersionWithStatusNotificationContent content = (ComponentUnknownVersionWithStatusNotificationContent) detailedContent.getNotificationContentWrapper().getNotificationContent();
assertEquals("project", content.getProjectName());
assertEquals("1", content.getProjectVersionName());
assertEquals("Apache Tomcat", content.getComponentName());
assertEquals(1, content.getCriticalVulnerabilityCount());
assertEquals(8, content.getHighVulnerabilityCount());
assertEquals(58, content.getMediumVulnerabilityCount());
assertEquals(29, content.getLowVulnerabilityCount());
assertEquals("0.0.1", content.getCriticalVulnerabilityVersionName());
assertEquals("6.0.0", content.getHighVulnerabilityVersionName());
assertEquals("6.0.0", content.getMediumVulnerabilityVersionName());
assertEquals("TOMCAT_9_0_0_M7", content.getLowVulnerabilityVersionName());
assertTrue(StringUtils.isNotBlank(content.getBomComponent()));
assertTrue(StringUtils.isNotBlank(content.getComponent()));
assertTrue(StringUtils.isNotBlank(content.getCriticalVulnerabilityVersion()));
assertTrue(StringUtils.isNotBlank(content.getHighVulnerabilityVersion()));
assertTrue(StringUtils.isNotBlank(content.getMediumVulnerabilityVersion()));
assertTrue(StringUtils.isNotBlank(content.getLowVulnerabilityVersion()));
}
}
Aggregations