Add test assertion that adding reviewer triggers email
Change-Id: I80c8c5bf23f309c637779870c584f44587174418 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -69,6 +69,7 @@ import com.google.gerrit.server.project.Util;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gerrit.testutil.ConfigSuite;
|
||||
import com.google.gerrit.testutil.FakeEmailSender;
|
||||
import com.google.gerrit.testutil.TempFileUtil;
|
||||
import com.google.gerrit.testutil.TestNotesMigration;
|
||||
import com.google.gson.Gson;
|
||||
@@ -187,6 +188,9 @@ public abstract class AbstractDaemonTest {
|
||||
@Inject
|
||||
protected Revisions revisions;
|
||||
|
||||
@Inject
|
||||
protected FakeEmailSender sender;
|
||||
|
||||
protected TestRepository<InMemoryRepository> testRepo;
|
||||
protected GerritServer server;
|
||||
protected TestAccount admin;
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.acceptance;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.server.mail.Address;
|
||||
|
||||
import com.jcraft.jsch.KeyPair;
|
||||
|
||||
@@ -58,6 +59,7 @@ public class TestAccount {
|
||||
public final Account.Id id;
|
||||
public final String username;
|
||||
public final String email;
|
||||
public final Address emailAddress;
|
||||
public final String fullName;
|
||||
public final KeyPair sshKey;
|
||||
public final String httpPassword;
|
||||
@@ -67,6 +69,7 @@ public class TestAccount {
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.email = email;
|
||||
this.emailAddress = new Address(fullName, email);
|
||||
this.fullName = fullName;
|
||||
this.sshKey = sshKey;
|
||||
this.httpPassword = httpPassword;
|
||||
|
||||
@@ -67,6 +67,7 @@ import com.google.gerrit.server.group.SystemGroupBackend;
|
||||
import com.google.gerrit.server.notedb.ChangeNoteUtil;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.Util;
|
||||
import com.google.gerrit.testutil.FakeEmailSender.Message;
|
||||
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
@@ -512,6 +513,14 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
.id(r.getChangeId())
|
||||
.addReviewer(in);
|
||||
|
||||
List<Message> messages = sender.getMessages();
|
||||
assertThat(messages).hasSize(1);
|
||||
Message m = messages.get(0);
|
||||
assertThat(m.rcpt()).containsExactly(user.emailAddress);
|
||||
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");
|
||||
|
||||
ChangeInfo c = gApi.changes()
|
||||
.id(r.getChangeId())
|
||||
.get();
|
||||
|
||||
@@ -23,9 +23,7 @@ import com.google.gerrit.reviewdb.client.AccountProjectWatch.NotifyType;
|
||||
import com.google.gerrit.server.git.NotifyConfig;
|
||||
import com.google.gerrit.server.git.ProjectConfig;
|
||||
import com.google.gerrit.server.mail.Address;
|
||||
import com.google.gerrit.testutil.FakeEmailSender;
|
||||
import com.google.gerrit.testutil.FakeEmailSender.Message;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -34,9 +32,6 @@ import java.util.List;
|
||||
|
||||
@NoHttpd
|
||||
public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
@Inject
|
||||
private FakeEmailSender sender;
|
||||
|
||||
/**
|
||||
* Tests message project watches on new patch sets
|
||||
* <p>
|
||||
|
||||
Reference in New Issue
Block a user