Search in sources :

Example 1 with ComponentUnknownVersionWithStatusNotificationContent

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()));
}
Also used : ComponentUnknownVersionNotificationContent(com.synopsys.integration.blackduck.api.manual.component.ComponentUnknownVersionNotificationContent) ComponentUnknownVersionWithStatusNotificationContent(com.synopsys.integration.alert.provider.blackduck.processor.model.ComponentUnknownVersionWithStatusNotificationContent)

Example 2 with ComponentUnknownVersionWithStatusNotificationContent

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()));
    }
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) ComponentUnknownVersionNotificationView(com.synopsys.integration.blackduck.api.manual.view.ComponentUnknownVersionNotificationView) ComponentUnknownVersionNotificationContent(com.synopsys.integration.blackduck.api.manual.component.ComponentUnknownVersionNotificationContent) DetailedNotificationContent(com.synopsys.integration.alert.processor.api.detail.DetailedNotificationContent) ComponentUnknownVersionWithStatusNotificationContent(com.synopsys.integration.alert.provider.blackduck.processor.model.ComponentUnknownVersionWithStatusNotificationContent) Test(org.junit.jupiter.api.Test)

Aggregations

ComponentUnknownVersionWithStatusNotificationContent (com.synopsys.integration.alert.provider.blackduck.processor.model.ComponentUnknownVersionWithStatusNotificationContent)2 ComponentUnknownVersionNotificationContent (com.synopsys.integration.blackduck.api.manual.component.ComponentUnknownVersionNotificationContent)2 AlertNotificationModel (com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)1 DetailedNotificationContent (com.synopsys.integration.alert.processor.api.detail.DetailedNotificationContent)1 ComponentUnknownVersionNotificationView (com.synopsys.integration.blackduck.api.manual.view.ComponentUnknownVersionNotificationView)1 Test (org.junit.jupiter.api.Test)1