Search in sources :

Example 61 with ReviewInput

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

the class ImpersonationIT method voteOnBehalfOfInvalidLabel.

@Test
public void voteOnBehalfOfInvalidLabel() throws Exception {
    allowCodeReviewOnBehalfOf();
    PushOneCommit.Result r = createChange();
    RevisionApi revision = gApi.changes().id(r.getChangeId()).current();
    ReviewInput in = new ReviewInput();
    in.onBehalfOf = user.id.toString();
    in.strictLabels = true;
    in.label("Not-A-Label", 5);
    exception.expect(BadRequestException.class);
    exception.expectMessage("label \"Not-A-Label\" is not a configured label");
    revision.review(in);
}
Also used : RevisionApi(com.google.gerrit.extensions.api.changes.RevisionApi) 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 62 with ReviewInput

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

the class ImpersonationIT method voteOnBehalfOfCannotModifyDrafts.

@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);
}
Also used : DraftInput(com.google.gerrit.extensions.api.changes.DraftInput) 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 63 with ReviewInput

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

the class DeleteDraftPatchSetIT method deleteDraftPS1.

@Test
public void deleteDraftPS1() throws Exception {
    String changeId = createDraftChangeWith2PS();
    ReviewInput rin = new ReviewInput();
    rin.message = "Change message";
    CommentInput cin = new CommentInput();
    cin.line = 1;
    cin.patchSet = 1;
    cin.path = PushOneCommit.FILE_NAME;
    cin.side = Side.REVISION;
    cin.message = "Inline comment";
    rin.comments = new HashMap<>();
    rin.comments.put(cin.path, ImmutableList.of(cin));
    gApi.changes().id(changeId).revision(1).review(rin);
    ChangeData cd = getChange(changeId);
    PatchSet.Id delPsId = new PatchSet.Id(cd.getId(), 1);
    PatchSet ps = cd.patchSet(delPsId);
    deletePatchSet(changeId, ps);
    cd = getChange(changeId);
    assertThat(cd.patchSets()).hasSize(1);
    assertThat(Iterables.getOnlyElement(cd.patchSets()).getId().get()).isEqualTo(2);
    // Other entities based on deleted patch sets are also deleted.
    for (ChangeMessage m : cd.messages()) {
        assertThat(m.getPatchSetId()).named(m.toString()).isNotEqualTo(delPsId);
    }
    for (Comment c : cd.publishedComments()) {
        assertThat(c.key.patchSetId).named(c.toString()).isNotEqualTo(delPsId.get());
    }
}
Also used : Comment(com.google.gerrit.reviewdb.client.Comment) CommentInput(com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput) ChangeMessage(com.google.gerrit.reviewdb.client.ChangeMessage) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) ChangeData(com.google.gerrit.server.query.change.ChangeData) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 64 with ReviewInput

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

the class DeleteDraftPatchSetIT method deleteDraftPS2.

@Test
public void deleteDraftPS2() throws Exception {
    String changeId = createDraftChangeWith2PS();
    ReviewInput rin = new ReviewInput();
    rin.message = "Change message";
    CommentInput cin = new CommentInput();
    cin.line = 1;
    cin.patchSet = 1;
    cin.path = PushOneCommit.FILE_NAME;
    cin.side = Side.REVISION;
    cin.message = "Inline comment";
    rin.comments = new HashMap<>();
    rin.comments.put(cin.path, ImmutableList.of(cin));
    gApi.changes().id(changeId).revision(1).review(rin);
    ChangeData cd = getChange(changeId);
    PatchSet.Id delPsId = new PatchSet.Id(cd.getId(), 2);
    PatchSet ps = cd.patchSet(delPsId);
    deletePatchSet(changeId, ps);
    cd = getChange(changeId);
    assertThat(cd.patchSets()).hasSize(1);
    assertThat(Iterables.getOnlyElement(cd.patchSets()).getId().get()).isEqualTo(1);
    // Other entities based on deleted patch sets are also deleted.
    for (ChangeMessage m : cd.messages()) {
        assertThat(m.getPatchSetId()).named(m.toString()).isNotEqualTo(delPsId);
    }
    for (Comment c : cd.publishedComments()) {
        assertThat(c.key.patchSetId).named(c.toString()).isNotEqualTo(delPsId.get());
    }
}
Also used : Comment(com.google.gerrit.reviewdb.client.Comment) CommentInput(com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput) ChangeMessage(com.google.gerrit.reviewdb.client.ChangeMessage) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) ChangeData(com.google.gerrit.server.query.change.ChangeData) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 65 with ReviewInput

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

the class ChangeMessagesIT method postMessage.

private void postMessage(String changeId, String msg, String tag) throws Exception {
    ReviewInput in = new ReviewInput();
    in.message = msg;
    in.tag = tag;
    gApi.changes().id(changeId).current().review(in);
}
Also used : ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput)

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