use of com.google.gerrit.acceptance.TestAccount in project gerrit by GerritCodeReview.
the class ChangeNotificationsIT method commentOnReviewableWipChangeByBotNotifyAll.
@Test
public void commentOnReviewableWipChangeByBotNotifyAll() throws Exception {
StagedChange sc = stageWipChange();
TestAccount bot = sc.testAccount("bot");
review(bot, sc.changeId, ENABLED, ALL, "tag");
assertThat(sender).sent("comment", sc).to(sc.owner).cc(sc.reviewer, sc.ccer).cc(StagedUsers.REVIEWER_BY_EMAIL, StagedUsers.CC_BY_EMAIL).bcc(sc.starrer).bcc(ALL_COMMENTS).noOneElse();
assertThat(sender).didNotSend();
}
use of com.google.gerrit.acceptance.TestAccount in project gerrit by GerritCodeReview.
the class GroupsIT method addMultipleMembers.
@Test
public void addMultipleMembers() throws Exception {
String g = createGroup("users");
TestAccount u1 = accounts.create("u1", "u1@example.com", "Full Name 1");
TestAccount u2 = accounts.create("u2", "u2@example.com", "Full Name 2");
gApi.groups().id(g).addMembers(u1.username, u2.username);
assertMembers(g, u1, u2);
}
use of com.google.gerrit.acceptance.TestAccount in project gerrit by GerritCodeReview.
the class ChangeReviewersIT method assertReviewers.
private static void assertReviewers(ChangeInfo c, ReviewerState reviewerState, TestAccount... accounts) throws Exception {
List<TestAccount> accountList = new ArrayList<>(accounts.length);
for (TestAccount a : accounts) {
accountList.add(a);
}
assertReviewers(c, reviewerState, accountList);
}
use of com.google.gerrit.acceptance.TestAccount in project gerrit by GerritCodeReview.
the class SuggestReviewersIT method reviewerRankingProjectIsolation.
@Test
public void reviewerRankingProjectIsolation() throws Exception {
// Create new project
Project.NameKey newProject = createProject("test");
// Create users who review changes in both the default and the new project
String fullName = "Primum Finalis";
TestAccount userWhoOwns = user("customuser1", fullName);
TestAccount reviewer1 = user("customuser2", fullName);
TestAccount reviewer2 = user("customuser3", fullName);
setApiUser(userWhoOwns);
String changeId1 = createChangeFromApi();
setApiUser(reviewer1);
reviewChange(changeId1);
setApiUser(userWhoOwns);
String changeId2 = createChangeFromApi(newProject);
setApiUser(reviewer2);
reviewChange(changeId2);
setApiUser(userWhoOwns);
String changeId3 = createChangeFromApi(newProject);
setApiUser(reviewer2);
reviewChange(changeId3);
setApiUser(userWhoOwns);
List<SuggestedReviewerInfo> reviewers = suggestReviewers(createChangeFromApi(), "Prim", 4);
// Assert that reviewer1 is on top, even though reviewer2 has more reviews
// in other projects
assertThat(reviewers.stream().map(r -> r.account._accountId).collect(toList())).containsExactly(reviewer1.id.get(), reviewer2.id.get()).inOrder();
}
use of com.google.gerrit.acceptance.TestAccount in project gerrit by GerritCodeReview.
the class PostReviewIT method deletingReviewers.
@Test
public void deletingReviewers() throws Exception {
PushOneCommit.Result r = createChange();
TestAccount user2 = accountCreator.user2();
// add user and user2
gApi.changes().id(r.getChangeId()).current().review(ReviewInput.create().reviewer(user.email()).reviewer(user2.email()));
sender.clear();
TestReviewerDeletedListener testReviewerDeletedListener = new TestReviewerDeletedListener();
try (Registration registration = extensionRegistry.newRegistration().add(testReviewerDeletedListener)) {
// remove user and user2
ReviewResult reviewResult = gApi.changes().id(r.getChangeId()).current().review(ReviewInput.create().reviewer(user.email(), ReviewerState.REMOVED, /* confirmed= */
true).reviewer(user2.email(), ReviewerState.REMOVED, /* confirmed= */
true));
assertThat(reviewResult.reviewers.values().stream().map(a -> a.removed.name).collect(toImmutableSet())).containsExactly(user.fullName(), user2.fullName());
}
assertThat(gApi.changes().id(r.getChangeId()).reviewers()).isEmpty();
// Ensure only one batch email was sent for this operation
FakeEmailSender.Message message = Iterables.getOnlyElement(sender.getMessages());
assertThat(message.body()).containsMatch(Pattern.quote("removed ") + "(" + Pattern.quote(String.format("%s, %s", user.fullName(), user2.fullName())) + "|" + Pattern.quote(String.format("%s, %s", user2.fullName(), user.fullName())) + ")");
assertThat(message.htmlBody()).containsMatch(Pattern.quote("removed ") + "(" + Pattern.quote(String.format("%s and %s", user.fullName(), user2.fullName())) + "|" + Pattern.quote(String.format("%s and %s", user2.fullName(), user.fullName())) + ")");
// Ensure that events have been sent:
// * 2 events for removing user and user2 as reviewers (one event per removed reviewer, batch
// event not available for reviewer removal)
assertThat(testReviewerDeletedListener.receivedEvents).hasSize(2);
assertThat(testReviewerDeletedListener.getReviewerIds()).containsExactly(user.id(), user2.id());
}
Aggregations