本文整理汇总了Java中com.atlassian.stash.util.PageRequest类的典型用法代码示例。如果您正苦于以下问题:Java PageRequest类的具体用法?Java PageRequest怎么用?Java PageRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PageRequest类属于com.atlassian.stash.util包,在下文中一共展示了PageRequest类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBranchMap
import com.atlassian.stash.util.PageRequest; //导入依赖的package包/类
@Override
public ImmutableMap<String, Branch> getBranchMap(Repository repository) {
PageRequest req = new PageRequestImpl(0, PAGE_SIZE);
Map<String, Branch> branchMap = new HashMap<String, Branch>();
RepositoryBranchesRequest rbr =
new RepositoryBranchesRequest.Builder().repository(repository).order(RefOrder.ALPHABETICAL).build();
while (true) {
Page<? extends Branch> branchPage = repositoryMetadataService.getBranches(rbr, req);
for (Branch b : branchPage.getValues()) {
if (branchMap.containsKey(b)) {
log.error("Tryting to insert existing key '" + b.getId() + "' into branchMap with value '" + b
+ "'");
continue;
}
branchMap.put(b.getId(), b);
}
if (branchPage.getIsLastPage()) {
break;
}
req = branchPage.getNextPageRequest();
}
return ImmutableMap.copyOf(branchMap);
}
示例2: getDetailedChangesets
import com.atlassian.stash.util.PageRequest; //导入依赖的package包/类
private Page<DetailedChangeset> getDetailedChangesets(Repository repository, Page<Changeset> changeSets) {
Page<String> changeSetIds = changeSets.transform(CHANGESET_TO_ID);
DetailedChangesetsRequest detailedChangesetsRequest = new DetailedChangesetsRequest.Builder(repository)
.changesetIds(changeSetIds.getValues())
.maxChangesPerCommit(PageRequest.MAX_PAGE_LIMIT)
.build();
return commitService.getDetailedChangesets(detailedChangesetsRequest, PAGE_REQUEST);
}
示例3: setUp
import com.atlassian.stash.util.PageRequest; //导入依赖的package包/类
@Before
public void setUp() {
initMocks(this);
// Mock some stuff
when(user.getName()).thenReturn("user");
when(stashAuthenticationContext.getCurrentUser()).thenReturn(user);
when(settingsFactoryService.getFilterType((Settings) anyObject())).thenReturn(FilterType.ALL);
Changeset changeSet = mock(Changeset.class);
when(changeSet.getId()).thenReturn("CHANGESET-ID");
Page<Changeset> changeSets = new PageImpl<>(ProtectPathsChangesetServiceImpl.PAGE_REQUEST,
1, asList(changeSet), true);
when(commitService.getChangesetsBetween((ChangesetsBetweenRequest) anyObject(),
(PageRequest) anyObject())).thenReturn(changeSets);
DetailedChangeset detailedChangeset = mock(DetailedChangeset.class);
Page<DetailedChangeset> detailedChangesets = new PageImpl<>(
ProtectPathsRepositoryHook.PAGE_REQUEST, 1, asList(detailedChangeset), true);
when(commitService.getDetailedChangesets((DetailedChangesetsRequest) anyObject(),
(PageRequest) anyObject())).thenReturn(detailedChangesets);
when(change.getPath()).thenReturn(new SimplePath("x/y/z"));
Page<Change> changes = new PageImpl<>(ProtectPathsRepositoryHook.PAGE_REQUEST, 1, asList(change), true);
when((Page<Change>) detailedChangeset.getChanges()).thenReturn(changes);
fromHash = "FROM-HASH";
toHash = "TO-HASH";
refId = "refs/heads/master";
protectPathsChangesetService = new ProtectPathsChangesetServiceImpl(
commitService, permissionService, stashAuthenticationContext, settingsFactoryService);
}
开发者ID:sgillespie,项目名称:protect-paths-stash-hook,代码行数:33,代码来源:ProtectPathsChangesetServiceImplTest.java
示例4: getRepositoryMap
import com.atlassian.stash.util.PageRequest; //导入依赖的package包/类
@Override
public ImmutableMap<String, Repository> getRepositoryMap(
PermissionValidationService validationService) {
PageRequest req = new PageRequestImpl(0, PAGE_SIZE);
Map<String, Repository> repoMap = new HashMap<String, Repository>();
while (true) {
Page<? extends Repository> repoPage = repositoryService.findAll(req);
for (Repository r : repoPage.getValues()) {
try {
if (validationService != null) {
validationService.validateForRepository(r, Permission.REPO_READ);
}
final String key = r.getProject().getKey() + "^" + r.getSlug();
if (repoMap.containsKey(key)) {
// ITOOLS-13350
log.error("Trying to insert existing key '" + key + "' intp repoMap with value " + r.toString());
continue;
}
repoMap.put(key, r);
} catch (AuthorisationException e) {
// User doesn't have permission to access the repo
}
}
if (repoPage.getIsLastPage()) {
break;
}
req = repoPage.getNextPageRequest();
}
return ImmutableMap.copyOf(repoMap);
}
示例5: setUp
import com.atlassian.stash.util.PageRequest; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
Mockito.when(res.getWriter()).thenReturn(writer);
Mockito.when(req.getPathInfo()).thenReturn("/projectName/repoName");
Mockito.when(repositoryService.getBySlug("projectName", "repoName")).thenReturn(mockRepo);
Mockito.when(cpm.getRepositoryConfigurationForRepository(mockRepo)).thenReturn(rc);
Mockito.when(cpm.getAllJenkinsServerNames()).thenReturn(ImmutableList.of(JSN, JSN + "2"));
Mockito.when(rc.getCiEnabled()).thenReturn(true);
Mockito.when(rc.getPublishBranchRegex()).thenReturn(PBR);
Mockito.when(rc.getPublishBuildCommand()).thenReturn(PBC);
Mockito.when(rc.getVerifyBranchRegex()).thenReturn(VBR);
Mockito.when(rc.getVerifyBuildCommand()).thenReturn(VBC);
Mockito.when(rc.getPrebuildCommand()).thenReturn(PREBC);
Mockito.when(rc.getJenkinsServerName()).thenReturn(JSN);
Mockito.when(rc.getRebuildOnTargetUpdate()).thenReturn(RB);
Mockito.when(rc.getVerifyPinned()).thenReturn(false);
Mockito.when(rc.getVerifyLabel()).thenReturn("N/A");
Mockito.when(rc.getPublishPinned()).thenReturn(false);
Mockito.when(rc.getPublishLabel()).thenReturn("N/A");
Mockito.when(rc.getJunitEnabled()).thenReturn(false);
Mockito.when(rc.getJunitPath()).thenReturn("N/A");
Mockito.when(rc.getArtifactsEnabled()).thenReturn(false);
Mockito.when(rc.getArtifactsPath()).thenReturn("N/A");
Mockito.when(rc.getEmailNotificationsEnabled()).thenReturn(false);
Mockito.when(rc.getEmailRecipients()).thenReturn("[email protected]");
Mockito.when(rc.getEmailForEveryUnstableBuild()).thenReturn(false);
Mockito.when(rc.getEmailPerModuleEmail()).thenReturn(false);
Mockito.when(rc.getEmailSendToIndividuals()).thenReturn(false);
Mockito.when(rc2.getPublishBranchRegex()).thenReturn(PBR + "2");
Mockito.when(rc2.getPublishBuildCommand()).thenReturn(PBC + "2");
Mockito.when(rc2.getVerifyBranchRegex()).thenReturn(VBR + "2");
Mockito.when(rc2.getVerifyBuildCommand()).thenReturn(VBC + "2");
Mockito.when(rc2.getPrebuildCommand()).thenReturn(PREBC + "2");
Mockito.when(rc2.getJenkinsServerName()).thenReturn(JSN + "2");
Mockito.when(rc2.getRebuildOnTargetUpdate()).thenReturn(RB);
Mockito.when(rc2.getVerifyPinned()).thenReturn(false);
Mockito.when(rc2.getVerifyLabel()).thenReturn("N/A");
Mockito.when(rc2.getPublishPinned()).thenReturn(false);
Mockito.when(rc2.getPublishLabel()).thenReturn("N/A");
Mockito.when(rc2.getJunitEnabled()).thenReturn(false);
Mockito.when(rc2.getJunitPath()).thenReturn("N/A");
Mockito.when(rc2.getArtifactsEnabled()).thenReturn(false);
Mockito.when(rc2.getArtifactsPath()).thenReturn("N/A");
Mockito.when(rc2.getEmailNotificationsEnabled()).thenReturn(true);
Mockito.when(rc2.getEmailRecipients()).thenReturn("[email protected]");
Mockito.when(rc2.getEmailForEveryUnstableBuild()).thenReturn(true);
Mockito.when(rc2.getEmailPerModuleEmail()).thenReturn(true);
Mockito.when(rc2.getEmailSendToIndividuals()).thenReturn(true);
Mockito.when(jsc.getName()).thenReturn(JSN);
Mockito.when(jsc.getStashUsername()).thenReturn("someuser");
Mockito.when(jsc2.getName()).thenReturn(JSN + "2");
Mockito.when(jsc2.getStashUsername()).thenReturn("someuser");
allServers = ImmutableList.of(jsc, jsc2);
when(cpm.getAllJenkinsServerConfigurations()).thenReturn(allServers);
when(cpm.getJenkinsServerConfiguration(JSN)).thenReturn(jsc);
when(cpm.getJenkinsServerConfiguration(JSN + "2")).thenReturn(jsc2);
when(pageBuilderService.assembler()).thenReturn(webResourceAssembler);
when(webResourceAssembler.resources()).thenReturn(rr);
Mockito.when(prs.search(Mockito.any(PullRequestSearchRequest.class), Mockito.any(PageRequest.class)))
.thenReturn(page);
// empty list, no PRs, nothign to do. not testing this bit.
Mockito.when(page.getValues()).thenReturn(ImmutableList.of());
Mockito.when(page.getIsLastPage()).thenReturn(true);
rcs =
new RepoConfigurationServlet(repositoryService, prs, soyTemplateRenderer, pageBuilderService,
cpm, jenkinsManager, pum, pvs, lf);
}
示例6: setUp
import com.atlassian.stash.util.PageRequest; //导入依赖的package包/类
@Before
public void setUp() throws SQLException {
MockitoAnnotations.initMocks(this);
Mockito.when(repo.getId()).thenReturn(REPO_ID);
Mockito.when(cpm.getRepositoryConfigurationForRepository(repo)).thenReturn(rc);
Mockito.when(cpm.getJobTypeStatusMapping(rc, JobType.VERIFY_PR)).thenReturn(true);
Mockito.when(rc.getCiEnabled()).thenReturn(true);
Mockito.when(rc.getVerifyBranchRegex()).thenReturn(VERIFY_REGEX);
Mockito.when(rc.getRebuildOnTargetUpdate()).thenReturn(true);
Mockito.when(rc.getStrictVerifyMode()).thenReturn(false);
Mockito.when(mr.getPullRequest()).thenReturn(pr);
Mockito.when(pr.getId()).thenReturn(PULL_REQUEST_ID);
Mockito.when(pr.getFromRef()).thenReturn(fromRef);
Mockito.when(pr.getToRef()).thenReturn(toRef);
Mockito.when(fromRef.getRepository()).thenReturn(repo);
Mockito.when(fromRef.getLatestChangeset()).thenReturn(TO_SHA);
Mockito.when(toRef.getRepository()).thenReturn(repo);
Mockito.when(toRef.getId()).thenReturn(TO_SHA);
Mockito.when(toRef.getLatestChangeset()).thenReturn(TO_SHA);
Mockito.when(cpm.getPullRequestMetadata(pr)).thenReturn(prm);
Mockito.when(cpm.getPullRequestMetadataWithoutToRef(pr)).thenReturn(ImmutableList.of(prm, prm2));
// prm and prm2 have same from sha, but different to shas.
Mockito.when(prm.getToSha()).thenReturn(TO_SHA);
Mockito.when(prm.getFromSha()).thenReturn(FROM_SHA);
Mockito.when(prm2.getToSha()).thenReturn(TO_SHA2);
Mockito.when(prm2.getFromSha()).thenReturn(FROM_SHA);
changesets = ImmutableList.of(changeA, changeB);
Mockito.when(
cs.getChangesetsBetween(Mockito.any(ChangesetsBetweenRequest.class), Mockito.any(PageRequest.class)))
.thenReturn(mockPage);
Mockito.when(mockPage.getValues()).thenReturn(changesets);
Mockito.when(mockPage.getIsLastPage()).thenReturn(true);
Mockito.when(changeA.getId()).thenReturn(SHA_A);
Mockito.when(changeB.getId()).thenReturn(SHA_B);
Mockito.when(bss.getStats(SHA_A)).thenReturn(bsA);
Mockito.when(bss.getStats(SHA_B)).thenReturn(bsB);
Mockito.when(bsA.getSuccessfulCount()).thenReturn(1);
Mockito.when(bsB.getSuccessfulCount()).thenReturn(1);
prmc = new PullRequestBuildSuccessMergeCheck(cs, bss, cpm, lf);
}