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


Java PostReviewers类代码示例

本文整理汇总了Java中com.google.gerrit.server.change.PostReviewers的典型用法代码示例。如果您正苦于以下问题:Java PostReviewers类的具体用法?Java PostReviewers怎么用?Java PostReviewers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PostReviewers类属于com.google.gerrit.server.change包,在下文中一共展示了PostReviewers类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addReviewers

import com.google.gerrit.server.change.PostReviewers; //导入依赖的package包/类
/**
 * Append the reviewers to change#{@link Change}
 *
 * @param topReviewers Set of reviewers proposed
 * @param change {@link Change} to add the reviewers to
 */
private void addReviewers(Set<Account.Id> topReviewers, Change change) {
  try {
    ChangeControl changeControl =
        changeControlFactory.controlFor(change,
            identifiedUserFactory.create(change.getOwner()));
    ChangeResource changeResource = new ChangeResource(changeControl);
    PostReviewers post = reviewersProvider.get();
    for (Account.Id accountId : topReviewers) {
      PostReviewers.Input input = new PostReviewers.Input();
      input.reviewer = accountId.toString();
      post.apply(changeResource, input);
    }
  } catch (Exception ex) {
    log.error("Couldn't add reviewers to the change", ex);
  }
}
 
开发者ID:Intersec,项目名称:smart-reviewers,代码行数:23,代码来源:SmartReviewers.java

示例2: SmartReviewers

import com.google.gerrit.server.change.PostReviewers; //导入依赖的package包/类
@Inject
public SmartReviewers(final AccountByEmailCache byEmailCache,
    final AccountCache accountCache,
    final ChangeControl.GenericFactory changeControlFactory,
    final ChangesCollection changes,
    final Provider<PostReviewers> reviewersProvider,
    final IdentifiedUser.GenericFactory identifiedUserFactory,
    final PatchListCache patchListCache, final ProjectCache projectCache,
    @Assisted final RevCommit commit, @Assisted final Change change,
    @Assisted final PatchSet ps, @Assisted final int maxReviewers,
    @Assisted final int weightBlame, @Assisted final int weightLastReviews,
    @Assisted final int weightWorkload, @Assisted final Repository repo,
    @Assisted final ReviewDb reviewDb) {
  this.byEmailCache = byEmailCache;
  this.accountCache = accountCache;
  this.changeControlFactory = changeControlFactory;
  this.reviewersProvider = reviewersProvider;
  this.identifiedUserFactory = identifiedUserFactory;
  this.patchListCache = patchListCache;
  this.commit = commit;
  this.change = change;
  this.ps = ps;
  this.maxReviewers = maxReviewers;
  this.weightBlame = weightBlame;
  this.weightLastReviews = weightLastReviews;
  this.weightWorkload = weightWorkload;
  this.repo = repo;
  this.reviewDb = reviewDb;
}
 
开发者ID:Intersec,项目名称:smart-reviewers,代码行数:30,代码来源:SmartReviewers.java

示例3: ReviewProjectAccess

