-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EVA-3738 - send email to EVA HelpDesk when new submission is uploaded (…
…#18) * send email to EVA HelpDesk when new submission uploaded
- Loading branch information
Showing
5 changed files
with
77 additions
and
18 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,15 +6,15 @@ | |
|
||
@Component | ||
public class EmailNotificationHelper { | ||
private static final String EVA_HELPDESK_EMAIL = "[email protected]"; | ||
public static final String EVA_HELPDESK_EMAIL = "[email protected]"; | ||
|
||
public String getSubjectForSubmissionStatusUpdate(SubmissionStatus submissionStatus, boolean success) { | ||
String result = (success == true) ? "SUCCESS" : "FAILED"; | ||
String result = success ? "SUCCESS" : "FAILED"; | ||
return String.format("EVA Submission Update: %s %s", submissionStatus, result); | ||
} | ||
|
||
public String getTextForSubmissionStatusUpdate(SubmissionAccount submissionAccount, String submissionId, | ||
SubmissionStatus submissionStatus, boolean success) { | ||
String projectTitle, SubmissionStatus submissionStatus, boolean success) { | ||
String result; | ||
String resultColor; | ||
if (success) { | ||
|
@@ -30,7 +30,9 @@ public String getTextForSubmissionStatusUpdate(SubmissionAccount submissionAccou | |
.addGap(1) | ||
.addText("Here is the update for your submission: ") | ||
.addGap(1) | ||
.addText("submission ID: " + submissionId) | ||
.addText("Submission ID: " + submissionId) | ||
.addLineBreak() | ||
.addText("Project Title: " + projectTitle) | ||
.addLineBreak() | ||
.addText("Submission Status: " + submissionStatus) | ||
.addLineBreak() | ||
|
@@ -44,6 +46,28 @@ public String getTextForSubmissionStatusUpdate(SubmissionAccount submissionAccou | |
return notificationText; | ||
} | ||
|
||
public String getTextForEVAHelpdeskSubmissionUploaded(SubmissionAccount submissionAccount, String submissionId, | ||
String projectTitle) { | ||
String notificationText = new HTMLHelper() | ||
.addText("Dear EVA Helpdesk,") | ||
.addGap(1) | ||
.addText("The user has uploaded a new Submission: ") | ||
.addGap(1) | ||
.addText("submission ID: " + submissionId) | ||
.addLineBreak() | ||
.addText("Project Title: " + projectTitle) | ||
.addLineBreak() | ||
.addText("User Name: " + submissionAccount.getFirstName() + " " + submissionAccount.getLastName()) | ||
.addLineBreak() | ||
.addText("User Email: " + submissionAccount.getPrimaryEmail()) | ||
.addGap(2) | ||
.build(); | ||
|
||
notificationText += getNotificationFooter(); | ||
|
||
return notificationText; | ||
} | ||
|
||
public String getNotificationFooter() { | ||
return new HTMLHelper() | ||
.addTextWithSize("Please don't reply to this email.", 10) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,8 @@ public void testGetTextForSubmissionStatusUpdateSuccess() { | |
"<br /><br />" + | ||
"Here is the update for your submission: " + | ||
"<br /><br />" + | ||
"submission ID: 12345<br />" + | ||
"Submission ID: submission12345<br />" + | ||
"Project Title: project123<br />" + | ||
"Submission Status: UPLOADED<br />" + | ||
"Result: <b><span style=\"color:green;\">SUCCESS</span></b>" + | ||
"<br /><br /><br />" + | ||
|
@@ -43,7 +44,7 @@ public void testGetTextForSubmissionStatusUpdateSuccess() { | |
"</span><br /><span style=\"font-size:10px;\">European Variation Archive: EMBL-EBI</span>"; | ||
|
||
String actualText = emailNotificationHelper.getTextForSubmissionStatusUpdate(submissionAccount, | ||
"12345", SubmissionStatus.UPLOADED, true); | ||
"submission12345", "project123", SubmissionStatus.UPLOADED, true); | ||
|
||
assertEquals(expectedText, actualText); | ||
} | ||
|
@@ -56,7 +57,8 @@ public void testGetTextForSubmissionStatusUpdateFailure() { | |
"<br /><br />" + | ||
"Here is the update for your submission: " + | ||
"<br /><br />" + | ||
"submission ID: 12345<br />" + | ||
"Submission ID: 12345<br />" + | ||
"Project Title: project123<br />" + | ||
"Submission Status: UPLOADED<br />" + | ||
"Result: <b><span style=\"color:red;\">FAILED</span></b>" + | ||
"<br /><br /><br />" + | ||
|
@@ -66,13 +68,36 @@ public void testGetTextForSubmissionStatusUpdateFailure() { | |
"</span><br /><span style=\"font-size:10px;\">European Variation Archive: EMBL-EBI</span>"; | ||
|
||
String actualText = emailNotificationHelper.getTextForSubmissionStatusUpdate(submissionAccount, | ||
"12345", SubmissionStatus.UPLOADED, false); | ||
"12345", "project123", SubmissionStatus.UPLOADED, false); | ||
|
||
assertEquals(expectedText, actualText); | ||
} | ||
|
||
@Test | ||
public void testGetNotificationFooter(){ | ||
public void testGetTextForEVAHelpdeskSubmissionUploaded() { | ||
SubmissionAccount submissionAccount = new SubmissionAccount("[email protected]", | ||
LoginMethod.WEBIN.toString(), "John", "Doe", "[email protected]"); | ||
String expectedText = "Dear EVA Helpdesk," + | ||
"<br /><br />" + | ||
"The user has uploaded a new Submission: " + | ||
"<br /><br />" + | ||
"submission ID: submission-12345<br />" + | ||
"Project Title: Test Project Title<br />" + | ||
"User Name: John Doe<br />" + | ||
"User Email: [email protected]" + | ||
"<br /><br /><br />" + | ||
"<span style=\"font-size:10px;\">Please don't reply to this email.</span><br />" + | ||
"<span style=\"font-size:10px;\">For any issues/support please contact us at </span>" + | ||
"<span style=\"font-size:10px;\"> <a href=\"mailto:[email protected]\">[email protected]</a> </span><br />" + | ||
"<span style=\"font-size:10px;\">European Variation Archive: EMBL-EBI</span>"; | ||
String actualText = emailNotificationHelper.getTextForEVAHelpdeskSubmissionUploaded(submissionAccount, | ||
"submission-12345", "Test Project Title"); | ||
|
||
assertEquals(expectedText, actualText); | ||
} | ||
|
||
@Test | ||
public void testGetNotificationFooter() { | ||
String expectedFooter = "<span style=\"font-size:10px;\">Please don't reply to this email.</span><br />" + | ||
"<span style=\"font-size:10px;\">For any issues/support please contact us at </span>" + | ||
"<span style=\"font-size:10px;\"> <a href=\"mailto:[email protected]\">[email protected]</a> " + | ||
|