use of com.synopsys.integration.exception.IntegrationException in project hub-alert by blackducksoftware.
the class BlackDuckProviderDataAccessor method getEmailAddressesByProvider.
private List<ProviderUserModel> getEmailAddressesByProvider(ConfigurationModel blackDuckConfiguration) throws IntegrationException {
BlackDuckServicesFactory blackDuckServicesFactory = createBlackDuckServicesFactory(blackDuckConfiguration);
BlackDuckApiClient blackDuckService = blackDuckServicesFactory.getBlackDuckApiClient();
ApiDiscovery apiDiscovery = blackDuckServicesFactory.getApiDiscovery();
Set<String> allActiveBlackDuckEmailAddresses = getAllActiveBlackDuckEmailAddresses(blackDuckService, apiDiscovery);
return allActiveBlackDuckEmailAddresses.stream().map(email -> new ProviderUserModel(email, false)).collect(Collectors.toList());
}
use of com.synopsys.integration.exception.IntegrationException in project hub-alert by blackducksoftware.
the class JiraCloudIssueCreator method retrieveProjectComponent.
private ProjectComponent retrieveProjectComponent() throws AlertException {
String jiraProjectName = distributionDetails.getProjectNameOrKey();
PageOfProjectsResponseModel projectsResponseModel;
try {
projectsResponseModel = projectService.getProjectsByName(jiraProjectName);
} catch (IntegrationException e) {
throw new AlertException("Failed to retrieve projects from Jira", e);
}
return projectsResponseModel.getProjects().stream().filter(project -> jiraProjectName.equals(project.getName()) || jiraProjectName.equals(project.getKey())).findAny().orElseThrow(() -> new AlertException(String.format("Unable to find project matching '%s'", jiraProjectName)));
}
use of com.synopsys.integration.exception.IntegrationException in project hub-alert by blackducksoftware.
the class NotificationWaitJobTask method waitForNotificationToBeProcessedByAllJobs.
private boolean waitForNotificationToBeProcessedByAllJobs() throws IntegrationException {
String response = alertRequestUtility.executeGetRequest("/api/audit?pageNumber=0&pageSize=2&searchTerm=VULNERABILITY&sortField=createdAt&sortOrder=desc&onlyShowSentNotifications=false", "Could not get the Alert audit entries.");
AuditEntryPageModel auditEntryPageModel = gson.fromJson(response, AuditEntryPageModel.class);
Optional<AuditEntryModel> matchingAuditEntry = auditEntryPageModel.getContent().stream().filter(auditEntryModel -> isNotificationAfterTime(startSearchTime, auditEntryModel.getNotification())).filter(auditEntryModel -> NotificationType.VULNERABILITY.name().equals(auditEntryModel.getNotification().getNotificationType())).filter(auditEntryModel -> isNotificationForNewVulnerabilities(auditEntryModel.getNotification())).findFirst();
if (matchingAuditEntry.isPresent()) {
AuditEntryModel auditEntryModel = matchingAuditEntry.get();
intLogger.info(String.format("The notification has been received by %s jobs.", auditEntryModel.getJobs().size()));
return haveAllJobsSuccessfullyProcessed(auditEntryModel.getJobs());
}
return false;
}
use of com.synopsys.integration.exception.IntegrationException 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());
}
use of com.synopsys.integration.exception.IntegrationException in project hub-alert by blackducksoftware.
the class DockerTagRetrieverTest method getTagsModelTestIT.
@Test
@Tags({ @Tag(TestTags.DEFAULT_INTEGRATION), @Tag(TestTags.CUSTOM_EXTERNAL_CONNECTION) })
public void getTagsModelTestIT() throws IntegrationException {
IntLogger intLogger = new PrintStreamIntLogger(System.out, LogLevel.INFO);
IntHttpClient intHttpClient = new IntHttpClient(intLogger, gson, 10, true, ProxyInfo.NO_PROXY_INFO);
HttpUrl httpUrl = new HttpUrl("https://google.com");
Request testRequest = new Request.Builder(httpUrl).build();
try (Response googleResponse = intHttpClient.execute(testRequest)) {
googleResponse.throwExceptionForError();
} catch (IntegrationException | IOException e) {
assumeTrue(null == e, "Could not connect. Skipping this test...");
}
DockerTagRetriever dockerTagRetriever = new DockerTagRetriever(gson, intHttpClient);
DockerTagsResponseModel tagsModel = dockerTagRetriever.getTagsModel();
assertFalse(tagsModel.isEmpty(), "Expected tags from the docker repo to exist");
}
Aggregations