use of com.synopsys.integration.blackduck.api.manual.view.NotificationView in project blackduck-common by blackducksoftware.
the class BlackDuckResponseResolverTest method testGettingRuntimeClass.
@Test
public void testGettingRuntimeClass() throws IOException {
String projectVersionJson = IOUtils.toString(this.getClass().getResourceAsStream("/json/notifications/project_version.json"), StandardCharsets.UTF_8);
String vulnerabilityJson = IOUtils.toString(this.getClass().getResourceAsStream("/json/notifications/vulnerability.json"), StandardCharsets.UTF_8);
BlackDuckResponseResolver blackDuckResponseResolver = new BlackDuckResponseResolver(new Gson());
NotificationView projectVersionNotificationView = blackDuckResponseResolver.resolve(projectVersionJson, NotificationView.class);
NotificationView vulnerabilityNotificationView = blackDuckResponseResolver.resolve(vulnerabilityJson, NotificationView.class);
assertTrue(projectVersionNotificationView instanceof ProjectVersionNotificationView);
assertTrue(vulnerabilityNotificationView instanceof VulnerabilityNotificationView);
}
use of com.synopsys.integration.blackduck.api.manual.view.NotificationView in project blackduck-common by blackducksoftware.
the class NotificationService method getPageOfNotifications.
public BlackDuckPageResponse<NotificationView> getPageOfNotifications(NotificationEditor notificationEditor, BlackDuckPageDefinition blackDuckPageDefinition) throws IntegrationException {
BlackDuckRequestBuilder blackDuckRequestBuilder = createNotificationRequestBuilder(notificationEditor).setBlackDuckPageDefinition(blackDuckPageDefinition);
BlackDuckMultipleRequest<NotificationView> requestMultiple = blackDuckRequestBuilder.buildBlackDuckRequest(notificationsResponses);
return blackDuckApiClient.getPageResponse(requestMultiple);
}
use of com.synopsys.integration.blackduck.api.manual.view.NotificationView in project blackduck-common by blackducksoftware.
the class NotificationService method getLatestNotificationDate.
/**
* @return The java.util.Date of the most recent notification. If there are no notifications, the current date will be returned. This can set an initial start time window for all future notifications.
* @throws IntegrationException
*/
public Date getLatestNotificationDate() throws IntegrationException {
BlackDuckRequestBuilder blackDuckRequestBuilder = createLatestDateRequestBuilder();
BlackDuckMultipleRequest<NotificationView> requestMultiple = blackDuckRequestBuilder.buildBlackDuckRequest(notificationsResponses);
List<NotificationView> notifications = blackDuckApiClient.getSomeResponses(requestMultiple, 1);
return getFirstCreatedAtDate(notifications);
}
use of com.synopsys.integration.blackduck.api.manual.view.NotificationView in project blackduck-common by blackducksoftware.
the class NotificationService method getAllNotifications.
public List<NotificationView> getAllNotifications(NotificationEditor notificationEditor) throws IntegrationException {
BlackDuckRequestBuilder blackDuckRequestBuilder = createNotificationRequestBuilder(notificationEditor);
BlackDuckMultipleRequest<NotificationView> requestMultiple = blackDuckRequestBuilder.buildBlackDuckRequest(notificationsResponses);
List<NotificationView> possiblyPoorlyFilteredNotifications = blackDuckApiClient.getAllResponses(requestMultiple);
return reallyFilterNotifications(possiblyPoorlyFilteredNotifications, notificationEditor.getNotificationTypesToInclude());
}
use of com.synopsys.integration.blackduck.api.manual.view.NotificationView in project blackduck-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();
}
Aggregations