Search in sources :

Example 91 with com.google.gerrit.extensions.api.changes.reviewinput

use of com.google.gerrit.extensions.api.changes.reviewinput in project gerrit by GerritCodeReview.

the class NoteDbPrimaryIT method rebuildReviewDb.

@Test
public void rebuildReviewDb() throws Exception {
    Change c = createChange().getChange().change();
    Change.Id id = c.getId();
    CommentInput cin = new CommentInput();
    cin.line = 1;
    cin.message = "Published comment";
    ReviewInput rin = ReviewInput.approve();
    rin.comments = ImmutableMap.of(PushOneCommit.FILE_NAME, ImmutableList.of(cin));
    gApi.changes().id(id.get()).current().review(ReviewInput.approve());
    DraftInput din = new DraftInput();
    din.path = PushOneCommit.FILE_NAME;
    din.line = 1;
    din.message = "Draft comment";
    gApi.changes().id(id.get()).current().createDraft(din);
    gApi.changes().id(id.get()).current().review(ReviewInput.approve());
    gApi.changes().id(id.get()).current().createDraft(din);
    assertThat(db.changeMessages().byChange(id)).isNotEmpty();
    assertThat(db.patchSets().byChange(id)).isNotEmpty();
    assertThat(db.patchSetApprovals().byChange(id)).isNotEmpty();
    assertThat(db.patchComments().byChange(id)).isNotEmpty();
    ChangeBundle noteDbBundle = ChangeBundle.fromNotes(commentsUtil, notesFactory.create(db, project, id));
    setNoteDbPrimary(id);
    db.changeMessages().delete(db.changeMessages().byChange(id));
    db.patchSets().delete(db.patchSets().byChange(id));
    db.patchSetApprovals().delete(db.patchSetApprovals().byChange(id));
    db.patchComments().delete(db.patchComments().byChange(id));
    ChangeMessage bogusMessage = ChangeMessagesUtil.newMessage(c.currentPatchSetId(), identifiedUserFactory.create(admin.getId()), TimeUtil.nowTs(), "some message", null);
    db.changeMessages().insert(Collections.singleton(bogusMessage));
    rebuilderWrapper.rebuildReviewDb(db, project, id);
    assertThat(db.changeMessages().byChange(id)).isNotEmpty();
    assertThat(db.patchSets().byChange(id)).isNotEmpty();
    assertThat(db.patchSetApprovals().byChange(id)).isNotEmpty();
    assertThat(db.patchComments().byChange(id)).isNotEmpty();
    ChangeBundle reviewDbBundle = bundleReader.fromReviewDb(ReviewDbUtil.unwrapDb(db), id);
    assertThat(reviewDbBundle.differencesFrom(noteDbBundle)).isEmpty();
}
Also used : CommentInput(com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput) ChangeBundle(com.google.gerrit.server.notedb.ChangeBundle) ChangeMessage(com.google.gerrit.reviewdb.client.ChangeMessage) DraftInput(com.google.gerrit.extensions.api.changes.DraftInput) Change(com.google.gerrit.reviewdb.client.Change) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 92 with com.google.gerrit.extensions.api.changes.reviewinput

use of com.google.gerrit.extensions.api.changes.reviewinput in project gerrit by GerritCodeReview.

the class CustomLabelIT method customLabelAnyWithBlock_Addreviewer_ZeroVote.

