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;
}
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();
}
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));
}
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;
}
Aggregations