import com.google.gerrit.server.change.PostReviewers; //导入依赖的package包/类
@Inject
ReviewProjectAccess(
    PermissionBackend permissionBackend,
    GroupBackend groupBackend,
    MetaDataUpdate.User metaDataUpdateFactory,
    ReviewDb db,
    Provider<PostReviewers> reviewersProvider,
    ProjectCache projectCache,
    AllProjectsName allProjects,
    AllUsersName allUsers,
    ChangesCollection changes,
    ChangeInserter.Factory changeInserterFactory,
    BatchUpdate.Factory updateFactory,
    Provider<SetParent> setParent,
    Sequences seq,
    ContributorAgreementsChecker contributorAgreements,
    Provider<CurrentUser> user,
    @Assisted("projectName") Project.NameKey projectName,
    @Nullable @Assisted ObjectId base,
    @Assisted List<AccessSection> sectionList,
    @Nullable @Assisted("parentProjectName") Project.NameKey parentProjectName,
    @Nullable @Assisted String message) {
  super(
      groupBackend,
      metaDataUpdateFactory,
      allProjects,
      allUsers,
      setParent,
      user.get(),
      projectName,
      base,
      sectionList,
      parentProjectName,
      message,
      contributorAgreements,
      permissionBackend,
      false);
  this.db = db;
  this.permissionBackend = permissionBackend;
  this.seq = seq;
  this.reviewersProvider = reviewersProvider;
  this.projectCache = projectCache;
  this.changes = changes;
  this.changeInserterFactory = changeInserterFactory;
  this.updateFactory = updateFactory;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:47,代码来源:ReviewProjectAccess.java

示例4: suggestGroupAsReviewer

import com.google.gerrit.server.change.PostReviewers; //导入依赖的package包/类
private GroupAsReviewer suggestGroupAsReviewer(
    SuggestReviewers suggestReviewers,
    Project project,
    GroupReference group,
    VisibilityControl visibilityControl)
    throws OrmException, IOException {
  GroupAsReviewer result = new GroupAsReviewer();
  int maxAllowed = suggestReviewers.getMaxAllowed();
  int maxAllowedWithoutConfirmation = suggestReviewers.getMaxAllowedWithoutConfirmation();

  if (!PostReviewers.isLegalReviewerGroup(group.getUUID())) {
    return result;
  }

  try {
    Set<Account> members = groupMembers.listAccounts(group.getUUID(), project.getNameKey());

    if (members.isEmpty()) {
      return result;
    }

    result.size = members.size();
    if (maxAllowed > 0 && result.size > maxAllowed) {
      return result;
    }

    boolean needsConfirmation = result.size > maxAllowedWithoutConfirmation;

    // require that at least one member in the group can see the change
    for (Account account : members) {
      if (visibilityControl.isVisibleTo(account.getId())) {
        if (needsConfirmation) {
          result.allowedWithConfirmation = true;
        } else {
          result.allowed = true;
        }
        return result;
      }
    }
  } catch (NoSuchGroupException | NoSuchProjectException e) {
    return result;
  }

  return result;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:46,代码来源:ReviewersUtil.java

示例5: addGroupAsReviewer

import com.google.gerrit.server.change.PostReviewers; //导入依赖的package包/类
@Test
public void addGroupAsReviewer() throws Exception {
  // Set up two groups, one that is too large too add as reviewer, and one
  // that is too large to add without confirmation.
  String largeGroup = createGroup("largeGroup");
  String mediumGroup = createGroup("mediumGroup");

  int largeGroupSize = PostReviewers.DEFAULT_MAX_REVIEWERS + 1;
  int mediumGroupSize = PostReviewers.DEFAULT_MAX_REVIEWERS_WITHOUT_CHECK + 1;
  List<TestAccount> users = createAccounts(largeGroupSize, "addGroupAsReviewer");
  List<String> largeGroupUsernames = new ArrayList<>(mediumGroupSize);
  for (TestAccount u : users) {
    largeGroupUsernames.add(u.username);
  }
  List<String> mediumGroupUsernames = largeGroupUsernames.subList(0, mediumGroupSize);
  gApi.groups()
      .id(largeGroup)
      .addMembers(largeGroupUsernames.toArray(new String[largeGroupSize]));
  gApi.groups()
      .id(mediumGroup)
      .addMembers(mediumGroupUsernames.toArray(new String[mediumGroupSize]));

  // Attempt to add overly large group as reviewers.
  PushOneCommit.Result r = createChange();
  String changeId = r.getChangeId();
  AddReviewerResult result = addReviewer(changeId, largeGroup);
  assertThat(result.input).isEqualTo(largeGroup);
  assertThat(result.confirm).isNull();
  assertThat(result.error).contains("has too many members to add them all as reviewers");
  assertThat(result.reviewers).isNull();

  // Attempt to add medium group without confirmation.
  result = addReviewer(changeId, mediumGroup);
  assertThat(result.input).isEqualTo(mediumGroup);
  assertThat(result.confirm).isTrue();
  assertThat(result.error)
      .contains("has " + mediumGroupSize + " members. Do you want to add them all as reviewers?");
  assertThat(result.reviewers).isNull();

  // Add medium group with confirmation.
  AddReviewerInput in = new AddReviewerInput();
  in.reviewer = mediumGroup;
  in.confirmed = true;
  result = addReviewer(changeId, in);
  assertThat(result.input).isEqualTo(mediumGroup);
  assertThat(result.confirm).isNull();
  assertThat(result.error).isNull();
  assertThat(result.reviewers).hasSize(mediumGroupSize);

  // Verify that group members were added as reviewers.
  ChangeInfo c = gApi.changes().id(r.getChangeId()).get();
  assertReviewers(c, REVIEWER, users.subList(0, mediumGroupSize));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:54,代码来源:ChangeReviewersIT.java


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