use of com.google.gerrit.extensions.api.changes.DraftInput in project gerrit by GerritCodeReview.
the class CommentsIT method createDraft.
@Test
public void createDraft() throws Exception {
for (Integer line : lines) {
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
String revId = r.getCommit().getName();
String path = "file1";
DraftInput comment = newDraft(path, Side.REVISION, line, "comment 1");
addDraft(changeId, revId, comment);
Map<String, List<CommentInfo>> result = getDraftComments(changeId, revId);
assertThat(result).hasSize(1);
CommentInfo actual = Iterables.getOnlyElement(result.get(comment.path));
assertThat(comment).isEqualTo(infoToDraft(path).apply(actual));
}
}
use of com.google.gerrit.extensions.api.changes.DraftInput in project gerrit by GerritCodeReview.
the class RevisionIT method drafts.
@Test
public void drafts() throws Exception {
PushOneCommit.Result r = createChange();
DraftInput in = new DraftInput();
in.line = 1;
in.message = "nit: trailing whitespace";
in.path = FILE_NAME;
DraftApi draftApi = gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).createDraft(in);
assertThat(draftApi.get().message).isEqualTo(in.message);
assertThat(gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).draft(draftApi.get().id).get().message).isEqualTo(in.message);
assertThat(gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).drafts()).hasSize(1);
in.message = "good catch!";
assertThat(gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).draft(draftApi.get().id).update(in).message).isEqualTo(in.message);
assertThat(gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).draft(draftApi.get().id).get().author.email).isEqualTo(admin.email);
draftApi.delete();
assertThat(gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).drafts()).isEmpty();
}
use of com.google.gerrit.extensions.api.changes.DraftInput 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);
}
use of com.google.gerrit.extensions.api.changes.DraftInput in project gerrit by GerritCodeReview.
the class CommentsIT method deleteDraft.
@Test
public void deleteDraft() throws Exception {
for (Integer line : lines) {
PushOneCommit.Result r = createChange();
Timestamp origLastUpdated = r.getChange().change().getLastUpdatedOn();
String changeId = r.getChangeId();
String revId = r.getCommit().getName();
DraftInput draft = newDraft("file1", Side.REVISION, line, "comment 1");
CommentInfo returned = addDraft(changeId, revId, draft);
deleteDraft(changeId, revId, returned.id);
Map<String, List<CommentInfo>> drafts = getDraftComments(changeId, revId);
assertThat(drafts).isEmpty();
// Deleting a draft comment doesn't cause lastUpdatedOn to change.
assertThat(r.getChange().change().getLastUpdatedOn()).isEqualTo(origLastUpdated);
}
}
use of com.google.gerrit.extensions.api.changes.DraftInput in project gerrit by GerritCodeReview.
the class CommentsIT method createDraftOnMergeCommitChange.
@Test
public void createDraftOnMergeCommitChange() throws Exception {
for (Integer line : lines) {
PushOneCommit.Result r = createMergeCommitChange("refs/for/master");
String changeId = r.getChangeId();
String revId = r.getCommit().getName();
String path = "file1";
DraftInput c1 = newDraft(path, Side.REVISION, line, "ps-1");
DraftInput c2 = newDraft(path, Side.PARENT, line, "auto-merge of ps-1");
DraftInput c3 = newDraftOnParent(path, 1, line, "parent-1 of ps-1");
DraftInput c4 = newDraftOnParent(path, 2, line, "parent-2 of ps-1");
addDraft(changeId, revId, c1);
addDraft(changeId, revId, c2);
addDraft(changeId, revId, c3);
addDraft(changeId, revId, c4);
Map<String, List<CommentInfo>> result = getDraftComments(changeId, revId);
assertThat(result).hasSize(1);
assertThat(Lists.transform(result.get(path), infoToDraft(path))).containsExactly(c1, c2, c3, c4);
}
}
Aggregations