@Test
public void customLabelAnyWithBlock_Addreviewer_ZeroVote() throws Exception {
    P.setFunctionName("AnyWithBlock");
    saveLabelConfig();
    PushOneCommit.Result r = createChange();
    AddReviewerInput in = new AddReviewerInput();
    in.reviewer = user.email;
    gApi.changes().id(r.getChangeId()).addReviewer(in);
    ReviewInput input = new ReviewInput().label(P.getName(), 0);
    input.message = "foo";
    revision(r).review(input);
    ChangeInfo c = get(r.getChangeId());
    LabelInfo q = c.labels.get(P.getName());
    assertThat(q.all).hasSize(2);
    assertThat(q.disliked).isNull();
    assertThat(q.rejected).isNull();
    assertThat(q.blocking).isNull();
    assertThat(lastCommentAddedEvent.getComment()).isEqualTo("Patch Set 1:\n\n" + input.message);
}
Also used : LabelInfo(com.google.gerrit.extensions.common.LabelInfo) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AddReviewerInput(com.google.gerrit.extensions.api.changes.AddReviewerInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 93 with com.google.gerrit.extensions.api.changes.reviewinput

use of com.google.gerrit.extensions.api.changes.reviewinput in project gerrit by GerritCodeReview.

the class ChangeRebuilderIT method commentBeforeFirstPatchSet.

@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);
}
Also used : PatchSet(com.google.gerrit.reviewdb.client.PatchSet) RevisionResource(com.google.gerrit.server.change.RevisionResource) Change(com.google.gerrit.reviewdb.client.Change) Timestamp(java.sql.Timestamp) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 94 with com.google.gerrit.extensions.api.changes.reviewinput

use of com.google.gerrit.extensions.api.changes.reviewinput in project gerrit by GerritCodeReview.

the class QueryIT method commentOptionsInCurrentPatchSetJSON.

@Test
public void commentOptionsInCurrentPatchSetJSON() throws Exception {
    String changeId = createChange().getChangeId();
    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);
    List<ChangeAttribute> changes = executeSuccessfulQuery("--current-patch-set " + changeId);
    assertThat(changes.size()).isEqualTo(1);
    assertThat(changes.get(0).currentPatchSet.comments).isNull();
    changes = executeSuccessfulQuery("--current-patch-set --comments " + changeId);
    assertThat(changes.size()).isEqualTo(1);
    assertThat(changes.get(0).currentPatchSet.comments).isNotNull();
    assertThat(changes.get(0).currentPatchSet.comments.size()).isEqualTo(1);
}
Also used : ChangeAttribute(com.google.gerrit.server.data.ChangeAttribute) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 95 with com.google.gerrit.extensions.api.changes.reviewinput

use of com.google.gerrit.extensions.api.changes.reviewinput in project gerrit by GerritCodeReview.

the class CustomLabelIT method customLabelNoOp_NegativeVoteNotBlock.

@Test
public void customLabelNoOp_NegativeVoteNotBlock() throws Exception {
    label.setFunctionName("NoOp");
    saveLabelConfig();
    PushOneCommit.Result r = createChange();
    revision(r).review(new ReviewInput().label(label.getName(), -1));
    ChangeInfo c = get(r.getChangeId());
    LabelInfo q = c.labels.get(label.getName());
    assertThat(q.all).hasSize(1);
    assertThat(q.rejected).isNotNull();
    assertThat(q.blocking).isNull();
}
Also used : LabelInfo(com.google.gerrit.extensions.common.LabelInfo) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)103 Test (org.junit.Test)85 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)77 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)70 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)25 CommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput)20 Change (com.google.gerrit.reviewdb.client.Change)16 ArrayList (java.util.ArrayList)15 List (java.util.List)14 ImmutableList (com.google.common.collect.ImmutableList)13 LabelInfo (com.google.gerrit.extensions.common.LabelInfo)13 CommentInfo (com.google.gerrit.extensions.common.CommentInfo)12 ProjectConfig (com.google.gerrit.server.git.ProjectConfig)12 RevisionApi (com.google.gerrit.extensions.api.changes.RevisionApi)11 LabelType (com.google.gerrit.common.data.LabelType)10 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)10 RobotCommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput)9 ChangeData (com.google.gerrit.server.query.change.ChangeData)9 RestResponse (com.google.gerrit.acceptance.RestResponse)8 TestAccount (com.google.gerrit.acceptance.TestAccount)8