Search in sources :

Example 6 with NotificationView

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

the class NotificationGeneratorUtils method createNotificationView.

public static NotificationView createNotificationView(Date createdAt, NotificationType type) {
    NotificationView view = new NotificationView();
    view.setContentType("application/json");
    view.setCreatedAt(createdAt);
    view.setType(type);
    return view;
}
Also used : NotificationView(com.synopsys.integration.blackduck.api.manual.view.NotificationView)

Example 7 with NotificationView

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

the class NotificationDetailExtractionDelegator method wrapNotification.

public final List<DetailedNotificationContent> wrapNotification(AlertNotificationModel notification) {
    NotificationView notificationView = blackDuckResponseResolver.resolve(notification.getContent(), NotificationView.class);
    Optional<NotificationDetailExtractor> notificationExtractorOptional = getNotificationExtractor(notificationView.getClass());
    if (notificationExtractorOptional.isPresent()) {
        NotificationDetailExtractor notificationDetailExtractor = notificationExtractorOptional.get();
        return notificationDetailExtractor.extractDetailedContent(notification, notificationView);
    }
    logger.warn("Did not find extractor for notification view: {}", notificationView.getClass().getSimpleName());
    return List.of();
}
Also used : NotificationView(com.synopsys.integration.blackduck.api.manual.view.NotificationView)

Example 8 with NotificationView

use of com.synopsys.integration.blackduck.api.manual.view.NotificationView in project blackduck-common by blackducksoftware.

the class VerifyNotifications method verify.

public static void verify(UserView currentUser, BlackDuckRegistrationService blackDuckRegistrationService, NotificationService notificationService, Date userStartDate, Date systemStartDate) throws IntegrationException {
    Date endDate = Date.from(new Date().toInstant().plus(7, ChronoUnit.DAYS));
    NotificationEditor systemDateEditor = new NotificationEditor(systemStartDate, endDate);
    NotificationEditor userDateEditor = new NotificationEditor(userStartDate, endDate);
    List<String> bomComputedFilter = Arrays.asList(NotificationType.VERSION_BOM_CODE_LOCATION_BOM_COMPUTED.name());
    NotificationEditor systemDateFilteredEditor = new NotificationEditor(systemStartDate, endDate, bomComputedFilter);
    NotificationEditor userDateFilteredEditor = new NotificationEditor(userStartDate, endDate, bomComputedFilter);
    List<NotificationView> allNotifications = notificationService.getAllNotifications(systemDateEditor);
    List<NotificationUserView> allUserNotifications = notificationService.getAllUserNotifications(currentUser, userDateEditor);
    List<NotificationView> filteredNotifications = notificationService.getAllNotifications(systemDateFilteredEditor);
    List<NotificationUserView> filteredUserNotifications = notificationService.getAllUserNotifications(currentUser, userDateFilteredEditor);
    assertFalse(allNotifications.isEmpty());
    assertFalse(allUserNotifications.isEmpty());
    assertFalse(filteredNotifications.isEmpty());
    assertFalse(filteredUserNotifications.isEmpty());
    List<VersionBomCodeLocationBomComputedNotificationView> bomComputedNotifications = filteredNotifications.stream().map(notificationView -> (VersionBomCodeLocationBomComputedNotificationView) notificationView).collect(Collectors.toList());
    List<VersionBomCodeLocationBomComputedNotificationUserView> bomComputedUserNotifications = filteredUserNotifications.stream().map(notificationView -> (VersionBomCodeLocationBomComputedNotificationUserView) notificationView).collect(Collectors.toList());
    // ejk - BD has a known bug in 2020.10.0 where version bom computed is
    // NOT included when asking for all
    /*
         * ejk 2021-07-16
         * TODO should this be in VersionSupport?
         */
    String version = blackDuckRegistrationService.getBlackDuckServerData().getVersion();
    if (!"2020.10.0".equals(version)) {
        assertTrue(allNotifications.containsAll(bomComputedNotifications));
        assertTrue(allUserNotifications.containsAll(bomComputedUserNotifications));
    }
    assertEquals(getContents(bomComputedNotifications), getContents(bomComputedUserNotifications));
}
Also used : VersionBomCodeLocationBomComputedNotificationView(com.synopsys.integration.blackduck.api.manual.view.VersionBomCodeLocationBomComputedNotificationView) Arrays(java.util.Arrays) IntegrationException(com.synopsys.integration.exception.IntegrationException) Date(java.util.Date) NotificationType(com.synopsys.integration.blackduck.api.manual.temporary.enumeration.NotificationType) VersionBomCodeLocationBomComputedNotificationUserView(com.synopsys.integration.blackduck.api.manual.view.VersionBomCodeLocationBomComputedNotificationUserView) NotificationService(com.synopsys.integration.blackduck.service.dataservice.NotificationService) NotificationUserView(com.synopsys.integration.blackduck.api.manual.view.NotificationUserView) BlackDuckRegistrationService(com.synopsys.integration.blackduck.service.dataservice.BlackDuckRegistrationService) VersionBomCodeLocationBomComputedNotificationContent(com.synopsys.integration.blackduck.api.manual.component.VersionBomCodeLocationBomComputedNotificationContent) Collectors(java.util.stream.Collectors) List(java.util.List) ChronoUnit(java.time.temporal.ChronoUnit) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NotificationEditor(com.synopsys.integration.blackduck.service.request.NotificationEditor) NotificationView(com.synopsys.integration.blackduck.api.manual.view.NotificationView) UserView(com.synopsys.integration.blackduck.api.generated.view.UserView) VersionBomCodeLocationBomComputedNotificationView(com.synopsys.integration.blackduck.api.manual.view.VersionBomCodeLocationBomComputedNotificationView) NotificationView(com.synopsys.integration.blackduck.api.manual.view.NotificationView) Date(java.util.Date) VersionBomCodeLocationBomComputedNotificationUserView(com.synopsys.integration.blackduck.api.manual.view.VersionBomCodeLocationBomComputedNotificationUserView) VersionBomCodeLocationBomComputedNotificationView(com.synopsys.integration.blackduck.api.manual.view.VersionBomCodeLocationBomComputedNotificationView) NotificationEditor(com.synopsys.integration.blackduck.service.request.NotificationEditor) VersionBomCodeLocationBomComputedNotificationUserView(com.synopsys.integration.blackduck.api.manual.view.VersionBomCodeLocationBomComputedNotificationUserView) NotificationUserView(com.synopsys.integration.blackduck.api.manual.view.NotificationUserView)

