use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class StickyApprovalsIT method notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsRenamed.
private void notStickyWithCopyAllScoresIfListOfFilesDidNotChangeWhenFileIsRenamed() throws Exception {
Change.Id changeId = changeOperations.newChange().project(project).file("file").content("content").create();
vote(admin, changeId.toString(), 2, 1);
vote(user, changeId.toString(), -2, -1);
changeOperations.change(changeId).newPatchset().file("file").renameTo("new_file").create();
ChangeInfo c = detailedChange(changeId.toString());
// no votes are copied since the list of files changed (rename).
assertVotes(c, admin, 0, 0);
assertVotes(c, user, 0, 0);
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class StickyApprovalsIT method stickyWhenCopyConditionIsTrue.
@Test
public void stickyWhenCopyConditionIsTrue() throws Exception {
try (ProjectConfigUpdate u = updateProject(project)) {
u.getConfig().updateLabelType(LabelId.CODE_REVIEW, b -> b.setCopyCondition("is:ANY"));
u.save();
}
for (ChangeKind changeKind : EnumSet.of(REWORK, TRIVIAL_REBASE, NO_CODE_CHANGE, MERGE_FIRST_PARENT_UPDATE, NO_CHANGE)) {
testRepo.reset(projectOperations.project(project).getHead("master"));
String changeId = changeKindCreator.createChange(changeKind, testRepo, admin);
vote(admin, changeId, 2, 1);
vote(user, changeId, 1, -1);
changeKindCreator.updateChange(changeId, changeKind, testRepo, admin, project);
ChangeInfo c = detailedChange(changeId);
assertVotes(c, admin, 2, 0, changeKind);
assertVotes(c, user, 1, 0, changeKind);
}
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class StickyApprovalsIT method stickyAcrossMultiplePatchSets.
@Test
public void stickyAcrossMultiplePatchSets() throws Exception {
try (ProjectConfigUpdate u = updateProject(project)) {
u.getConfig().updateLabelType(LabelId.CODE_REVIEW, b -> b.setCopyMaxScore(true));
u.getConfig().updateLabelType(LabelId.VERIFIED, b -> b.setCopyAllScoresIfNoCodeChange(true));
u.save();
}
String changeId = changeKindCreator.createChange(REWORK, testRepo, admin);
vote(admin, changeId, 2, 1);
for (int i = 0; i < 5; i++) {
changeKindCreator.updateChange(changeId, NO_CODE_CHANGE, testRepo, admin, project);
ChangeInfo c = detailedChange(changeId);
assertVotes(c, admin, 2, 1, NO_CODE_CHANGE);
}
changeKindCreator.updateChange(changeId, REWORK, testRepo, admin, project);
ChangeInfo c = detailedChange(changeId);
assertVotes(c, admin, 2, 0, REWORK);
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class AbandonIT method batchAbandon.
@Test
public void batchAbandon() throws Exception {
CurrentUser user = atrScope.get().getUser();
PushOneCommit.Result a = createChange();
PushOneCommit.Result b = createChange();
List<ChangeData> list = ImmutableList.of(a.getChange(), b.getChange());
batchAbandon.batchAbandon(batchUpdateFactory, a.getChange().project(), user, list, "deadbeef");
ChangeInfo info = get(a.getChangeId(), MESSAGES);
assertThat(info.status).isEqualTo(ChangeStatus.ABANDONED);
assertThat(Iterables.getLast(info.messages).message.toLowerCase()).contains("abandoned");
assertThat(Iterables.getLast(info.messages).message.toLowerCase()).contains("deadbeef");
info = get(b.getChangeId(), MESSAGES);
assertThat(info.status).isEqualTo(ChangeStatus.ABANDONED);
assertThat(Iterables.getLast(info.messages).message.toLowerCase()).contains("abandoned");
assertThat(Iterables.getLast(info.messages).message.toLowerCase()).contains("deadbeef");
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class ChangeReviewersIT method addCcGroup.
@Test
public void addCcGroup() throws Exception {
List<TestAccount> users = createAccounts(6, "addCcGroup");
List<String> usernames = new ArrayList<>(6);
for (TestAccount u : users) {
usernames.add(u.username());
}
List<TestAccount> firstUsers = users.subList(0, 3);
List<String> firstUsernames = usernames.subList(0, 3);
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
ReviewerInput in = new ReviewerInput();
in.reviewer = groupOperations.newGroup().name("cc1").create().get();
in.state = CC;
gApi.groups().id(in.reviewer).addMembers(firstUsernames.toArray(new String[firstUsernames.size()]));
ReviewerResult result = addReviewer(changeId, in);
assertThat(result.input).isEqualTo(in.reviewer);
assertThat(result.confirm).isNull();
assertThat(result.error).isNull();
assertThat(result.reviewers).isNull();
ChangeInfo c = gApi.changes().id(r.getChangeId()).get();
assertReviewers(c, CC, firstUsers);
// Verify emails were sent to each of the group's accounts.
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
Message m = messages.get(0);
List<Address> expectedAddresses = new ArrayList<>(firstUsers.size());
for (TestAccount u : firstUsers) {
expectedAddresses.add(u.getNameEmail());
}
assertThat(m.rcpt()).containsExactlyElementsIn(expectedAddresses);
// CC a group that overlaps with some existing reviewers and CCed accounts.
TestAccount reviewer = accountCreator.create(name("reviewer"), "addCcGroup-reviewer@example.com", "Reviewer", null);
result = addReviewer(changeId, reviewer.username());
assertThat(result.error).isNull();
sender.clear();
in.reviewer = groupOperations.newGroup().name("cc2").create().get();
gApi.groups().id(in.reviewer).addMembers(usernames.toArray(new String[usernames.size()]));
gApi.groups().id(in.reviewer).addMembers(reviewer.username());
result = addReviewer(changeId, in);
assertThat(result.input).isEqualTo(in.reviewer);
assertThat(result.confirm).isNull();
assertThat(result.error).isNull();
c = gApi.changes().id(r.getChangeId()).get();
assertThat(result.ccs).hasSize(3);
assertThat(result.reviewers).isNull();
assertReviewers(c, REVIEWER, reviewer);
assertReviewers(c, CC, users);
messages = sender.getMessages();
assertThat(messages).hasSize(1);
m = messages.get(0);
expectedAddresses = new ArrayList<>(4);
for (int i = 0; i < 3; i++) {
expectedAddresses.add(users.get(users.size() - i - 1).getNameEmail());
}
expectedAddresses.add(reviewer.getNameEmail());
assertThat(m.rcpt()).containsExactlyElementsIn(expectedAddresses);
}
Aggregations