use of com.google.gerrit.testing.FakeEmailSender.Message in project gerrit by GerritCodeReview.
the class AccountIT method ignoreChange.
@Test
public void ignoreChange() throws Exception {
AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
try (Registration registration = extensionRegistry.newRegistration().add(accountIndexedCounter)) {
TestAccount user2 = accountCreator.user2();
accountIndexedCounter.clear();
PushOneCommit.Result r = createChange();
ReviewerInput in = new ReviewerInput();
in.reviewer = user.email();
gApi.changes().id(r.getChangeId()).addReviewer(in);
in = new ReviewerInput();
in.reviewer = user2.email();
gApi.changes().id(r.getChangeId()).addReviewer(in);
requestScopeOperations.setApiUser(user.id());
gApi.changes().id(r.getChangeId()).ignore(true);
sender.clear();
requestScopeOperations.setApiUser(admin.id());
gApi.changes().id(r.getChangeId()).abandon();
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
assertThat(messages.get(0).rcpt()).containsExactly(user2.getNameEmail());
accountIndexedCounter.assertNoReindex();
}
}
use of com.google.gerrit.testing.FakeEmailSender.Message in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method removingReviewerTriggersNotification.
@Test
public void removingReviewerTriggersNotification() throws Exception {
AccountInfo acc = new AccountInfo("Foo Bar", "foo.bar@gerritcodereview.com");
for (ReviewerState state : ImmutableList.of(ReviewerState.CC, ReviewerState.REVIEWER)) {
PushOneCommit.Result r = createChange();
ReviewerInput addInput = new ReviewerInput();
addInput.reviewer = toRfcAddressString(acc);
addInput.state = state;
gApi.changes().id(r.getChangeId()).addReviewer(addInput);
// Review change as user
ReviewInput reviewInput = new ReviewInput();
reviewInput.message = "I have a comment";
requestScopeOperations.setApiUser(user.id());
revision(r).review(reviewInput);
requestScopeOperations.setApiUser(admin.id());
sender.clear();
// Delete as admin
gApi.changes().id(r.getChangeId()).reviewer(addInput.reviewer).remove();
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
assertThat(messages.get(0).rcpt()).containsExactly(Address.parse(addInput.reviewer), user.getNameEmail());
sender.clear();
}
}
use of com.google.gerrit.testing.FakeEmailSender.Message in project gerrit by GerritCodeReview.
the class ChangeReviewersIT method addCcAccount.
@Test
public void addCcAccount() throws Exception {
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
ReviewerInput in = new ReviewerInput();
in.reviewer = user.email();
in.state = CC;
ReviewerResult result = addReviewer(changeId, in);
assertThat(result.input).isEqualTo(user.email());
assertThat(result.confirm).isNull();
assertThat(result.error).isNull();
ChangeInfo c = gApi.changes().id(r.getChangeId()).get();
assertThat(result.reviewers).isNull();
assertThat(result.ccs).hasSize(1);
AccountInfo ai = result.ccs.get(0);
assertThat(ai._accountId).isEqualTo(user.id().get());
assertReviewers(c, CC, user);
// Verify email was sent to CCed account.
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
Message m = messages.get(0);
assertThat(m.rcpt()).containsExactly(user.getNameEmail());
assertThat(m.body()).contains(admin.fullName() + " has uploaded this change for review.");
}
use of com.google.gerrit.testing.FakeEmailSender.Message in project gerrit by GerritCodeReview.
the class AssigneeIT method addGetAssignee.
@Test
public void addGetAssignee() throws Exception {
PushOneCommit.Result r = createChange();
assertThat(setAssignee(r, user.email())._accountId).isEqualTo(user.id().get());
assertThat(getAssignee(r)._accountId).isEqualTo(user.id().get());
assertThat(sender.getMessages()).hasSize(1);
Message m = sender.getMessages().get(0);
assertThat(m.rcpt()).containsExactly(user.getNameEmail());
}
use of com.google.gerrit.testing.FakeEmailSender.Message in project gerrit by GerritCodeReview.
the class ChangeIT method pushCommitWithFooterOfOtherUser.
@Test
public void pushCommitWithFooterOfOtherUser() throws Exception {
// admin pushes commit that references 'user' in a footer
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo, PushOneCommit.SUBJECT + "\n\n" + FooterConstants.REVIEWED_BY.getName() + ": " + user.newIdent().toExternalString(), PushOneCommit.FILE_NAME, PushOneCommit.FILE_CONTENT);
PushOneCommit.Result result = push.to("refs/for/master");
result.assertOkStatus();
// check that 'user' was added as reviewer
ChangeInfo change = gApi.changes().id(result.getChangeId()).get();
Collection<AccountInfo> reviewers = change.reviewers.get(REVIEWER);
assertThat(reviewers).isNotNull();
assertThat(reviewers).hasSize(1);
assertThat(reviewers.iterator().next()._accountId).isEqualTo(user.id().get());
assertThat(change.reviewers.get(CC)).isNull();
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
Message m = messages.get(0);
assertThat(m.rcpt()).containsExactly(user.getNameEmail());
assertThat(m.body()).contains("Hello " + user.fullName() + ",\n");
assertThat(m.body()).contains("I'd like you to do a code review.");
assertThat(m.body()).contains("Change subject: " + PushOneCommit.SUBJECT + "\n");
assertMailReplyTo(m, admin.email());
}
Aggregations