Search in sources :

Example 1 with ProjectNotificationView

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

the class ProjectNotificationDetailExtractorTest method extractDetailedContentTest.

@Test
public void extractDetailedContentTest() throws IOException {
    String jsonContent = TestResourceUtils.readFileToString(NOTIFICATION_JSON_PATH);
    ProjectNotificationView projectNotificationView = gson.fromJson(jsonContent, ProjectNotificationView.class);
    ProjectNotificationContent projectNotificationContent = projectNotificationView.getContent();
    AlertNotificationModel notification = new AlertNotificationModel(0L, 0L, "BlackDuck", "Config 1", null, null, null, null, false);
    ProjectNotificationDetailExtractor extractor = new ProjectNotificationDetailExtractor();
    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(projectNotificationContent.getProjectName(), optionalProjectName.get());
    assertTrue(detailedNotificationContent.getPolicyName().isEmpty(), "Expected no policy name to be present");
    assertEquals(0, detailedNotificationContent.getVulnerabilitySeverities().size());
}
Also used : ProjectNotificationContent(com.synopsys.integration.blackduck.api.manual.component.ProjectNotificationContent) AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) ProjectNotificationView(com.synopsys.integration.blackduck.api.manual.view.ProjectNotificationView) DetailedNotificationContent(com.synopsys.integration.alert.processor.api.detail.DetailedNotificationContent) Test(org.junit.jupiter.api.Test)

Example 2 with ProjectNotificationView

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

the class JmsNotificationReceiverTestIT method createAlertNotificationModel.

private AlertNotificationModel createAlertNotificationModel(Long id, boolean processed) {
    ProjectNotificationContent projectNotificationContent = new ProjectNotificationContent();
    projectNotificationContent.setProject("project");
    projectNotificationContent.setProjectName(String.format("projectName-%s", id));
    projectNotificationContent.setOperationType(OperationType.CREATE);
    ProjectNotificationView projectNotificationView = new ProjectNotificationView();
    projectNotificationView.setContent(projectNotificationContent);
    projectNotificationView.setType(NotificationType.PROJECT);
    String content = gson.toJson(projectNotificationView);
    return new AlertNotificationModel(id, blackDuckGlobalConfigId, "provider_blackduck", "DELETED CONFIGURATION", NotificationType.PROJECT.name(), content, DateUtils.createCurrentDateTimestamp(), DateUtils.createCurrentDateTimestamp(), processed);
}
Also used : ProjectNotificationContent(com.synopsys.integration.blackduck.api.manual.component.ProjectNotificationContent) AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) ProjectNotificationView(com.synopsys.integration.blackduck.api.manual.view.ProjectNotificationView)

Aggregations

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