当前位置: 首页>>代码示例>>Java>>正文


Java PagedIterable类代码示例

本文整理汇总了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);
}
 
开发者ID:SonarSource,项目名称:sonar-github,代码行数:17,代码来源:PullRequestFacadeTest.java

示例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;
}
 
开发者ID:hazelcast,项目名称:hazelcast-qa,代码行数:27,代码来源:CodeCoverageReaderTest.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:GitHubDTOFactory.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:GitHubDTOFactory.java

示例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());
	}
}
 
开发者ID:appbank2020,项目名称:GitRobot,代码行数:31,代码来源:GitRobot.java

示例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();
}
 
开发者ID:chriskearney,项目名称:creeper,代码行数:21,代码来源:RecentChangesManager.java

示例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);
}
 
开发者ID:groupon,项目名称:DotCi,代码行数:26,代码来源:CommitHistoryViewTest.java

示例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);
}
 
开发者ID:payne,项目名称:github_cleaner,代码行数:17,代码来源:MainCleanup.java

示例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++;
		}
	}
}
 
开发者ID:uw-loci,项目名称:github-backup-java,代码行数:28,代码来源:GitHubBackup.java

示例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();
}
 
开发者ID:SonarSource,项目名称:sonar-github,代码行数:12,代码来源:PullRequestFacadeTest.java

示例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);
}
 
开发者ID:hazelcast,项目名称:hazelcast-qa,代码行数:13,代码来源:CodeCoverageReaderTest.java

示例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);
}
 
开发者ID:GerritCodeReview,项目名称:plugins_github,代码行数:12,代码来源:RepositoriesListController.java

示例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);
}
 
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:9,代码来源:GhprcRepositoryTest.java

示例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);
}
 
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:10,代码来源:GhprcTestUtil.java


注:本文中的org.kohsuke.github.PagedIterable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。