use of com.google.api.services.source.model.ListReposResponse in project google-cloud-intellij by GoogleCloudPlatform.
the class RepositorySelectorTest method getPopulatedRepositoriesPanel.
private RepositorySelector getPopulatedRepositoriesPanel(boolean openPopup) {
ListReposResponse reposResponse = new ListReposResponse();
reposResponse.setRepos(createRepos());
when(repositoryService.listAsync(any(CredentialedUser.class), anyString())).thenReturn(CompletableFuture.completedFuture(reposResponse));
return getSelector(openPopup);
}
use of com.google.api.services.source.model.ListReposResponse in project google-cloud-intellij by GoogleCloudPlatform.
the class RepositorySelectorTest method getErrorRepositoryPanel.
private RepositorySelector getErrorRepositoryPanel() {
CompletableFuture<ListReposResponse> failedListing = CompletableFuture.supplyAsync(() -> {
throw new CloudRepositoryServiceException();
});
failedListing.completeExceptionally(new CloudRepositoryServiceException());
when(repositoryService.listAsync(any(CredentialedUser.class), anyString())).thenReturn(failedListing);
return getSelector(true);
}
use of com.google.api.services.source.model.ListReposResponse in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudRepositoryService method list.
@NotNull
public ListReposResponse list(CredentialedUser user, String cloudProject) throws CloudRepositoryServiceException {
try {
Credential credential = user.getCredential();
HttpRequestInitializer initializer = httpRequest -> {
HttpHeaders headers = new HttpHeaders();
httpRequest.setConnectTimeout(LIST_TIMEOUT_MS);
httpRequest.setReadTimeout(LIST_TIMEOUT_MS);
httpRequest.setHeaders(headers);
credential.initialize(httpRequest);
};
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
String userAgent = ServiceManager.getService(PluginInfoService.class).getUserAgent();
Source source = new Source.Builder(httpTransport, JacksonFactory.getDefaultInstance(), initializer).setRootUrl(CLOUD_SOURCE_API_ROOT_URL).setServicePath("").setApplicationName(userAgent).build();
return new CustomUrlSourceRequest(source, cloudProject).execute();
} catch (IOException | GeneralSecurityException ex) {
throw new CloudRepositoryServiceException();
}
}
Aggregations