use of com.synopsys.integration.rest.HttpUrl in project hub-alert by blackducksoftware.
the class BlackDuckProviderDataAccessor method createProviderProject.
private ProviderProject createProviderProject(ProjectView projectView, BlackDuckApiClient blackDuckService) {
String projectOwnerEmail = null;
if (StringUtils.isNotBlank(projectView.getProjectOwner())) {
try {
HttpUrl projectOwnerHttpUrl = new HttpUrl(projectView.getProjectOwner());
UserView projectOwner = blackDuckService.getResponse(projectOwnerHttpUrl, UserView.class);
projectOwnerEmail = projectOwner.getEmail();
} catch (IntegrationException e) {
logger.errorAndDebug(createProjectOwnerNotFoundString(projectView.getName(), e.getMessage()), e);
}
}
String truncatedDescription = truncateDescription(projectView.getDescription());
return new ProviderProject(projectView.getName(), truncatedDescription, projectView.getMeta().getHref().toString(), projectOwnerEmail);
}
use of com.synopsys.integration.rest.HttpUrl 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.rest.HttpUrl 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");
}
use of com.synopsys.integration.rest.HttpUrl in project hub-alert by blackducksoftware.
the class ExternalAlertRequestUtility method createRequestBuilder.
public Request.Builder createRequestBuilder(String path) throws IntegrationException {
Request.Builder requestBuilder = new Request.Builder();
requestBuilder.url(new HttpUrl(alertURL + path));
return requestBuilder;
}
use of com.synopsys.integration.rest.HttpUrl in project hub-alert by blackducksoftware.
the class BlackDuckProviderDataAccessor method getEmailAddressesForProjectHref.
@Override
public Set<String> getEmailAddressesForProjectHref(Long providerConfigId, String projectHref) {
Optional<ConfigurationModel> providerConfigOptional = configurationModelConfigurationAccessor.getConfigurationById(providerConfigId);
if (providerConfigOptional.isPresent()) {
try {
BlackDuckServicesFactory blackDuckServicesFactory = createBlackDuckServicesFactory(providerConfigOptional.get());
BlackDuckApiClient blackDuckService = blackDuckServicesFactory.getBlackDuckApiClient();
ProjectView projectView = blackDuckService.getResponse(new HttpUrl(projectHref), ProjectView.class);
return getEmailAddressesForProject(projectView, blackDuckServicesFactory.createProjectUsersService());
} catch (IntegrationException e) {
logger.errorAndDebug(createProjectNotFoundString(providerConfigId, e.getMessage()), e);
}
}
return Set.of();
}
Aggregations