use of com.google.gerrit.extensions.api.changes.ReviewInput in project gerrit by GerritCodeReview.
the class RobotCommentsIT method robotCommentsNotSupportedWithoutNoteDb.
@Test
public void robotCommentsNotSupportedWithoutNoteDb() throws Exception {
assume().that(notesMigration.readChanges()).isFalse();
RobotCommentInput in = createRobotCommentInput();
ReviewInput reviewInput = new ReviewInput();
Map<String, List<RobotCommentInput>> robotComments = new HashMap<>();
robotComments.put(in.path, ImmutableList.of(in));
reviewInput.robotComments = robotComments;
reviewInput.message = "comment test";
exception.expect(MethodNotAllowedException.class);
exception.expectMessage("robot comments not supported");
gApi.changes().id(changeId).current().review(reviewInput);
}
use of com.google.gerrit.extensions.api.changes.ReviewInput in project gerrit by GerritCodeReview.
the class SuggestReviewersIT method reviewerRanking.
@Test
@GerritConfig(name = "suggest.maxSuggestedReviewers", value = "10")
public void reviewerRanking() throws Exception {
// Assert that user are ranked by the number of times they have applied a
// a label to a change (highest), added comments (medium) or owned a
// change (low).
String fullName = "Primum Finalis";
TestAccount userWhoOwns = user("customuser1", fullName);
TestAccount reviewer1 = user("customuser2", fullName);
TestAccount reviewer2 = user("customuser3", fullName);
TestAccount userWhoComments = user("customuser4", fullName);
TestAccount userWhoLooksForSuggestions = user("customuser5", fullName);
// Create a change as userWhoOwns and add some reviews
setApiUser(userWhoOwns);
String changeId1 = createChangeFromApi();
setApiUser(reviewer1);
reviewChange(changeId1);
setApiUser(user1);
String changeId2 = createChangeFromApi();
setApiUser(reviewer1);
reviewChange(changeId2);
setApiUser(reviewer2);
reviewChange(changeId2);
// Create a comment as a different user
setApiUser(userWhoComments);
ReviewInput ri = new ReviewInput();
ri.message = "Test";
gApi.changes().id(changeId1).revision(1).review(ri);
// Create a change as a new user to assert that we receive the correct
// ranking
setApiUser(userWhoLooksForSuggestions);
List<SuggestedReviewerInfo> reviewers = suggestReviewers(createChangeFromApi(), "Pri", 4);
assertThat(reviewers.stream().map(r -> r.account._accountId).collect(toList())).containsExactly(reviewer1.id.get(), reviewer2.id.get(), userWhoOwns.id.get(), userWhoComments.id.get()).inOrder();
}
use of com.google.gerrit.extensions.api.changes.ReviewInput in project gerrit by GerritCodeReview.
the class ProjectWatchIT method noNotificationForDraftPatchSetsForWatchersInNotifyConfig.
@Test
public void noNotificationForDraftPatchSetsForWatchersInNotifyConfig() throws Exception {
Address addr = new Address("Watcher", "watcher@example.com");
NotifyConfig nc = new NotifyConfig();
nc.addEmail(addr);
nc.setName("team");
nc.setHeader(NotifyConfig.Header.TO);
nc.setTypes(EnumSet.of(NotifyType.NEW_PATCHSETS, NotifyType.ALL_COMMENTS));
ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
cfg.putNotifyConfig("team", nc);
saveProjectConfig(project, cfg);
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent(), testRepo, "subject", "a", "a1").to("refs/for/master");
r.assertOkStatus();
sender.clear();
r = pushFactory.create(db, admin.getIdent(), testRepo, "subject", "a", "a2", r.getChangeId()).to("refs/for/master%draft");
r.assertOkStatus();
assertThat(sender.getMessages()).isEmpty();
setApiUser(admin);
ReviewInput in = new ReviewInput();
in.message = "comment";
gApi.changes().id(r.getChangeId()).current().review(in);
assertThat(sender.getMessages()).isEmpty();
}
use of com.google.gerrit.extensions.api.changes.ReviewInput in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method byDraftByExcludesZombieDrafts.
@Test
public void byDraftByExcludesZombieDrafts() throws Exception {
assume().that(notesMigration.readChanges()).isTrue();
Project.NameKey project = new Project.NameKey("repo");
TestRepository<Repo> repo = createProject(project.get());
Change change = insert(repo, newChange(repo));
Change.Id id = change.getId();
DraftInput in = new DraftInput();
in.line = 1;
in.message = "nit: trailing whitespace";
in.path = Patch.COMMIT_MSG;
gApi.changes().id(id.get()).current().createDraft(in);
assertQuery("draftby:" + userId, change);
assertQuery("commentby:" + userId);
TestRepository<Repo> allUsers = new TestRepository<>(repoManager.openRepository(allUsersName));
Ref draftsRef = allUsers.getRepository().exactRef(RefNames.refsDraftComments(id, userId));
assertThat(draftsRef).isNotNull();
ReviewInput rin = ReviewInput.dislike();
rin.drafts = DraftHandling.PUBLISH_ALL_REVISIONS;
gApi.changes().id(id.get()).current().review(rin);
assertQuery("draftby:" + userId);
assertQuery("commentby:" + userId, change);
assertThat(allUsers.getRepository().exactRef(draftsRef.getName())).isNull();
// Re-add drafts ref and ensure it gets filtered out during indexing.
allUsers.update(draftsRef.getName(), draftsRef.getObjectId());
assertThat(allUsers.getRepository().exactRef(draftsRef.getName())).isNotNull();
if (PrimaryStorage.of(change) == PrimaryStorage.REVIEW_DB && !notesMigration.disableChangeReviewDb()) {
// Record draft ref in noteDbState as well.
ReviewDb db = ReviewDbUtil.unwrapDb(this.db);
change = db.changes().get(id);
NoteDbChangeState.applyDelta(change, NoteDbChangeState.Delta.create(id, Optional.empty(), ImmutableMap.of(userId, draftsRef.getObjectId())));
db.changes().update(Collections.singleton(change));
}
indexer.index(db, project, id);
assertQuery("draftby:" + userId);
}
use of com.google.gerrit.extensions.api.changes.ReviewInput in project gerrit by GerritCodeReview.
the class ChangeIT method implicitlyCcOnNonVotingReviewGwtStyle.
@Test
public void implicitlyCcOnNonVotingReviewGwtStyle() throws Exception {
PushOneCommit.Result r = createChange();
setApiUser(user);
assertThat(getReviewerState(r.getChangeId(), user.id)).isEmpty();
// Exact request format made by GWT UI at ddc6b7160fe416fed9e7e3180489d44c82fd64f8.
ReviewInput in = new ReviewInput();
in.labels = ImmutableMap.of("Code-Review", (short) 0);
in.strictLabels = true;
in.drafts = DraftHandling.PUBLISH_ALL_REVISIONS;
in.message = "comment";
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);
}
Aggregations