• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ReviewInput类的典型用法和代码示例

java 2次浏览

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

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

示例1: addingMultipleReviewersAndCCsAtOnceSendsOnlyOneEmail

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void addingMultipleReviewersAndCCsAtOnceSendsOnlyOneEmail() throws Exception {
  assume().that(notesMigration.readChanges()).isTrue();

  PushOneCommit.Result r = createChange();
  ReviewInput reviewInput = new ReviewInput();
  for (ReviewerState state : ImmutableList.of(ReviewerState.CC, ReviewerState.REVIEWER)) {
    for (int i = 0; i < 10; i++) {
      reviewInput.reviewer(String.format("%s-%[email protected]", state, i), state, true);
    }
  }
  assertThat(reviewInput.reviewers).hasSize(20);

  sender.clear();
  gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(reviewInput);
  assertThat(sender.getMessages()).hasSize(1);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:18,
代码来源:ChangeReviewersByEmailIT.java

示例2: defaultNotify

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
private NotifyHandling defaultNotify(Change c, ReviewInput in) {
  boolean workInProgress = c.isWorkInProgress();
  if (in.workInProgress) {
    workInProgress = true;
  }
  if (in.ready) {
    workInProgress = false;
  }

  if (ChangeMessagesUtil.isAutogenerated(in.tag)) {
    // Autogenerated comments default to lower notify levels.
    return workInProgress ? NotifyHandling.OWNER : NotifyHandling.OWNER_REVIEWERS;
  }

  if (workInProgress && !c.hasReviewStarted()) {
    // If review hasn't started we want to minimize recipients, no matter who
    // the author is.
    return NotifyHandling.OWNER;
  }

  return NotifyHandling.ALL;
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:23,
代码来源:PostReview.java

示例3: currentPatchSetOptionJSON

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void currentPatchSetOptionJSON() throws Exception {
  String changeId = createChange().getChangeId();
  amendChange(changeId);

  List<ChangeAttribute> changes = executeSuccessfulQuery(changeId);
  assertThat(changes.size()).isEqualTo(1);
  assertThat(changes.get(0).currentPatchSet).isNull();

  changes = executeSuccessfulQuery("--current-patch-set " + changeId);
  assertThat(changes.size()).isEqualTo(1);
  assertThat(changes.get(0).currentPatchSet).isNotNull();
  assertThat(changes.get(0).currentPatchSet.number).isEqualTo(2);

  gApi.changes().id(changeId).current().review(ReviewInput.approve());
  changes = executeSuccessfulQuery("--current-patch-set " + changeId);
  assertThat(changes.size()).isEqualTo(1);
  assertThat(changes.get(0).currentPatchSet).isNotNull();
  assertThat(changes.get(0).currentPatchSet.approvals).isNotNull();
  assertThat(changes.get(0).currentPatchSet.approvals.size()).isEqualTo(1);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:22,
代码来源:QueryIT.java

示例4: pushNewPatchsetToPatchSetLockedChange

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void pushNewPatchsetToPatchSetLockedChange() throws Exception {
  PushOneCommit.Result r = pushTo("refs/for/master");
  r.assertOkStatus();
  PushOneCommit push =
      pushFactory.create(
          db,
          admin.getIdent(),
          testRepo,
          PushOneCommit.SUBJECT,
          "b.txt",
          "anotherContent",
          r.getChangeId());
  revision(r).review(new ReviewInput().label("Patch-Set-Lock", 1));
  r = push.to("refs/for/master");
  r.assertErrorStatus("cannot add patch set to " + r.getChange().change().getChangeId() + ".");
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:18,
代码来源:AbstractPushForReview.java

示例5: mergedOptionWithNewCommitWithSameChangeIdFails

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void mergedOptionWithNewCommitWithSameChangeIdFails() throws Exception {
  PushOneCommit.Result r = pushTo("refs/for/master");
  r.assertOkStatus();
  gApi.changes().id(r.getChangeId()).current().review(ReviewInput.approve());
  gApi.changes().id(r.getChangeId()).current().submit();

  RevCommit c2 =
      testRepo
          .amend(r.getCommit())
          .message("New subject")
          .insertChangeId(r.getChangeId().substring(1))
          .create();
  testRepo.reset(c2);

  String ref = "refs/for/master%merged";
  PushResult pr = pushHead(testRepo, ref, false);
  RemoteRefUpdate rru = pr.getRemoteUpdate(ref);
  assertThat(rru.getStatus()).isEqualTo(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
  assertThat(rru.getMessage()).contains("not merged into branch");
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:22,
代码来源:AbstractPushForReview.java

示例6: changeMessageCreatedOnBehalfOfHasRealUser

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void changeMessageCreatedOnBehalfOfHasRealUser() throws Exception {
  allowCodeReviewOnBehalfOf();

  PushOneCommit.Result r = createChange();
  ReviewInput in = new ReviewInput();
  in.onBehalfOf = user.id.toString();
  in.message = "Message on behalf of";
  in.label("Code-Review", 1);

  setApiUser(accountCreator.user2());
  gApi.changes().id(r.getChangeId()).revision(r.getPatchSetId().getId()).review(in);

  ChangeInfo info = gApi.changes().id(r.getChangeId()).get(MESSAGES);
  assertThat(info.messages).hasSize(2);

  ChangeMessageInfo changeMessageInfo = Iterables.getLast(info.messages);
  assertThat(changeMessageInfo.realAuthor).isNotNull();
  assertThat(changeMessageInfo.realAuthor._accountId).isEqualTo(accountCreator.user2().id.get());
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:21,
代码来源:ImpersonationIT.java

示例7: pushToUserBranchForReview

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void pushToUserBranchForReview() throws Exception {
  String userRefName = RefNames.refsUsers(admin.id);
  TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
  fetch(allUsersRepo, userRefName + ":userRef");
  allUsersRepo.reset("userRef");
  PushOneCommit push = pushFactory.create(db, admin.getIdent(), allUsersRepo);
  PushOneCommit.Result r = push.to(MagicBranch.NEW_CHANGE + userRefName);
  r.assertOkStatus();
  accountIndexedCounter.assertNoReindex();
  assertThat(r.getChange().change().getDest().get()).isEqualTo(userRefName);
  gApi.changes().id(r.getChangeId()).current().review(ReviewInput.approve());
  gApi.changes().id(r.getChangeId()).current().submit();
  accountIndexedCounter.assertReindexOf(admin);

  push = pushFactory.create(db, admin.getIdent(), allUsersRepo);
  r = push.to(MagicBranch.NEW_CHANGE + RefNames.REFS_USERS_SELF);
  r.assertOkStatus();
  accountIndexedCounter.assertNoReindex();
  assertThat(r.getChange().change().getDest().get()).isEqualTo(userRefName);
  gApi.changes().id(r.getChangeId()).current().review(ReviewInput.approve());
  gApi.changes().id(r.getChangeId()).current().submit();
  accountIndexedCounter.assertReindexOf(admin);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:25,
代码来源:AccountIT.java

示例8: moveChangeWithCurrentPatchSetLocked

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void moveChangeWithCurrentPatchSetLocked() throws Exception {
  // Move change that is locked
  PushOneCommit.Result r = createChange();
  Branch.NameKey newBranch = new Branch.NameKey(r.getChange().change().getProject(), "moveTest");
  createBranch(newBranch);

  ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
  LabelType patchSetLock = Util.patchSetLock();
  cfg.getLabelSections().put(patchSetLock.getName(), patchSetLock);
  AccountGroup.UUID registeredUsers = systemGroupBackend.getGroup(REGISTERED_USERS).getUUID();
  Util.allow(
      cfg, Permission.forLabel(patchSetLock.getName()), 0, 1, registeredUsers, "refs/heads/*");
  saveProjectConfig(cfg);
  grant(project, "refs/heads/*", Permission.LABEL + "Patch-Set-Lock");
  revision(r).review(new ReviewInput().label("Patch-Set-Lock", 1));

  exception.expect(AuthException.class);
  exception.expectMessage("move not permitted");
  move(r.getChangeId(), newBranch.get());
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:22,
代码来源:MoveChangeIT.java

示例9: submitOnBehalfOf

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的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

示例10: revertOf

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void revertOf() throws Exception {
  if (getSchemaVersion() < 45) {
    assertMissingField(ChangeField.REVERT_OF);
    assertFailingQuery(
        "revertof:1", "'revertof' operator is not supported by change index version");
    return;
  }

  TestRepository<Repo> repo = createProject("repo");
  // Create two commits and revert second commit (initial commit can't be reverted)
  Change initial = insert(repo, newChange(repo));
  gApi.changes().id(initial.getChangeId()).current().review(ReviewInput.approve());
  gApi.changes().id(initial.getChangeId()).current().submit();

  ChangeInfo changeToRevert =
      gApi.changes().create(new ChangeInput("repo", "master", "commit to revert")).get();
  gApi.changes().id(changeToRevert.id).current().review(ReviewInput.approve());
  gApi.changes().id(changeToRevert.id).current().submit();

  ChangeInfo changeThatReverts = gApi.changes().id(changeToRevert.id).revert().get();
  assertQueryByIds(
      "revertof:" + changeToRevert._number, new Change.Id(changeThatReverts._number));
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:25,
代码来源:AbstractQueryChangesTest.java

示例11: postCommentWithUnresolved

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void postCommentWithUnresolved() throws Exception {
  for (Integer line : lines) {
    String file = "file";
    String contents = "contents " + line;
    PushOneCommit push =
        pushFactory.create(db, admin.getIdent(), testRepo, "first subject", file, contents);
    PushOneCommit.Result r = push.to("refs/for/master");
    String changeId = r.getChangeId();
    String revId = r.getCommit().getName();
    ReviewInput input = new ReviewInput();
    CommentInput comment = newComment(file, Side.REVISION, line, "comment 1", true);
    input.comments = new HashMap<>();
    input.comments.put(comment.path, Lists.newArrayList(comment));
    revision(r).review(input);
    Map<String, List<CommentInfo>> result = getPublishedComments(changeId, revId);
    assertThat(result).isNotEmpty();
    CommentInfo actual = Iterables.getOnlyElement(result.get(comment.path));
    assertThat(comment).isEqualTo(infoToInput(file).apply(actual));
    assertThat(comment)
        .isEqualTo(infoToInput(file).apply(getPublishedComment(changeId, revId, actual.id)));
  }
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:24,
代码来源:CommentsIT.java

示例12: approvalCopiedDuringSubmitIsNotPostSubmit

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@TestProjectInput(submitType = SubmitType.CHERRY_PICK)
@Test
public void approvalCopiedDuringSubmitIsNotPostSubmit() throws Exception {
  PushOneCommit.Result r = createChange();
  Change.Id id = r.getChange().getId();
  gApi.changes().id(id.get()).current().review(ReviewInput.approve());
  gApi.changes().id(id.get()).current().submit();

  ChangeData cd = r.getChange();
  assertThat(cd.patchSets()).hasSize(2);
  PatchSetApproval psa =
      Iterators.getOnlyElement(
          cd.currentApprovals().stream().filter(a -> !a.isLegacySubmit()).iterator());
  assertThat(psa.getPatchSetId().get()).isEqualTo(2);
  assertThat(psa.getLabel()).isEqualTo("Code-Review");
  assertThat(psa.getValue()).isEqualTo(2);
  assertThat(psa.isPostSubmit()).isFalse();
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:19,
代码来源:RevisionIT.java

示例13: includedInMergedChange

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void includedInMergedChange() throws Exception {
  Result result = createChange();
  gApi.changes()
      .id(result.getChangeId())
      .revision(result.getCommit().name())
      .review(ReviewInput.approve());
  gApi.changes().id(result.getChangeId()).revision(result.getCommit().name()).submit();

  assertThat(gApi.changes().id(result.getChangeId()).includedIn().branches)
      .containsExactly("master");
  assertThat(gApi.changes().id(result.getChangeId()).includedIn().tags).isEmpty();

  grantTagPermissions();
  gApi.projects().name(project.get()).tag("test-tag").create(new TagInput());

  assertThat(gApi.changes().id(result.getChangeId()).includedIn().tags)
      .containsExactly("test-tag");

  createBranch(new Branch.NameKey(project.get(), "test-branch"));

  assertThat(gApi.changes().id(result.getChangeId()).includedIn().branches)
      .containsExactly("master", "test-branch");
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:25,
代码来源:ChangeIncludedInIT.java

示例14: commentPredatingChangeBySomeoneOtherThanOwner

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void commentPredatingChangeBySomeoneOtherThanOwner() throws Exception {
  PushOneCommit.Result r = createChange();
  PatchSet.Id psId = r.getPatchSetId();
  Change.Id id = psId.getParentKey();
  Change c = db.changes().get(id);

  ReviewInput rin = new ReviewInput();
  rin.message = "comment";

  Timestamp ts = new Timestamp(c.getCreatedOn().getTime() - 10000);
  RevisionResource revRsrc = parseCurrentRevisionResource(r.getChangeId());
  setApiUser(user);
  postReview.get().apply(batchUpdateFactory, revRsrc, rin, ts);

  checker.rebuildAndCheckChanges(id);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:18,
代码来源:ChangeRebuilderIT.java

示例15: customLabelMaxWithBlock_MaxVoteSubmittable

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void customLabelMaxWithBlock_MaxVoteSubmittable() throws Exception {
  label.setFunction(MAX_WITH_BLOCK);
  P.setFunction(NO_OP);
  saveLabelConfig();
  PushOneCommit.Result r = createChange();
  assertThat(info(r.getChangeId()).submittable).isNull();
  revision(r).review(ReviewInput.approve().label(label.getName(), 1));

  ChangeInfo c = getWithLabels(r);
  assertThat(c.submittable).isTrue();
  LabelInfo q = c.labels.get(label.getName());
  assertThat(q.all).hasSize(1);
  assertThat(q.approved).isNotNull();
  assertThat(q.recommended).isNull();
  assertThat(q.disliked).isNull();
  assertThat(q.rejected).isNull();
  assertThat(q.blocking).isNull();
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:20,
代码来源:CustomLabelIT.java

示例16: revert

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void revert() throws Exception {
  PushOneCommit.Result r = createChange();
  gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
  gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).submit();
  ChangeInfo revertChange = gApi.changes().id(r.getChangeId()).revert().get();

  // expected messages on source change:
  // 1. Uploaded patch set 1.
  // 2. Patch Set 1: Code-Review+2
  // 3. Change has been successfully merged by Administrator
  // 4. Patch Set 1: Reverted
  List<ChangeMessageInfo> sourceMessages =
      new ArrayList<>(gApi.changes().id(r.getChangeId()).get().messages);
  assertThat(sourceMessages).hasSize(4);
  String expectedMessage =
      String.format("Created a revert of this change as %s", revertChange.changeId);
  assertThat(sourceMessages.get(3).message).isEqualTo(expectedMessage);

  assertThat(revertChange.messages).hasSize(1);
  assertThat(revertChange.messages.iterator().next().message).isEqualTo("Uploaded patch set 1.");
  assertThat(revertChange.revertOf).isEqualTo(gApi.changes().id(r.getChangeId()).get()._number);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:24,
代码来源:ChangeIT.java

示例17: notifyDetailsWorkOnPostReview

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void notifyDetailsWorkOnPostReview() throws Exception {
  PushOneCommit.Result r = createChange();
  TestAccount userToNotify = createAccounts(1, "notify-details-post-review").get(0);

  ReviewInput reviewInput = new ReviewInput();
  reviewInput.reviewer(user.email, ReviewerState.REVIEWER, true);
  reviewInput.notify = NotifyHandling.NONE;
  reviewInput.notifyDetails =
      ImmutableMap.of(RecipientType.TO, new NotifyInfo(ImmutableList.of(userToNotify.email)));

  sender.clear();
  gApi.changes().id(r.getChangeId()).current().review(reviewInput);
  assertThat(sender.getMessages()).hasSize(1);
  assertThat(sender.getMessages().get(0).rcpt()).containsExactly(userToNotify.emailAddress);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:17,
代码来源:ChangeReviewersIT.java

示例18: rebaseAllowedWithPermission

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void rebaseAllowedWithPermission() throws Exception {
  // Create two changes both with the same parent
  PushOneCommit.Result r = createChange();
  testRepo.reset("HEAD~1");
  PushOneCommit.Result r2 = createChange();

  // Approve and submit the first change
  RevisionApi revision = gApi.changes().id(r.getChangeId()).current();
  revision.review(ReviewInput.approve());
  revision.submit();

  grant(project, "refs/heads/master", Permission.REBASE, false, REGISTERED_USERS);

  // Rebase the second
  String changeId = r2.getChangeId();
  setApiUser(user);
  gApi.changes().id(changeId).rebase();
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:20,
代码来源:ChangeIT.java

示例19: voteOnBehalfOfInvisibleUserNotAllowed

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@GerritConfig(name = "accounts.visibility", value = "SAME_GROUP")
@Test
public void voteOnBehalfOfInvisibleUserNotAllowed() throws Exception {
  allowCodeReviewOnBehalfOf();
  setApiUser(accountCreator.user2());
  assertThat(accountControlFactory.get().canSee(user.id)).isFalse();

  PushOneCommit.Result r = createChange();
  RevisionApi revision = gApi.changes().id(r.getChangeId()).current();

  ReviewInput in = new ReviewInput();
  in.onBehalfOf = user.id.toString();
  in.label("Code-Review", 1);

  exception.expect(UnprocessableEntityException.class);
  exception.expectMessage("Account Not Found: " + in.onBehalfOf);
  revision.review(in);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:19,
代码来源:ImpersonationIT.java

示例20: commentBeforeFirstPatchSet

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void commentBeforeFirstPatchSet() throws Exception {
  PushOneCommit.Result r = createChange();
  PatchSet.Id psId = r.getPatchSetId();
  Change.Id id = psId.getParentKey();

  Change c = db.changes().get(id);
  c.setCreatedOn(new Timestamp(c.getCreatedOn().getTime() - 5000));
  db.changes().update(Collections.singleton(c));
  indexer.index(db, project, id);

  ReviewInput rin = new ReviewInput();
  rin.message = "comment";

  Timestamp ts = new Timestamp(c.getCreatedOn().getTime() + 2000);
  assertThat(ts).isGreaterThan(c.getCreatedOn());
  assertThat(ts).isLessThan(db.patchSets().get(psId).getCreatedOn());
  RevisionResource revRsrc = parseCurrentRevisionResource(r.getChangeId());
  postReview.get().apply(batchUpdateFactory, revRsrc, rin, ts);

  checker.rebuildAndCheckChanges(id);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:23,
代码来源:ChangeRebuilderIT.java

示例21: implicitlyCcOnNonVotingReviewPgStyle

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void implicitlyCcOnNonVotingReviewPgStyle() throws Exception {
  PushOneCommit.Result r = createChange();
  setApiUser(user);
  assertThat(getReviewerState(r.getChangeId(), user.id)).isEmpty();

  // Exact request format made by PG UI at ddc6b7160fe416fed9e7e3180489d44c82fd64f8.
  ReviewInput in = new ReviewInput();
  in.drafts = DraftHandling.PUBLISH_ALL_REVISIONS;
  in.labels = ImmutableMap.of();
  in.message = "comment";
  in.reviewers = ImmutableList.of();
  gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(in);

  // If we're not reading from NoteDb, then the CCed user will be returned in the REVIEWER state.
  assertThat(getReviewerState(r.getChangeId(), user.id))
      .hasValue(notesMigration.readChanges() ? CC : REVIEWER);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:19,
代码来源:ChangeIT.java

示例22: addReviewerToClosedChange

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void addReviewerToClosedChange() throws Exception {
  PushOneCommit.Result r = createChange();
  gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
  gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).submit();

  ChangeInfo c = gApi.changes().id(r.getChangeId()).get();
  Collection<AccountInfo> reviewers = c.reviewers.get(REVIEWER);
  assertThat(reviewers).hasSize(1);
  assertThat(reviewers.iterator().next()._accountId).isEqualTo(admin.getId().get());
  assertThat(c.reviewers).doesNotContainKey(CC);

  AddReviewerInput in = new AddReviewerInput();
  in.reviewer = user.email;
  gApi.changes().id(r.getChangeId()).addReviewer(in);

  c = gApi.changes().id(r.getChangeId()).get();
  reviewers = c.reviewers.get(REVIEWER);
  assertThat(reviewers).hasSize(2);
  Iterator<AccountInfo> reviewerIt = reviewers.iterator();
  assertThat(reviewerIt.next()._accountId).isEqualTo(admin.getId().get());
  assertThat(reviewerIt.next()._accountId).isEqualTo(user.getId().get());
  assertThat(c.reviewers).doesNotContainKey(CC);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:25,
代码来源:ChangeIT.java

示例23: emailNotificationForFileLevelComment

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void emailNotificationForFileLevelComment() throws Exception {
  String changeId = createChange().getChangeId();

  AddReviewerInput in = new AddReviewerInput();
  in.reviewer = user.email;
  gApi.changes().id(changeId).addReviewer(in);
  sender.clear();

  ReviewInput review = new ReviewInput();
  ReviewInput.CommentInput comment = new ReviewInput.CommentInput();
  comment.path = PushOneCommit.FILE_NAME;
  comment.side = Side.REVISION;
  comment.message = "comment 1";
  review.comments = new HashMap<>();
  review.comments.put(comment.path, Lists.newArrayList(comment));
  gApi.changes().id(changeId).current().review(review);

  assertThat(sender.getMessages()).hasSize(1);
  Message m = sender.getMessages().get(0);
  assertThat(m.rcpt()).containsExactly(user.emailAddress);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:23,
代码来源:ChangeIT.java

示例24: addComment

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
private void addComment(
    PushOneCommit.Result r,
    String message,
    boolean omitDuplicateComments,
    Boolean unresolved,
    String inReplyTo)
    throws Exception {
  CommentInput c = new CommentInput();
  c.line = 1;
  c.message = message;
  c.path = FILE_NAME;
  c.unresolved = unresolved;
  c.inReplyTo = inReplyTo;
  ReviewInput in = newInput(c);
  in.omitDuplicateComments = omitDuplicateComments;
  gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(in);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:18,
代码来源:CommentsIT.java

示例25: removingReviewerRemovesTheirVote

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void removingReviewerRemovesTheirVote() throws Exception {
  String crLabel = "Code-Review";
  PushOneCommit.Result r = createChange();
  ReviewInput input = ReviewInput.approve().reviewer(admin.email);
  ReviewResult addResult = review(r.getChangeId(), r.getCommit().name(), input);
  assertThat(addResult.reviewers).isNotNull();
  assertThat(addResult.reviewers).hasSize(1);

  Map<String, LabelInfo> changeLabels = getChangeLabels(r.getChangeId());
  assertThat(changeLabels.get(crLabel).all).hasSize(1);

  RestResponse deleteResult = deleteReviewer(r.getChangeId(), admin);
  deleteResult.assertNoContent();

  changeLabels = getChangeLabels(r.getChangeId());
  assertThat(changeLabels.get(crLabel).all).isNull();

  // Check that the vote is gone even after the reviewer is added back
  addReviewer(r.getChangeId(), admin.email);
  changeLabels = getChangeLabels(r.getChangeId());
  assertThat(changeLabels.get(crLabel).all).isNull();
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:24,
代码来源:ChangeReviewersIT.java

示例26: deleteVoteNotifyNone

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void deleteVoteNotifyNone() throws Exception {
  PushOneCommit.Result r = createChange();
  gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());

  setApiUser(user);
  recommend(r.getChangeId());

  setApiUser(admin);
  sender.clear();
  DeleteVoteInput in = new DeleteVoteInput();
  in.label = "Code-Review";
  in.notify = NotifyHandling.NONE;
  gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).deleteVote(in);
  assertThat(sender.getMessages()).isEmpty();
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:17,
代码来源:ChangeIT.java

示例27: putComment

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
private void putComment(TestAccount account, Change.Id id, int line, String msg, String inReplyTo)
    throws Exception {
  CommentInput in = new CommentInput();
  in.line = line;
  in.message = msg;
  in.inReplyTo = inReplyTo;
  ReviewInput rin = new ReviewInput();
  rin.comments = new HashMap<>();
  rin.comments.put(PushOneCommit.FILE_NAME, ImmutableList.of(in));
  rin.drafts = ReviewInput.DraftHandling.KEEP;
  AcceptanceTestRequestScope.Context old = setApiUser(account);
  try {
    gApi.changes().id(id.get()).current().review(rin);
  } finally {
    atrScope.set(old);
  }
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:18,
代码来源:ChangeRebuilderIT.java

示例28: voteOnBehalfOfCannotModifyDrafts

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void voteOnBehalfOfCannotModifyDrafts() throws Exception {
  allowCodeReviewOnBehalfOf();
  PushOneCommit.Result r = createChange();

  setApiUser(user);
  DraftInput di = new DraftInput();
  di.path = Patch.COMMIT_MSG;
  di.side = Side.REVISION;
  di.line = 1;
  di.message = "message";
  gApi.changes().id(r.getChangeId()).current().createDraft(di);

  setApiUser(admin);
  ReviewInput in = new ReviewInput();
  in.onBehalfOf = user.id.toString();
  in.label("Code-Review", 1);
  in.drafts = DraftHandling.PUBLISH;

  exception.expect(AuthException.class);
  exception.expectMessage("not allowed to modify other user's drafts");
  gApi.changes().id(r.getChangeId()).current().review(in);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:24,
代码来源:ImpersonationIT.java

示例29: submitted

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void submitted() throws Exception {
  PushOneCommit.Result r = createChange();
  String id = r.getChangeId();

  ChangeInfo c = gApi.changes().id(r.getChangeId()).info();
  assertThat(c.submitted).isNull();
  assertThat(c.submitter).isNull();

  gApi.changes().id(id).current().review(ReviewInput.approve());
  gApi.changes().id(id).current().submit();

  c = gApi.changes().id(r.getChangeId()).info();
  assertThat(c.submitted).isNotNull();
  assertThat(c.submitter).isNotNull();
  assertThat(c.submitter._accountId).isEqualTo(atrScope.get().getUser().getAccountId().get());
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:18,
代码来源:ChangeIT.java

示例30: submitStaleChange

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void submitStaleChange() throws Exception {
  PushOneCommit.Result r = createChange();

  disableChangeIndexWrites();
  try {
    r = amendChange(r.getChangeId());
  } finally {
    enableChangeIndexWrites();
  }

  gApi.changes().id(r.getChangeId()).current().review(ReviewInput.approve());

  gApi.changes().id(r.getChangeId()).current().submit();
  assertThat(gApi.changes().id(r.getChangeId()).info().status).isEqualTo(ChangeStatus.MERGED);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:17,
代码来源:ChangeIT.java

示例31: listComments

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void listComments() throws Exception {
  String file = "file";
  PushOneCommit push =
      pushFactory.create(db, admin.getIdent(), testRepo, "first subject", file, "contents");
  PushOneCommit.Result r = push.to("refs/for/master");
  String changeId = r.getChangeId();
  String revId = r.getCommit().getName();
  assertThat(getPublishedComments(changeId, revId)).isEmpty();

  List<CommentInput> expectedComments = new ArrayList<>();
  for (Integer line : lines) {
    ReviewInput input = new ReviewInput();
    CommentInput comment = newComment(file, Side.REVISION, line, "comment " + line, false);
    expectedComments.add(comment);
    input.comments = new HashMap<>();
    input.comments.put(comment.path, Lists.newArrayList(comment));
    revision(r).review(input);
  }

  Map<String, List<CommentInfo>> result = getPublishedComments(changeId, revId);
  assertThat(result).isNotEmpty();
  List<CommentInfo> actualComments = result.get(file);
  assertThat(Lists.transform(actualComments, infoToInput(file)))
      .containsExactlyElementsIn(expectedComments);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:27,
代码来源:CommentsIT.java

示例32: trivialRebase

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
private void trivialRebase(String changeId) throws Exception {
  setApiUser(admin);
  testRepo.reset(getRemoteHead());
  PushOneCommit push =
      pushFactory.create(
          db,
          admin.getIdent(),
          testRepo,
          "Other Change",
          "a" + System.nanoTime() + ".txt",
          PushOneCommit.FILE_CONTENT);
  PushOneCommit.Result r = push.to("refs/for/master");
  r.assertOkStatus();
  RevisionApi revision = gApi.changes().id(r.getChangeId()).current();
  ReviewInput in = new ReviewInput().label("Code-Review", 2).label("Verified", 1);
  revision.review(in);
  revision.submit();

  gApi.changes().id(changeId).current().rebase();
  assertThat(getChangeKind(changeId)).isEqualTo(TRIVIAL_REBASE);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:22,
代码来源:StickyApprovalsIT.java

示例33: voteOnBehalfOfLabelNotPermitted

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void voteOnBehalfOfLabelNotPermitted() throws Exception {
  ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
  LabelType verified = Util.verified();
  cfg.getLabelSections().put(verified.getName(), verified);
  saveProjectConfig(project, cfg);

  PushOneCommit.Result r = createChange();
  RevisionApi revision = gApi.changes().id(r.getChangeId()).current();

  ReviewInput in = new ReviewInput();
  in.onBehalfOf = user.id.toString();
  in.label("Verified", 1);

  exception.expect(AuthException.class);
  exception.expectMessage(
      "not permitted to modify label \"Verified\" on behalf of \"" + in.onBehalfOf + '"');
  revision.review(in);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:20,
代码来源:ImpersonationIT.java

示例34: byFrom

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void byFrom() throws Exception {
  TestRepository<Repo> repo = createProject("repo");
  Change change1 = insert(repo, newChange(repo));

  Account.Id user2 =
      accountManager.authenticate(AuthRequest.forUser("anotheruser")).getAccountId();
  Change change2 = insert(repo, newChange(repo), user2);

  ReviewInput input = new ReviewInput();
  input.message = "toplevel";
  ReviewInput.CommentInput comment = new ReviewInput.CommentInput();
  comment.line = 1;
  comment.message = "inline";
  input.comments =
      ImmutableMap.<String, List<ReviewInput.CommentInput>>of(
          Patch.COMMIT_MSG, ImmutableList.<ReviewInput.CommentInput>of(comment));
  gApi.changes().id(change2.getId().get()).current().review(input);

  assertQuery("from:" + userId.get(), change2, change1);
  assertQuery("from:" + user2, change2);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:23,
代码来源:AbstractQueryChangesTest.java

示例35: fileOptionJSON

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void fileOptionJSON() throws Exception {
  String changeId = createChange().getChangeId();

  List<ChangeAttribute> changes =
      executeSuccessfulQuery("--current-patch-set --files " + changeId);
  assertThat(changes.size()).isEqualTo(1);
  assertThat(changes.get(0).currentPatchSet.files).isNotNull();
  assertThat(changes.get(0).currentPatchSet.files.size()).isEqualTo(2);

  changes = executeSuccessfulQuery("--patch-sets --files " + changeId);
  assertThat(changes.size()).isEqualTo(1);
  assertThat(changes.get(0).patchSets.get(0).files).isNotNull();
  assertThat(changes.get(0).patchSets.get(0).files.size()).isEqualTo(2);

  gApi.changes().id(changeId).current().review(ReviewInput.approve());
  changes = executeSuccessfulQuery("--patch-sets --files --all-approvals " + changeId);
  assertThat(changes.size()).isEqualTo(1);
  assertThat(changes.get(0).patchSets.get(0).files).isNotNull();
  assertThat(changes.get(0).patchSets.get(0).files.size()).isEqualTo(2);
  assertThat(changes.get(0).patchSets.get(0).approvals).isNotNull();
  assertThat(changes.get(0).patchSets.get(0).approvals.size()).isEqualTo(1);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:24,
代码来源:QueryIT.java

示例36: contentOfParent

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void contentOfParent() throws Exception {
  String parentContent = "parent content";
  PushOneCommit.Result parent = createChange("Parent change", FILE_NAME, parentContent);
  parent.assertOkStatus();

  gApi.changes().id(parent.getChangeId()).current().review(ReviewInput.approve());
  gApi.changes().id(parent.getChangeId()).current().submit();

  PushOneCommit.Result child = createChange("Child change", FILE_NAME, FILE_CONTENT);
  child.assertOkStatus();
  assertContent(child, FILE_NAME, FILE_CONTENT);

  RestResponse response =
      adminRestSession.get(
          "/changes/"
              + child.getChangeId()
              + "/revisions/current/files/"
              + FILE_NAME
              + "/content?parent=1");
  response.assertOK();
  assertThat(new String(Base64.decode(response.getEntityContent()), UTF_8))
      .isEqualTo(parentContent);
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:25,
代码来源:RevisionIT.java

示例37: contentOfInvalidParent

点赞 3

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void contentOfInvalidParent() throws Exception {
  String parentContent = "parent content";
  PushOneCommit.Result parent = createChange("Parent change", FILE_NAME, parentContent);
  parent.assertOkStatus();

  gApi.changes().id(parent.getChangeId()).current().review(ReviewInput.approve());
  gApi.changes().id(parent.getChangeId()).current().submit();

  PushOneCommit.Result child = createChange("Child change", FILE_NAME, FILE_CONTENT);
  child.assertOkStatus();
  assertContent(child, FILE_NAME, FILE_CONTENT);

  RestResponse response =
      adminRestSession.get(
          "/changes/"
              + child.getChangeId()
              + "/revisions/current/files/"
              + FILE_NAME
              + "/content?parent=10");
  response.assertBadRequest();
  assertThat(response.getEntityContent()).isEqualTo("invalid parent");
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:24,
代码来源:RevisionIT.java

示例38: getReviewResult

点赞 2

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@VisibleForTesting
ReviewInput getReviewResult(Multimap<String, Issue> finalIssues) {
    String reviewMessage = getReviewMessage(finalIssues);
    ReviewInput reviewInput = new ReviewInput().message(reviewMessage);

    int finalIssuesCount = finalIssues.size();

    reviewInput.notify = getNotificationSettings(finalIssuesCount);

    if (postScore) {
        reviewInput.label(category, getReviewMark(finalIssuesCount));
    }

    reviewInput.comments = new HashMap<String, List<ReviewInput.CommentInput>>();
    for (String file : finalIssues.keySet()) {
        reviewInput.comments.put(file, Lists.newArrayList(
                        Collections2.transform(finalIssues.get(file),
                                new Function<Issue, ReviewInput.CommentInput>() {
                                    @Nullable
                                    @Override
                                    public ReviewInput.CommentInput apply(@Nullable Issue input) {
                                        if (input == null) {
                                            return null;
                                        }
                                        ReviewInput.CommentInput commentInput = new ReviewInput.CommentInput();
                                        commentInput.id = input.getKey();
                                        commentInput.line = input.getLine();
                                        commentInput.message = new CustomIssueFormatter(input, issueComment, getSonarURL()).getMessage();
                                        return commentInput;
                                    }

                                }
                        )
                )
        );
    }
    return reviewInput;
}
 

开发者ID:aquarellian,
项目名称:sonar-gerrit-plugin,
代码行数:39,
代码来源:SonarToGerritPublisher.java

示例39: openChangeForTargetBranchPreventsMerge

点赞 2

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Test
public void openChangeForTargetBranchPreventsMerge() throws Exception {
  gApi.projects().name(project.get()).branch("stable").create(new BranchInput());

  // Propose a change for master, but leave it open for master!
  PushOneCommit change =
      pushFactory.create(db, user.getIdent(), testRepo, "small fix", "a.txt", "2");
  PushOneCommit.Result change2result = change.to("refs/for/master");

  // Now cherry pick to stable
  CherryPickInput in = new CherryPickInput();
  in.destination = "stable";
  in.message = "it goes to stable branch";
  ChangeApi orig = gApi.changes().id(change2result.getChangeId());
  ChangeApi cherry = orig.current().cherryPick(in);
  cherry.current().review(ReviewInput.approve());
  cherry.current().submit();

  // Create a commit locally
  testRepo.git().fetch().setRefSpecs(new RefSpec("refs/heads/stable")).call();

  PushOneCommit.Result change3 = createChange(testRepo, "stable", "test", "a.txt", "3", "");
  submitWithConflict(
      change3.getChangeId(),
      "Failed to submit 1 change due to the following problems:\n"
          + "Change "
          + change3.getPatchSetId().getParentKey().get()
          + ": depends on change that was not submitted");

  assertRefUpdatedEvents();
  assertChangeMergedEvents();
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:33,
代码来源:SubmitByMergeIfNecessaryIT.java

示例40: review

点赞 2

import com.google.gerrit.extensions.api.changes.ReviewInput; //导入依赖的package包/类
@Override
public ReviewResult review(ReviewInput in) throws RestApiException {
  try {
    return review.apply(revision, in).value();
  } catch (Exception e) {
    throw asRestApiException("Cannot post review", e);
  }
}
 

开发者ID:gerrit-review,
项目名称:gerrit,
代码行数:9,
代码来源:RevisionApiImpl.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)