use of com.synopsys.integration.blackduck.api.core.response.UrlMultipleResponses in project hub-alert by blackducksoftware.
the class BlackDuckMessageBomComponentDetailsCreator method retrieveComponentVulnerabilities.
private ComponentVulnerabilities retrieveComponentVulnerabilities(ProjectVersionComponentVersionView bomComponent) throws IntegrationException {
if (!vulnerabilityDetailsCreator.hasSecurityRisk(bomComponent)) {
return ComponentVulnerabilities.none();
}
if (StringUtils.isBlank(bomComponent.getComponentVersion())) {
return ComponentVulnerabilities.none();
}
List<HttpUrl> vulnerabilitiesUrls = createVulnerabilitiesLinks(bomComponent.getHref(), bomComponent.getOrigins());
List<BlackDuckProjectVersionComponentVulnerabilitiesView> allVulnerabilitiesViews = new ArrayList<>();
for (HttpUrl vulnerabilitiesUrl : vulnerabilitiesUrls) {
UrlMultipleResponses<BlackDuckProjectVersionComponentVulnerabilitiesView> urlMultipleResponses = new UrlMultipleResponses<>(vulnerabilitiesUrl, VULNERABILITIES_LINK.getResponseClass());
BlackDuckMultipleRequest<BlackDuckProjectVersionComponentVulnerabilitiesView> spec = new BlackDuckRequestBuilder().commonGet().addHeader(HttpHeaders.ACCEPT, VULNERABILITIES_MEDIA_TYPE).buildBlackDuckRequest(urlMultipleResponses);
allVulnerabilitiesViews.addAll(blackDuckApiClient.getAllResponses(spec));
}
return vulnerabilityDetailsCreator.toComponentVulnerabilities(allVulnerabilitiesViews);
}
use of com.synopsys.integration.blackduck.api.core.response.UrlMultipleResponses in project hub-alert by blackducksoftware.
the class BlackDuckNotificationRetrieverTest method retrievePageOfFilteredNotificationsTest.
@Test
public void retrievePageOfFilteredNotificationsTest() throws IntegrationException {
ProjectNotificationUserView projectNotificationView = new ProjectNotificationUserView();
BlackDuckPageResponse<NotificationUserView> pageResponse = new BlackDuckPageResponse<>(1, List.of(projectNotificationView));
UrlMultipleResponses<NotificationUserView> currentUserNotificationsUrl = new UrlMultipleResponses<>(new HttpUrl(THROWAWAY_SERVER), NotificationUserView.class);
UserView apiUser = Mockito.mock(UserView.class);
Mockito.doReturn(currentUserNotificationsUrl).when(apiUser).metaNotificationsLink();
UrlSingleResponse<UserView> currentUserUrl = new UrlSingleResponse<>(new HttpUrl(THROWAWAY_SERVER), UserView.class);
ApiDiscovery apiDiscovery = Mockito.mock(ApiDiscovery.class);
Mockito.doReturn(currentUserUrl).when(apiDiscovery).metaCurrentUserLink();
BlackDuckApiClient blackDuckApiClient = Mockito.mock(BlackDuckApiClient.class);
Mockito.doReturn(pageResponse).when(blackDuckApiClient).getPageResponse(Mockito.any(BlackDuckMultipleRequest.class));
Mockito.doReturn(apiUser).when(blackDuckApiClient).getResponse(Mockito.eq(currentUserUrl));
BlackDuckAccumulatorSearchDateManager dateRangeCreator = createDateRangeCreator();
BlackDuckNotificationRetriever notificationRetriever = new BlackDuckNotificationRetriever(blackDuckApiClient, apiDiscovery);
StatefulAlertPage<NotificationUserView, IntegrationException> notificationPage = notificationRetriever.retrievePageOfFilteredNotifications(dateRangeCreator.retrieveNextSearchDateRange(), List.of());
assertEquals(pageResponse.getItems(), notificationPage.getCurrentModels());
}
Aggregations