Example 9 with NotificationView

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

the class NotificationGeneratorUtils method createNotificationView.

public static NotificationView createNotificationView(Date createdAt, NotificationType type) {
    NotificationView view = new NotificationView();
    view.setContentType("application/json");
    view.setCreatedAt(createdAt);
    view.setType(type);
    return view;
}
Also used : NotificationView(com.synopsys.integration.blackduck.api.manual.view.NotificationView)

Aggregations

NotificationView (com.synopsys.integration.blackduck.api.manual.view.NotificationView)9 BlackDuckRequestBuilder (com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder)3 Gson (com.google.gson.Gson)1 UserView (com.synopsys.integration.blackduck.api.generated.view.UserView)1 VersionBomCodeLocationBomComputedNotificationContent (com.synopsys.integration.blackduck.api.manual.component.VersionBomCodeLocationBomComputedNotificationContent)1 NotificationType (com.synopsys.integration.blackduck.api.manual.temporary.enumeration.NotificationType)1 NotificationUserView (com.synopsys.integration.blackduck.api.manual.view.NotificationUserView)1 ProjectVersionNotificationView (com.synopsys.integration.blackduck.api.manual.view.ProjectVersionNotificationView)1 VersionBomCodeLocationBomComputedNotificationUserView (com.synopsys.integration.blackduck.api.manual.view.VersionBomCodeLocationBomComputedNotificationUserView)1 VersionBomCodeLocationBomComputedNotificationView (com.synopsys.integration.blackduck.api.manual.view.VersionBomCodeLocationBomComputedNotificationView)1 VulnerabilityNotificationView (com.synopsys.integration.blackduck.api.manual.view.VulnerabilityNotificationView)1 BlackDuckRegistrationService (com.synopsys.integration.blackduck.service.dataservice.BlackDuckRegistrationService)1 NotificationService (com.synopsys.integration.blackduck.service.dataservice.NotificationService)1 NotificationEditor (com.synopsys.integration.blackduck.service.request.NotificationEditor)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1 ChronoUnit (java.time.temporal.ChronoUnit)1 Arrays (java.util.Arrays)1 Date (java.util.Date)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1