本文整理汇总了Java中org.kohsuke.github.PagedIterable类的典型用法代码示例。如果您正苦于以下问题:Java PagedIterable类的具体用法?Java PagedIterable怎么用?Java PagedIterable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PagedIterable类属于org.kohsuke.github包,在下文中一共展示了PagedIterable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetCommitStatusForContextWithOneCorrectStatus
import org.kohsuke.github.PagedIterable; //导入依赖的package包/类
@Test
public void testGetCommitStatusForContextWithOneCorrectStatus() throws IOException {
PullRequestFacade facade = new PullRequestFacade(mock(GitHubPluginConfiguration.class));
GHRepository ghRepo = mock(GHRepository.class);
PagedIterable<GHCommitStatus> ghCommitStatuses = Mockito.mock(PagedIterable.class);
List<GHCommitStatus> ghCommitStatusesList = new ArrayList<>();
GHCommitStatus ghCommitStatusGHPRHContext = Mockito.mock(GHCommitStatus.class);
ghCommitStatusesList.add(ghCommitStatusGHPRHContext);
GHPullRequest pr = mock(GHPullRequest.class, withSettings().defaultAnswer(RETURNS_DEEP_STUBS));
when(pr.getRepository()).thenReturn(ghRepo);
when(pr.getHead().getSha()).thenReturn("abc123");
when(ghRepo.listCommitStatuses(pr.getHead().getSha())).thenReturn(ghCommitStatuses);
when(ghCommitStatuses.asList()).thenReturn(ghCommitStatusesList);
when(ghCommitStatusGHPRHContext.getContext()).thenReturn(PullRequestFacade.COMMIT_CONTEXT);
assertThat(facade.getCommitStatusForContext(pr, PullRequestFacade.COMMIT_CONTEXT).getContext()).isEqualTo(PullRequestFacade.COMMIT_CONTEXT);
}
示例2: mockPagedIterable
import org.kohsuke.github.PagedIterable; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static <T> PagedIterable<T> mockPagedIterable(T... values) {
PagedIterator<T> mockIterator = mock(PagedIterator.class);
PagedIterable<T> iterable = mock(PagedIterable.class);
when(iterable.iterator()).thenReturn(mockIterator);
if (values.length == 0) {
when(mockIterator.hasNext()).thenReturn(false);
} else if (values.length == 1) {
when(mockIterator.hasNext()).thenReturn(true, false);
when(mockIterator.next()).thenReturn(values[0]);
} else {
// build boolean array for hasNext()
Boolean[] hasNextResponses = new Boolean[values.length];
for (int i = 0; i < hasNextResponses.length - 1; i++) {
hasNextResponses[i] = true;
}
hasNextResponses[hasNextResponses.length - 1] = false;
when(mockIterator.hasNext()).thenReturn(true, hasNextResponses);
T[] valuesMinusTheFirst = Arrays.copyOfRange(values, 1, values.length);
when(mockIterator.next()).thenReturn(values[0], valuesMinusTheFirst);
}
return iterable;
}
示例3: createRepositoriesList
import org.kohsuke.github.PagedIterable; //导入依赖的package包/类
/**
* Create DTO object of GitHub repositories collection from given repositories list
*
* @param ghRepositoriesList collection of repositories from kohsuke GitHub library
* @return DTO object
* @throws IOException
*/
public GitHubRepositoryList createRepositoriesList(PagedIterable<GHRepository> ghRepositoriesList)
throws ApiException, IOException {
GitHubRepositoryList dtoRepositoriesList =
DtoFactory.getInstance().createDto(GitHubRepositoryList.class);
List<GitHubRepository> dtoRepositories = new ArrayList<>();
for (GHRepository ghRepository : ghRepositoriesList) {
dtoRepositories.add(createRepository(ghRepository));
}
dtoRepositoriesList.setRepositories(dtoRepositories);
return dtoRepositoriesList;
}
示例4: createPullRequestsList
import org.kohsuke.github.PagedIterable; //导入依赖的package包/类
/**
* Create DTO object of GitHub pull-requests collection from given pull-requests
*
* @param ghPullRequestsList collection of pull-requests from kohsuke GitHub library
* @return DTO object
* @throws IOException
*/
public GitHubPullRequestList createPullRequestsList(
PagedIterable<GHPullRequest> ghPullRequestsList) throws IOException {
GitHubPullRequestList gitHubPullRequestList =
DtoFactory.getInstance().createDto(GitHubPullRequestList.class);
List<GitHubPullRequest> dtoPullRequestsList = new ArrayList<>();
for (GHPullRequest ghPullRequest : ghPullRequestsList) {
dtoPullRequestsList.add(createPullRequest(ghPullRequest));
}
gitHubPullRequestList.setPullRequests(dtoPullRequestsList);
return gitHubPullRequestList;
}
示例5: getRepoDirectory
import org.kohsuke.github.PagedIterable; //导入依赖的package包/类
/**
* �ݹ麯��. ����github����ijһ��Ŀ¼��������Դ������·��
* @param content github����ijһ��Ŀ¼����
* @param strPath ����·��
* @return void
*/
private void getRepoDirectory(GHContent content, String strRemotePath, String strLocalPath){
try {
PagedIterable<GHContent> pi = content.listDirectoryContent();
Iterator<GHContent> it = pi.iterator();
while(it.hasNext()){
GHContent content1 = it.next();
if(content1.isDirectory())
getRepoDirectory(content1, strRemotePath, strLocalPath);
else{
int nPathStartPos = strRemotePath.length()==0 || strRemotePath.charAt(strRemotePath.length()-1)=='/' ? strRemotePath.length() : strRemotePath.length()+1;
String strFileName = strLocalPath + content1.getPath().substring(nPathStartPos);
if(content1.getDownloadUrl() != null && content1.getSize() < 1024 * 1024){
writeFile(content1.read(), strFileName);
}
else if(content1.getGitUrl() != null){
writeFileFromGitUrl(content1.getGitUrl(), strFileName);
}
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
errHandle(e.getMessage());
}
}
示例6: setupConditions
import org.kohsuke.github.PagedIterable; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void setupConditions(String triggerLogin, String committerName) throws IOException {
given(triggerSender.getLogin()).willReturn(triggerLogin);
given(triggerSender.getName()).willReturn(committerName);
given(committer.getName()).willReturn(this.committerName);
PagedIterator<GHPullRequestCommitDetail> itr = Mockito.mock(PagedIterator.class);
PagedIterable<GHPullRequestCommitDetail> pagedItr = Mockito.mock(PagedIterable.class);
Commit commit = mock(Commit.class);
GHPullRequestCommitDetail commitDetail = mock(GHPullRequestCommitDetail.class);
given(pr.listCommits()).willReturn(pagedItr);
given(pagedItr.iterator()).willReturn(itr);
given(itr.hasNext()).willReturn(true, false);
given(itr.next()).willReturn(commitDetail);
given(commitDetail.getCommit()).willReturn(commit);
given(commit.getCommitter()).willReturn(committer);
}
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:23,代码来源:GhprcPullRequestMergeTest.java
示例7: _getRecentChanges
import org.kohsuke.github.PagedIterable; //导入依赖的package包/类
private static String _getRecentChanges() {
StringBuilder sb = new StringBuilder();
try {
GitHub github = GitHub.connectAnonymously();
GHRepository repo = github.getRepository("chriskearney/creeper");
PagedIterable<GHCommit> list = repo.queryCommits().list();
int i = 1;
for (GHCommit ghCommit : list.asList()) {
if (i < 10) {
sb.append("Change #" + i + " | " + ghCommit.getCommitShortInfo().getMessage() + "\r\n");
} else {
continue;
}
i++;
}
} catch (IOException e) {
SentryManager.logSentry(RecentChangesManager.class, e, "Recent changes problem!");
}
return sb.toString();
}
示例8: should_group_commit_statueses_by_context
import org.kohsuke.github.PagedIterable; //导入依赖的package包/类
@Test
public void should_group_commit_statueses_by_context() throws IOException {
final CommitHistoryView commitHistoryView = new CommitHistoryView();
final DynamicBuild build = mock(DynamicBuild.class);
final GHRepository githubRepo = mock(GHRepository.class);
when(build.getGithubRepository()).thenReturn(githubRepo);
final PagedIterable<GHCommitStatus> commitStatusesList = mock(PagedIterable.class);
final GHCommitStatus commitStatus1 = mock(GHCommitStatus.class);
final GHCommitStatus commitStatus2 = mock(GHCommitStatus.class);
when(commitStatus1.getContext()).thenReturn("Default");
when(commitStatus2.getContext()).thenReturn("DotCi");
when(commitStatusesList.asList()).thenReturn(Arrays.asList(commitStatus1, commitStatus2));
final GHCommit currentCommit = mock(GHCommit.class);
when(githubRepo.getCommit(null)).thenReturn(currentCommit);
when(currentCommit.listStatuses()).thenReturn(commitStatusesList);
when(githubRepo.getLastCommitStatus(null)).thenReturn(commitStatus1);
commitHistoryView.onLoad(build);
final Map<String, List<GHCommitStatus>> commitStatuses = commitHistoryView.getCommitStatuses();
Assert.assertEquals(commitStatuses.get("Default").get(0), commitStatus1);
Assert.assertEquals(commitStatuses.get("DotCi").get(0), commitStatus2);
}
示例9: deleteRepos
import org.kohsuke.github.PagedIterable; //导入依赖的package包/类
private void deleteRepos(List<String> lstReposToDelete) throws IOException {
GitHub github = GitHub.connect();
GHMyself me = github.getMyself();
PagedIterable<GHRepository> lstRepos = me.listRepositories();
int cntDeleted = 0;
for (GHRepository repo : lstRepos) {
String name = repo.getName();
if (lstReposToDelete.contains(name)) {
repo.delete();
cntDeleted++;
System.out.format("Deleted: %s\n", name);
}
}
System.out.format("That's %d repositories deleted!\n",
cntDeleted);
}
示例10: backupMilestones
import org.kohsuke.github.PagedIterable; //导入依赖的package包/类
/**
* Backs up all milestone information to the given directory, one file per
* milestone.
*
* @param git - local git repository
* @param milestones - a list of GitHub milestones
* @param baseDir - base directory to write milestones
*/
private void backupMilestones(Git git, PagedIterable<GHMilestone> milestones,
String baseDir)
{
// Milestones don't have their own ids so we just number them in the order
// they come back, to avoid potential clashes with odd title characters
int i = 0;
if (checkPoint(git, ResumePoint.milestones(), 2)) {
for (GHMilestone milestone : milestones) {
String milestonePath = getFilePath(baseDir, i);
BufferedWriter writer = getWriter(milestonePath);
// Write milestone info out
writeLine(writer, "title: " + milestone.getTitle());
writeLine(writer, "description: " + milestone.getDescription());
writeLine(writer, "state: " + milestone.getState().toString());
cleanUp(milestonePath, git, writer);
i++;
}
}
}
示例11: testEmptyGetCommitStatusForContext
import org.kohsuke.github.PagedIterable; //导入依赖的package包/类
@Test
public void testEmptyGetCommitStatusForContext() throws IOException {
PullRequestFacade facade = new PullRequestFacade(mock(GitHubPluginConfiguration.class));
GHRepository ghRepo = mock(GHRepository.class);
PagedIterable<GHCommitStatus> ghCommitStatuses = Mockito.mock(PagedIterable.class);
GHPullRequest pr = mock(GHPullRequest.class, withSettings().defaultAnswer(RETURNS_DEEP_STUBS));
when(pr.getRepository()).thenReturn(ghRepo);
when(pr.getHead().getSha()).thenReturn("abc123");
when(ghRepo.listCommitStatuses(pr.getHead().getSha())).thenReturn(ghCommitStatuses);
assertThat(facade.getCommitStatusForContext(pr, PullRequestFacade.COMMIT_CONTEXT)).isNull();
}
示例12: addPullRequest
import org.kohsuke.github.PagedIterable; //导入依赖的package包/类
private void addPullRequest(GHPullRequestFileDetail... pullRequestFiles) throws IOException {
int pullRequestId = ++pullRequestIdGenerator;
pullRequests.add(pullRequestId);
PagedIterable<GHPullRequestFileDetail> iterable = mockPagedIterable(pullRequestFiles);
GHPullRequest pullRequest = mock(GHPullRequest.class);
when(pullRequest.isMerged()).thenReturn(true);
when(pullRequest.listFiles()).thenReturn(iterable);
when(repo.getPullRequest(pullRequestId)).thenReturn(pullRequest);
}
示例13: getRepositories
import org.kohsuke.github.PagedIterable; //导入依赖的package包/类
private PagedIterable<GHRepository> getRepositories(GitHubLogin hubLogin, String organisation)
throws IOException {
if (organisation.equals(hubLogin.getMyself().getLogin())) {
return hubLogin
.getMyself()
.listRepositories(config.repositoryListPageSize, RepositoryListFilter.OWNER);
}
GHOrganization ghOrganisation =
hubLogin.getMyself().getAllOrganizations().byLogin(organisation);
return ghOrganisation.listRepositories(config.repositoryListPageSize);
}
示例14: mockCommitList
import org.kohsuke.github.PagedIterable; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
private void mockCommitList() {
PagedIterator itr = Mockito.mock(PagedIterator.class);
PagedIterable pagedItr = Mockito.mock(PagedIterable.class);
Mockito.when(ghPullRequest.listCommits()).thenReturn(pagedItr);
Mockito.when(pagedItr.iterator()).thenReturn(itr);
Mockito.when(itr.hasNext()).thenReturn(false);
}
示例15: mockCommitList
import org.kohsuke.github.PagedIterable; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void mockCommitList(GHPullRequest ghPullRequest) {
PagedIterator itr = Mockito.mock(PagedIterator.class);
PagedIterable pagedItr = Mockito.mock(PagedIterable.class);
Mockito.when(ghPullRequest.listCommits()).thenReturn(pagedItr);
Mockito.when(pagedItr.iterator()).thenReturn(itr);
Mockito.when(itr.hasNext()).thenReturn(false);
}