-
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.
- Loading branch information
Showing
2 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
src/test/java/uk/ac/ebi/eva/submission/unit/EmailNotificationHelperTest.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,87 @@ | ||
package uk.ac.ebi.eva.submission.unit; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import uk.ac.ebi.eva.submission.entity.SubmissionAccount; | ||
import uk.ac.ebi.eva.submission.model.SubmissionStatus; | ||
import uk.ac.ebi.eva.submission.service.LoginMethod; | ||
import uk.ac.ebi.eva.submission.util.EmailNotificationHelper; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class EmailNotificationHelperTest { | ||
private EmailNotificationHelper emailNotificationHelper; | ||
|
||
@BeforeEach | ||
public void setup() { | ||
emailNotificationHelper = new EmailNotificationHelper(); | ||
} | ||
|
||
@Test | ||
public void testGetSubjectForSubmissionStatusUpdate() { | ||
String expectedSubject = "EVA Submission Update: UPLOADED SUCCESS"; | ||
String actualSubject = emailNotificationHelper.getSubjectForSubmissionStatusUpdate(SubmissionStatus.UPLOADED, Boolean.TRUE); | ||
|
||
assertEquals(expectedSubject, actualSubject); | ||
} | ||
|
||
@Test | ||
public void testGetTextForSubmissionStatusUpdateSuccess() { | ||
SubmissionAccount submissionAccount = new SubmissionAccount("[email protected]", | ||
LoginMethod.WEBIN.toString(), "John", "Doe", "[email protected]"); | ||
String expectedText = "Dear John," + | ||
"<br /><br />" + | ||
"Here is the update for your submission: " + | ||
"<br /><br />" + | ||
"submission id: 12345<br />" + | ||
"Submission Status: UPLOADED<br />" + | ||
"Result: <b><span style=\"color:green;\">SUCCESS</span></b>" + | ||
"<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.getTextForSubmissionStatusUpdate(submissionAccount, | ||
"12345", SubmissionStatus.UPLOADED, Boolean.TRUE); | ||
|
||
assertEquals(expectedText, actualText); | ||
} | ||
|
||
@Test | ||
public void testGetTextForSubmissionStatusUpdateFailure() { | ||
SubmissionAccount submissionAccount = new SubmissionAccount("[email protected]", | ||
LoginMethod.WEBIN.toString(), "John", "Doe", "[email protected]"); | ||
String expectedText = "Dear John," + | ||
"<br /><br />" + | ||
"Here is the update for your submission: " + | ||
"<br /><br />" + | ||
"submission id: 12345<br />" + | ||
"Submission Status: UPLOADED<br />" + | ||
"Result: <b><span style=\"color:red;\">FAILED</span></b>" + | ||
"<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.getTextForSubmissionStatusUpdate(submissionAccount, | ||
"12345", SubmissionStatus.UPLOADED, Boolean.FALSE); | ||
|
||
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> " + | ||
"</span><br /><span style=\"font-size:10px;\">European Variation Archive: EMBL-EBI</span>"; | ||
|
||
String actualFooter = emailNotificationHelper.getNotificationFooter(); | ||
|
||
assertEquals(expectedFooter, actualFooter); | ||
} | ||
|
||
} | ||
|
109 changes: 109 additions & 0 deletions
109
src/test/java/uk/ac/ebi/eva/submission/unit/HTMLHelperTest.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,109 @@ | ||
package uk.ac.ebi.eva.submission.unit; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import uk.ac.ebi.eva.submission.util.HTMLHelper; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class HTMLHelperTest { | ||
|
||
@Test | ||
public void testAddLineBreak() { | ||
String expectedHTML = "<br />"; | ||
String actualHTML = new HTMLHelper().addLineBreak().build(); | ||
assertEquals(expectedHTML, actualHTML); | ||
} | ||
|
||
@Test | ||
public void testAddGap() { | ||
// adding a gap of 3 lines means you need to add 4 <br /> tags, | ||
// one for taking the cursor to the new line and the rest for the actual gap | ||
String expectedHTML = "<br /><br /><br /><br />"; | ||
String actualHTML = new HTMLHelper().addGap(3).build(); | ||
assertEquals(expectedHTML, actualHTML); | ||
} | ||
|
||
@Test | ||
public void testAddText() { | ||
String expectedHTML = "sample text"; | ||
String actualHTML = new HTMLHelper().addText("sample text").build(); | ||
assertEquals(expectedHTML, actualHTML); | ||
} | ||
|
||
@Test | ||
public void testAddTextWithSize() { | ||
String expectedHTML = "<span style=\"font-size:5px;\">sample text</span>"; | ||
String actualHTML = new HTMLHelper().addTextWithSize("sample text", 5).build(); | ||
assertEquals(expectedHTML, actualHTML); | ||
} | ||
|
||
@Test | ||
public void testAddTextWithColour() { | ||
String expectedHTML = "<span style=\"color:red;\">sample text</span>"; | ||
String actualHTML = new HTMLHelper().addTextWithColor("sample text", "red").build(); | ||
assertEquals(expectedHTML, actualHTML); | ||
} | ||
|
||
@Test | ||
public void testAddBoldText() { | ||
String expectedHTML = "<b>sample text</b>"; | ||
String actualHTML = new HTMLHelper().addBoldText("sample text").build(); | ||
assertEquals(expectedHTML, actualHTML); | ||
} | ||
|
||
@Test | ||
public void testAddLink() { | ||
String expectedHTML = "<a href=\"[email protected]\">abc</a>"; | ||
String actualHTML = new HTMLHelper().addLink("[email protected]", "abc").build(); | ||
assertEquals(expectedHTML, actualHTML); | ||
} | ||
|
||
@Test | ||
public void testAddEmailLink() { | ||
String expectedHTML = "<a href=\"mailto:[email protected]\">[email protected]</a>"; | ||
String actualHTML = new HTMLHelper().addEmailLink("[email protected]", "[email protected]").build(); | ||
assertEquals(expectedHTML, actualHTML); | ||
} | ||
|
||
@Test | ||
public void testAddEmailLinkWithSize() { | ||
String expectedHTML = "<span style=\"font-size:5px;\"> <a href=\"mailto:[email protected]\">[email protected]</a> </span>"; | ||
String actualHTML = new HTMLHelper().addEmailLinkWithSize("[email protected]", "[email protected]", 5).build(); | ||
assertEquals(expectedHTML, actualHTML); | ||
} | ||
|
||
@Test | ||
public void addBoldTextWithColour() { | ||
String expectedHTML = "<b><span style=\"color:red;\">sample text</span></b>"; | ||
String actualHTML = new HTMLHelper().addBoldTextWithColor("sample text", "red").build(); | ||
assertEquals(expectedHTML, actualHTML); | ||
} | ||
|
||
@Test | ||
public void testMultiLineHTML() { | ||
String expectedHTML = "Dear John," + | ||
"<br /><br />" + | ||
"Here is the update for your submission: " + | ||
"<br /><br />" + | ||
"submission id: 12345<br />" + | ||
"Submission Status: UPLOADED<br />" + | ||
"Result: <b><span style=\"color:red;\">FAILED</span></b>" + | ||
"<br /><br /><br />"; | ||
String actualHTMl = new HTMLHelper() | ||
.addText("Dear " + "John" + ",") | ||
.addGap(1) | ||
.addText("Here is the update for your submission: ") | ||
.addGap(1) | ||
.addText("submission id: " + 12345) | ||
.addLineBreak() | ||
.addText("Submission Status: " + "UPLOADED") | ||
.addLineBreak() | ||
.addText("Result: ") | ||
.addBoldTextWithColor("FAILED", "red") | ||
.addGap(2) | ||
.build(); | ||
|
||
assertEquals(expectedHTML, actualHTMl); | ||
} | ||
|
||
} |