Search in sources :

Example 1 with ProjectVersionNotificationView

use of com.synopsys.integration.blackduck.api.manual.view.ProjectVersionNotificationView in project hub-alert by blackducksoftware.

the class NotificationDetailExtractionDelegatorTest method createProjectVersionNotificationView.

private static ProjectVersionNotificationView createProjectVersionNotificationView() {
    ProjectVersionNotificationContent projectVersionNotificationContent = new ProjectVersionNotificationContent();
    projectVersionNotificationContent.setProject("https://my-project");
    projectVersionNotificationContent.setProjectName("my project!");
    projectVersionNotificationContent.setProjectVersion("https://project-version");
    projectVersionNotificationContent.setProjectVersionName("a name for a version 02468");
    projectVersionNotificationContent.setOperationType(OperationType.CREATE);
    ProjectVersionNotificationView projectVersionNotificationView = new ProjectVersionNotificationView();
    projectVersionNotificationView.setType(NotificationType.PROJECT_VERSION);
    projectVersionNotificationView.setContent(projectVersionNotificationContent);
    return projectVersionNotificationView;
}
Also used : ProjectVersionNotificationContent(com.synopsys.integration.blackduck.api.manual.component.ProjectVersionNotificationContent) ProjectVersionNotificationView(com.synopsys.integration.blackduck.api.manual.view.ProjectVersionNotificationView)

Example 2 with ProjectVersionNotificationView

use of com.synopsys.integration.blackduck.api.manual.view.ProjectVersionNotificationView in project hub-alert by blackducksoftware.

the class ProjectVersionNotificationDetailExtractorTest method extractDetailedContentTest.

@Test
public void extractDetailedContentTest() throws IOException {
    String jsonContent = TestResourceUtils.readFileToString(NOTIFICATION_JSON_PATH);
    ProjectVersionNotificationView projectNotificationView = gson.fromJson(jsonContent, ProjectVersionNotificationView.class);
    ProjectVersionNotificationContent projectVersionNotificationContent = projectNotificationView.getContent();
    AlertNotificationModel notification = new AlertNotificationModel(0L, 0L, "BlackDuck", "Config 1", null, null, null, null, false);
    ProjectVersionNotificationDetailExtractor extractor = new ProjectVersionNotificationDetailExtractor();
    List<DetailedNotificationContent> detailedNotificationContents = extractor.extractDetailedContent(notification, projectNotificationView);
    assertEquals(1, detailedNotificationContents.size());
    DetailedNotificationContent detailedNotificationContent = detailedNotificationContents.get(0);
    Optional<String> optionalProjectName = detailedNotificationContent.getProjectName();
    assertTrue(optionalProjectName.isPresent(), "Expect project name to be present");
    assertEquals(projectVersionNotificationContent.getProjectName(), optionalProjectName.get());
    assertTrue(detailedNotificationContent.getPolicyName().isEmpty(), "Expected no policy name to be present");
    assertEquals(0, detailedNotificationContent.getVulnerabilitySeverities().size());
}
Also used : ProjectVersionNotificationContent(com.synopsys.integration.blackduck.api.manual.component.ProjectVersionNotificationContent) AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) ProjectVersionNotificationView(com.synopsys.integration.blackduck.api.manual.view.ProjectVersionNotificationView) DetailedNotificationContent(com.synopsys.integration.alert.processor.api.detail.DetailedNotificationContent) Test(org.junit.jupiter.api.Test)

Aggregations

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