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


Java PatchSetApproval类代码示例

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


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

示例1: fromApprovals

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入依赖的package包/类
public static ReviewerSet fromApprovals(Iterable<PatchSetApproval> approvals) {
  PatchSetApproval first = null;
  Table<ReviewerStateInternal, Account.Id, Timestamp> reviewers = HashBasedTable.create();
  for (PatchSetApproval psa : approvals) {
    if (first == null) {
      first = psa;
    } else {
      checkArgument(
          first
              .getKey()
              .getParentKey()
              .getParentKey()
              .equals(psa.getKey().getParentKey().getParentKey()),
          "multiple change IDs: %s, %s",
          first.getKey(),
          psa.getKey());
    }
    Account.Id id = psa.getAccountId();
    reviewers.put(REVIEWER, id, psa.getGranted());
    if (psa.getValue() != 0) {
      reviewers.remove(CC, id);
    }
  }
  return new ReviewerSet(reviewers);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:26,代码来源:ReviewerSet.java

示例2: putOtherUsersApprovals

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入依赖的package包/类
@Test
public void putOtherUsersApprovals() throws Exception {
  Change c = newChange();
  ChangeUpdate update = newUpdate(c, changeOwner);
  update.putApproval("Code-Review", (short) 1);
  update.putApprovalFor(otherUser.getAccountId(), "Code-Review", (short) -1);
  update.commit();

  ChangeNotes notes = newNotes(c);
  List<PatchSetApproval> approvals =
      ReviewDbUtil.intKeyOrdering()
          .onResultOf(PatchSetApproval::getAccountId)
          .sortedCopy(notes.getApprovals().get(c.currentPatchSetId()));
  assertThat(approvals).hasSize(2);

  assertThat(approvals.get(0).getAccountId()).isEqualTo(changeOwner.getAccountId());
  assertThat(approvals.get(0).getLabel()).isEqualTo("Code-Review");
  assertThat(approvals.get(0).getValue()).isEqualTo((short) 1);

  assertThat(approvals.get(1).getAccountId()).isEqualTo(otherUser.getAccountId());
  assertThat(approvals.get(1).getLabel()).isEqualTo("Code-Review");
  assertThat(approvals.get(1).getValue()).isEqualTo((short) -1);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:24,代码来源:ChangeNotesTest.java

示例3: renderMessageWithApprovals

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入依赖的package包/类
public static String renderMessageWithApprovals(
    int patchSetId, Map<String, Short> n, Map<String, PatchSetApproval> c) {
  StringBuilder msgs = new StringBuilder("Uploaded patch set " + patchSetId);
  if (!n.isEmpty()) {
    boolean first = true;
    for (Map.Entry<String, Short> e : n.entrySet()) {
      if (c.containsKey(e.getKey()) && c.get(e.getKey()).getValue() == e.getValue()) {
        continue;
      }
      if (first) {
        msgs.append(":");
        first = false;
      }
      msgs.append(" ").append(LabelVote.create(e.getKey(), e.getValue()).format());
    }
  }
  return msgs.toString();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:19,代码来源:ApprovalsUtil.java

示例4: buildApprovals

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入依赖的package包/类
private ListMultimap<PatchSet.Id, PatchSetApproval> buildApprovals() {
  ListMultimap<PatchSet.Id, PatchSetApproval> result =
      MultimapBuilder.hashKeys().arrayListValues().build();
  for (PatchSetApproval a : approvals.values()) {
    if (!patchSets.containsKey(a.getPatchSetId())) {
      continue; // Patch set deleted or missing.
    } else if (allPastReviewers.contains(a.getAccountId())
        && !reviewers.containsRow(a.getAccountId())) {
      continue; // Reviewer was explicitly removed.
    }
    result.put(a.getPatchSetId(), a);
  }
  for (Collection<PatchSetApproval> v : result.asMap().values()) {
    Collections.sort((List<PatchSetApproval>) v, ChangeNotes.PSA_BY_TIME);
  }
  return result;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:ChangeNotesParser.java

示例5: parseStatus

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入依赖的package包/类
private Change.Status parseStatus(ChangeNotesCommit commit) throws ConfigInvalidException {
  List<String> statusLines = commit.getFooterLineValues(FOOTER_STATUS);
  if (statusLines.isEmpty()) {
    return null;
  } else if (statusLines.size() > 1) {
    throw expectedOneFooter(FOOTER_STATUS, statusLines);
  }
  Change.Status status =
      Enums.getIfPresent(Change.Status.class, statusLines.get(0).toUpperCase()).orNull();
  if (status == null) {
    throw invalidFooter(FOOTER_STATUS, statusLines.get(0));
  }
  // All approvals after MERGED and before the next status change get the postSubmit
  // bit. (Currently the state can't change from MERGED to something else, but just in case.) The
  // exception is the legacy SUBM approval, which is never considered post-submit, but might end
  // up sorted after the submit during rebuilding.
  if (status == Change.Status.MERGED) {
    for (PatchSetApproval psa : bufferedApprovals) {
      if (!psa.isLegacySubmit()) {
        psa.setPostSubmit(true);
      }
    }
  }
  bufferedApprovals.clear();
  return status;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:ChangeNotesParser.java

示例6: patchSetApprovalMap

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入依赖的package包/类
private static Map<PatchSetApproval.Key, PatchSetApproval> patchSetApprovalMap(
    Iterable<PatchSetApproval> in) {
  Map<PatchSetApproval.Key, PatchSetApproval> out =
      new TreeMap<>(
          new Comparator<PatchSetApproval.Key>() {
            @Override
            public int compare(PatchSetApproval.Key a, PatchSetApproval.Key b) {
              return patchSetIdChain(a.getParentKey(), b.getParentKey())
                  .compare(a.getAccountId().get(), b.getAccountId().get())
                  .compare(a.getLabelId(), b.getLabelId())
                  .result();
            }
          });
  for (PatchSetApproval psa : in) {
    out.put(psa.getKey(), psa);
  }
  return out;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:19,代码来源:ChangeBundle.java

示例7: getLatestTimestamp

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入依赖的package包/类
private Timestamp getLatestTimestamp() {
  Ordering<Timestamp> o = Ordering.natural().nullsFirst();
  Timestamp ts = null;
  for (ChangeMessage cm : filterChangeMessages()) {
    ts = o.max(ts, cm.getWrittenOn());
  }
  for (PatchSet ps : getPatchSets()) {
    ts = o.max(ts, ps.getCreatedOn());
  }
  for (PatchSetApproval psa : filterPatchSetApprovals().values()) {
    ts = o.max(ts, psa.getGranted());
  }
  for (PatchLineComment plc : filterPatchLineComments().values()) {
    // Ignore draft comments, as they do not show up in the change meta graph.
    if (plc.getStatus() != PatchLineComment.Status.DRAFT) {
      ts = o.max(ts, plc.getWrittenOn());
    }
  }
  return firstNonNull(ts, change.getLastUpdatedOn());
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:21,代码来源:ChangeBundle.java

示例8: addReviewers

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入依赖的package包/类
public List<PatchSetApproval> addReviewers(
    ReviewDb db,
    ChangeUpdate update,
    LabelTypes labelTypes,
    Change change,
    PatchSet ps,
    PatchSetInfo info,
    Iterable<Account.Id> wantReviewers,
    Collection<Account.Id> existingReviewers)
    throws OrmException {
  return addReviewers(
      db,
      update,
      labelTypes,
      change,
      ps.getId(),
      info.getAuthor().getAccount(),
      info.getCommitter().getAccount(),
      wantReviewers,
      existingReviewers);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:22,代码来源:ApprovalsUtil.java

示例9: approvalsOnePatchSet

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入依赖的package包/类
@Test
public void approvalsOnePatchSet() throws Exception {
  Change c = newChange();
  ChangeUpdate update = newUpdate(c, changeOwner);
  update.putApproval("Verified", (short) 1);
  update.putApproval("Code-Review", (short) -1);
  update.commit();

  ChangeNotes notes = newNotes(c);
  assertThat(notes.getApprovals().keySet()).containsExactly(c.currentPatchSetId());
  List<PatchSetApproval> psas = notes.getApprovals().get(c.currentPatchSetId());
  assertThat(psas).hasSize(2);

  assertThat(psas.get(0).getPatchSetId()).isEqualTo(c.currentPatchSetId());
  assertThat(psas.get(0).getAccountId().get()).isEqualTo(1);
  assertThat(psas.get(0).getLabel()).isEqualTo("Code-Review");
  assertThat(psas.get(0).getValue()).isEqualTo((short) -1);
  assertThat(psas.get(0).getGranted()).isEqualTo(truncate(after(c, 2000)));

  assertThat(psas.get(1).getPatchSetId()).isEqualTo(c.currentPatchSetId());
  assertThat(psas.get(1).getAccountId().get()).isEqualTo(1);
  assertThat(psas.get(1).getLabel()).isEqualTo("Verified");
  assertThat(psas.get(1).getValue()).isEqualTo((short) 1);
  assertThat(psas.get(1).getGranted()).isEqualTo(psas.get(0).getGranted());
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:26,代码来源:ChangeNotesTest.java

示例10: submitOnBehalfOf

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入依赖的package包/类
@Test
public void submitOnBehalfOf() throws Exception {
  allowSubmitOnBehalfOf();
  PushOneCommit.Result r = createChange();
  String changeId = project.get() + "~master~" + r.getChangeId();
  gApi.changes().id(changeId).current().review(ReviewInput.approve());
  SubmitInput in = new SubmitInput();
  in.onBehalfOf = admin2.email;
  gApi.changes().id(changeId).current().submit(in);

  ChangeData cd = r.getChange();
  assertThat(cd.change().getStatus()).isEqualTo(Change.Status.MERGED);
  PatchSetApproval submitter =
      approvalsUtil.getSubmitter(db, cd.notes(), cd.change().currentPatchSetId());
  assertThat(submitter.getAccountId()).isEqualTo(admin2.id);
  assertThat(submitter.getRealAccountId()).isEqualTo(admin.id);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:ImpersonationIT.java

示例11: addReviewerWithNoteDbWhenDummyApprovalInReviewDbExists

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入依赖的package包/类
@Test
public void addReviewerWithNoteDbWhenDummyApprovalInReviewDbExists() throws Exception {
  assume().that(notesMigration.readChanges()).isTrue();
  assume().that(notesMigration.changePrimaryStorage()).isEqualTo(PrimaryStorage.REVIEW_DB);

  PushOneCommit.Result r = createChange();

  // insert dummy approval in ReviewDb
  PatchSetApproval psa =
      new PatchSetApproval(
          new PatchSetApproval.Key(r.getPatchSetId(), user.id, new LabelId("Code-Review")),
          (short) 0,
          TimeUtil.nowTs());
  db.patchSetApprovals().insert(Collections.singleton(psa));

  AddReviewerInput in = new AddReviewerInput();
  in.reviewer = user.email;
  gApi.changes().id(r.getChangeId()).addReviewer(in);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:ChangeIT.java

示例12: currentLabels

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入依赖的package包/类
private Map<String, Short> currentLabels(PermissionBackend.ForChange perm, ChangeData cd)
    throws OrmException {
  IdentifiedUser user = perm.user().asIdentifiedUser();
  Map<String, Short> result = new HashMap<>();
  for (PatchSetApproval psa :
      approvalsUtil.byPatchSetUser(
          db.get(),
          lazyLoad ? cd.notes() : notesFactory.createFromIndexedChange(cd.change()),
          user,
          cd.change().currentPatchSetId(),
          user.getAccountId(),
          null,
          null)) {
    result.put(psa.getLabel(), psa.getValue());
  }
  return result;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:ChangeJson.java

示例13: apply

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入依赖的package包/类
@Override
public Map<String, Short> apply(ReviewerResource rsrc)
    throws OrmException, MethodNotAllowedException {
  if (rsrc.getRevisionResource() != null && !rsrc.getRevisionResource().isCurrent()) {
    throw new MethodNotAllowedException("Cannot list votes on non-current patch set");
  }

  Map<String, Short> votes = new TreeMap<>();
  Iterable<PatchSetApproval> byPatchSetUser =
      approvalsUtil.byPatchSetUser(
          db.get(),
          rsrc.getChangeResource().getNotes(),
          rsrc.getChangeResource().getUser(),
          rsrc.getChange().currentPatchSetId(),
          rsrc.getReviewerUser().getAccountId(),
          null,
          null);
  for (PatchSetApproval psa : byPatchSetUser) {
    votes.put(psa.getLabel(), psa.getValue());
  }
  return votes;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:23,代码来源:Votes.java

示例14: runAsWithOnBehalfOf

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入依赖的package包/类
@Test
public void runAsWithOnBehalfOf() throws Exception {
  // - Has the same restrictions as on_behalf_of (e.g. requires labels).
  // - Takes the effective user from on_behalf_of (user).
  // - Takes the real user from the real caller, not the intermediate
  //   X-Gerrit-RunAs user (user2).
  allowRunAs();
  allowCodeReviewOnBehalfOf();
  TestAccount user2 = accountCreator.user2();

  PushOneCommit.Result r = createChange();
  ReviewInput in = new ReviewInput();
  in.onBehalfOf = user.id.toString();
  in.message = "Message on behalf of";

  String endpoint = "/changes/" + r.getChangeId() + "/revisions/current/review";
  RestResponse res = adminRestSession.postWithHeader(endpoint, in, runAsHeader(user2.id));
  res.assertForbidden();
  assertThat(res.getEntityContent())
      .isEqualTo("label required to post review on behalf of \"" + in.onBehalfOf + '"');

  in.label("Code-Review", 1);
  adminRestSession.postWithHeader(endpoint, in, runAsHeader(user2.id)).assertOK();

  PatchSetApproval psa = Iterables.getOnlyElement(r.getChange().approvals().values());
  assertThat(psa.getPatchSetId().get()).isEqualTo(1);
  assertThat(psa.getLabel()).isEqualTo("Code-Review");
  assertThat(psa.getAccountId()).isEqualTo(user.id);
  assertThat(psa.getValue()).isEqualTo(1);
  assertThat(psa.getRealAccountId()).isEqualTo(admin.id); // not user2

  ChangeData cd = r.getChange();
  ChangeMessage m = Iterables.getLast(cmUtil.byChange(db, cd.notes()));
  assertThat(m.getMessage()).endsWith(in.message);
  assertThat(m.getAuthor()).isEqualTo(user.id);
  assertThat(m.getRealAuthor()).isEqualTo(admin.id); // not user2
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:38,代码来源:ImpersonationIT.java

示例15: explicitZeroVoteOnNonEmptyRangeIsPresent

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入依赖的package包/类
@Test
public void explicitZeroVoteOnNonEmptyRangeIsPresent() throws Exception {
  ProjectConfig pc = loadAllProjects();
  allow(pc, forLabel("Code-Review"), -1, 1, REGISTERED_USERS, "refs/heads/*");
  save(pc);

  PatchSetApproval cr = psa(userId, "Code-Review", 0);
  PatchSetApproval v = psa(userId, "Verified", 0);
  assertEquals(Result.create(list(cr, v), list(), list()), norm.normalize(notes, list(cr, v)));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:11,代码来源:LabelNormalizerTest.java


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