-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add admin alert email * Add email type * Add subject * Add email content * Indicate that action is needed in the email subject
- Loading branch information
1 parent
fc1342f
commit 24a914d
Showing
9 changed files
with
275 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,13 +43,16 @@ protected void testExecute() throws Exception { | |
assertEquals("The Fellowship of the Ring", accountRequest.getInstitute()); | ||
assertNull(accountRequest.getRegisteredAt()); | ||
assertEquals(accountRequest.getRegistrationUrl(), output.getJoinLink()); | ||
verifyNumberOfEmailsSent(1); | ||
verifySpecifiedTasksAdded(Const.TaskQueue.SEARCH_INDEXING_QUEUE_NAME, 1); | ||
verifyNumberOfEmailsSent(2); | ||
EmailWrapper emailSent = mockEmailSender.getEmailsSent().get(0); | ||
assertEquals(String.format(EmailType.NEW_INSTRUCTOR_ACCOUNT.getSubject(), "Frodo Baggins"), | ||
emailSent.getSubject()); | ||
assertEquals("[email protected]", emailSent.getRecipient()); | ||
assertTrue(emailSent.getContent().contains(output.getJoinLink())); | ||
EmailWrapper sentAdminAlertEmail = mockEmailSender.getEmailsSent().get(1); | ||
// Check only the email type. The content of the email is not tested here, but in the email generator test(s). | ||
assertEquals(EmailType.NEW_ACCOUNT_REQUEST_ADMIN_ALERT, sentAdminAlertEmail.getType()); | ||
} | ||
|
||
@Override | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/resources/adminEmailTemplate-newAccountRequestAlert.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<p>Hello, Admin</p> | ||
|
||
<p> | ||
A new instructor account request has been submitted: | ||
</p> | ||
|
||
<div> | ||
<table style="max-width:600px;border:1px solid black;"> | ||
<tr> | ||
<td style="padding:5px;"> | ||
<strong> | ||
Full Name | ||
</strong> | ||
</td> | ||
<td style="padding:5px;"> | ||
${name} | ||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td style="padding:5px;"> | ||
<strong> | ||
Institute | ||
</strong> | ||
</td> | ||
<td style="padding:5px;"> | ||
${institute} | ||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td style="padding:5px;"> | ||
<strong> | ||
Email Address | ||
</strong> | ||
</td> | ||
<td style="padding:5px;"> | ||
${emailAddress} | ||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td style="padding:5px;"> | ||
<strong> | ||
Comments | ||
</strong> | ||
</td> | ||
<td style="padding:5px;"> | ||
${comments} | ||
</td> | ||
</tr> | ||
</table> | ||
</div> | ||
|
||
Accept/reject this request on the admin panel: <a href="${adminAccountRequestsPageUrl}">${adminAccountRequestsPageUrl}</a> | ||
|
||
<p> | ||
Regards,<br> | ||
TEAMMATES Team. | ||
</p> |
58 changes: 58 additions & 0 deletions
58
src/test/java/teammates/sqllogic/api/SqlEmailGeneratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package teammates.sqllogic.api; | ||
|
||
import java.io.IOException; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
import teammates.common.datatransfer.AccountRequestStatus; | ||
import teammates.common.util.Config; | ||
import teammates.common.util.EmailType; | ||
import teammates.common.util.EmailWrapper; | ||
import teammates.storage.sqlentity.AccountRequest; | ||
import teammates.test.BaseTestCase; | ||
import teammates.test.EmailChecker; | ||
|
||
/** | ||
* SUT: {@link SqlEmailGenerator}. | ||
*/ | ||
public class SqlEmailGeneratorTest extends BaseTestCase { | ||
private final SqlEmailGenerator sqlEmailGenerator = SqlEmailGenerator.inst(); | ||
|
||
@Test | ||
void testGenerateNewAccountRequestAdminAlertEmail_withComments_generatesSuccessfully() throws IOException { | ||
AccountRequest accountRequest = new AccountRequest("[email protected]", "Anakin Skywalker", "Jedi Order", | ||
AccountRequestStatus.PENDING, | ||
"I don't like sand. It's coarse and rough and irritating... and it gets everywhere."); | ||
EmailWrapper email = sqlEmailGenerator.generateNewAccountRequestAdminAlertEmail(accountRequest); | ||
verifyEmail(email, Config.SUPPORT_EMAIL, EmailType.NEW_ACCOUNT_REQUEST_ADMIN_ALERT, | ||
"TEAMMATES (Action Needed): New Account Request Received", | ||
"/adminNewAccountRequestAlertEmailWithComments.html"); | ||
} | ||
|
||
@Test | ||
void testGenerateNewAccountRequestAdminAlertEmail_withNoComments_generatesSuccessfully() throws IOException { | ||
AccountRequest accountRequest = new AccountRequest("[email protected]", "Maul", "Sith Order", | ||
AccountRequestStatus.PENDING, null); | ||
EmailWrapper email = sqlEmailGenerator.generateNewAccountRequestAdminAlertEmail(accountRequest); | ||
verifyEmail(email, Config.SUPPORT_EMAIL, EmailType.NEW_ACCOUNT_REQUEST_ADMIN_ALERT, | ||
"TEAMMATES (Action Needed): New Account Request Received", | ||
"/adminNewAccountRequestAlertEmailWithNoComments.html"); | ||
} | ||
|
||
private void verifyEmail(EmailWrapper email, String expectedRecipientEmailAddress, EmailType expectedEmailType, | ||
String expectedSubject, String expectedEmailContentFilePathname) throws IOException { | ||
assertEquals(expectedRecipientEmailAddress, email.getRecipient()); | ||
assertEquals(Config.EMAIL_SENDEREMAIL, email.getSenderEmail()); | ||
assertEquals(Config.EMAIL_SENDERNAME, email.getSenderName()); | ||
assertEquals(Config.EMAIL_REPLYTO, email.getReplyTo()); | ||
assertEquals(expectedEmailType, email.getType()); | ||
assertEquals(expectedSubject, email.getSubject()); | ||
String emailContent = email.getContent(); | ||
EmailChecker.verifyEmailContent(emailContent, expectedEmailContentFilePathname); | ||
verifyEmailContentHasNoPlaceholders(emailContent); | ||
} | ||
|
||
private void verifyEmailContentHasNoPlaceholders(String emailContent) { | ||
assertFalse(emailContent.contains("${")); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/test/resources/emails/adminNewAccountRequestAlertEmailWithComments.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<p>Hello, Admin</p> | ||
|
||
<p> | ||
A new instructor account request has been submitted: | ||
</p> | ||
|
||
<div> | ||
<table style="max-width:600px;border:1px solid black;"> | ||
<tr> | ||
<td style="padding:5px;"> | ||
<strong> | ||
Full Name | ||
</strong> | ||
</td> | ||
<td style="padding:5px;"> | ||
Anakin Skywalker | ||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td style="padding:5px;"> | ||
<strong> | ||
Institute | ||
</strong> | ||
</td> | ||
<td style="padding:5px;"> | ||
Jedi Order | ||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td style="padding:5px;"> | ||
<strong> | ||
Email Address | ||
</strong> | ||
</td> | ||
<td style="padding:5px;"> | ||
[email protected] | ||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td style="padding:5px;"> | ||
<strong> | ||
Comments | ||
</strong> | ||
</td> | ||
<td style="padding:5px;"> | ||
I don't like sand. It's coarse and rough and irritating... and it gets everywhere. | ||
</td> | ||
</tr> | ||
</table> | ||
</div> | ||
|
||
Accept/reject this request on the admin panel: <a href="${app.url}/web/admin/home">${app.url}/web/admin/home</a> | ||
|
||
<p> | ||
Regards,<br> | ||
TEAMMATES Team. | ||
</p> |
60 changes: 60 additions & 0 deletions
60
src/test/resources/emails/adminNewAccountRequestAlertEmailWithNoComments.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<p>Hello, Admin</p> | ||
|
||
<p> | ||
A new instructor account request has been submitted: | ||
</p> | ||
|
||
<div> | ||
<table style="max-width:600px;border:1px solid black;"> | ||
<tr> | ||
<td style="padding:5px;"> | ||
<strong> | ||
Full Name | ||
</strong> | ||
</td> | ||
<td style="padding:5px;"> | ||
Maul | ||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td style="padding:5px;"> | ||
<strong> | ||
Institute | ||
</strong> | ||
</td> | ||
<td style="padding:5px;"> | ||
Sith Order | ||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td style="padding:5px;"> | ||
<strong> | ||
Email Address | ||
</strong> | ||
</td> | ||
<td style="padding:5px;"> | ||
[email protected] | ||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td style="padding:5px;"> | ||
<strong> | ||
Comments | ||
</strong> | ||
</td> | ||
<td style="padding:5px;"> | ||
|
||
</td> | ||
</tr> | ||
</table> | ||
</div> | ||
|
||
Accept/reject this request on the admin panel: <a href="${app.url}/web/admin/home">${app.url}/web/admin/home</a> | ||
|
||
<p> | ||
Regards,<br> | ||
TEAMMATES Team. | ||
</p> |