|
7 | 7 | import static org.junit.Assert.assertEquals;
|
8 | 8 |
|
9 | 9 | public class SendgridTest {
|
10 |
| - private static final String FROM_EMAIL = "[email protected]"; |
11 |
| - private static final String PASSWORD = "password"; |
12 |
| - private static final String TO_ANOTHER_EMAIL = "bcc@email.to"; |
13 |
| - private static final String TO_EMAIL = "[email protected]"; |
14 |
| - private static final String USERNAME = "username"; |
| 10 | + private static final String FROM_EMAIL = "[email protected]"; |
| 11 | + private static final String TO_ANOTHER_EMAIL = "[email protected]"; |
| 12 | + private static final String TO_EMAIL = "to@email.to"; |
| 13 | + private static final String USERNAME = "username"; |
| 14 | + private static final String PASSWORD = "password"; |
15 | 15 |
|
16 |
| - @Test |
17 |
| - public void testSendSuccess() { |
18 |
| - String result = Sendgrid |
19 |
| - .withCredentials(USERNAME, PASSWORD) |
20 |
| - .from(FROM_EMAIL) |
21 |
| - .to(TO_EMAIL) |
22 |
| - .withSubject("This is a test subject") |
23 |
| - .withText("This is a test text.") |
24 |
| - .send(); |
25 |
| - assertEquals("{\"message\":\"success\"}", result); |
26 |
| - } |
| 16 | + @Test |
| 17 | + public void testSendSuccess() { |
| 18 | + String result = Sendgrid |
| 19 | + .withCredentials(USERNAME, PASSWORD) |
| 20 | + .from(FROM_EMAIL) |
| 21 | + .to(TO_EMAIL) |
| 22 | + .withSubject("This is a test subject") |
| 23 | + .withText("This is a test text.") |
| 24 | + .send(); |
| 25 | + assertEquals("{\"message\":\"success\"}", result); |
| 26 | + } |
27 | 27 |
|
28 |
| - @Test |
29 |
| - public void testSendSuccessBcc() { |
30 |
| - String result = Sendgrid |
31 |
| - .withCredentials(USERNAME, PASSWORD) |
32 |
| - .from(FROM_EMAIL) |
33 |
| - .to(TO_EMAIL) |
34 |
| - .bcc(TO_ANOTHER_EMAIL) |
35 |
| - .withSubject("This is a test subject") |
36 |
| - .withText("This is a test text.") |
37 |
| - .send(); |
38 |
| - assertEquals("{\"message\":\"success\"}", result); |
39 |
| - } |
| 28 | + @Test |
| 29 | + public void testSendSuccessBcc() { |
| 30 | + String result = Sendgrid |
| 31 | + .withCredentials(USERNAME, PASSWORD) |
| 32 | + .from(FROM_EMAIL) |
| 33 | + .to(TO_EMAIL) |
| 34 | + .bcc(TO_ANOTHER_EMAIL) |
| 35 | + .withSubject("This is a test subject") |
| 36 | + .withText("This is a test text.") |
| 37 | + .send(); |
| 38 | + assertEquals("{\"message\":\"success\"}", result); |
| 39 | + } |
40 | 40 |
|
41 |
| - @Test |
42 |
| - public void testSendSuccessWithAttachment() { |
43 |
| - File attachment = new File(getClass().getResource("/test.txt").getFile()); |
44 |
| - String result = Sendgrid |
45 |
| - .withCredentials(USERNAME, PASSWORD) |
46 |
| - .from(FROM_EMAIL) |
47 |
| - .to(TO_EMAIL) |
48 |
| - .withSubject("This is a test subject") |
49 |
| - .withText("This is a test text.") |
50 |
| - .withAttachment(attachment) |
51 |
| - .send(); |
52 |
| - assertEquals("{\"message\":\"success\"}", result); |
53 |
| - } |
| 41 | + @Test |
| 42 | + public void testSendSuccessWithAttachment() { |
| 43 | + File attachment = new File(getClass().getResource("/test.txt").getFile()); |
| 44 | + String result = Sendgrid |
| 45 | + .withCredentials(USERNAME, PASSWORD) |
| 46 | + .from(FROM_EMAIL) |
| 47 | + .to(TO_EMAIL) |
| 48 | + .withSubject("This is a test subject") |
| 49 | + .withText("This is a test text.") |
| 50 | + .withAttachment(attachment) |
| 51 | + .send(); |
| 52 | + assertEquals("{\"message\":\"success\"}", result); |
| 53 | + } |
54 | 54 |
|
55 |
| - @Test |
56 |
| - public void testSendSuccessWithMultipleRecipients() { |
57 |
| - String result = Sendgrid |
58 |
| - .withCredentials(USERNAME, PASSWORD) |
59 |
| - .from(FROM_EMAIL) |
60 |
| - .to(TO_EMAIL, TO_ANOTHER_EMAIL) |
61 |
| - .withSubject("This is a test subject") |
62 |
| - .withText("This is a test text.") |
63 |
| - .send(); |
64 |
| - assertEquals("{\"message\":\"success\"}", result); |
65 |
| - } |
| 55 | + @Test |
| 56 | + public void testSendSuccessWithMultipleRecipients() { |
| 57 | + String result = Sendgrid |
| 58 | + .withCredentials(USERNAME, PASSWORD) |
| 59 | + .from(FROM_EMAIL) |
| 60 | + .to(TO_EMAIL, TO_ANOTHER_EMAIL) |
| 61 | + .withSubject("This is a test subject") |
| 62 | + .withText("This is a test text.") |
| 63 | + .send(); |
| 64 | + assertEquals("{\"message\":\"success\"}", result); |
| 65 | + } |
66 | 66 |
|
67 |
| - @Test |
68 |
| - public void testSendWithoutFrom() { |
69 |
| - String result = Sendgrid |
70 |
| - .withCredentials(USERNAME, PASSWORD) |
71 |
| - .to(TO_EMAIL) |
72 |
| - .withSubject("This is a test subject") |
73 |
| - .withText("This is a test text.") |
74 |
| - .send(); |
75 |
| - assertEquals("{\"message\": \"error\", \"errors\": [\"Empty from email address (required)\"]}", result); |
76 |
| - } |
| 67 | + @Test |
| 68 | + public void testSendWithoutFrom() { |
| 69 | + String result = Sendgrid |
| 70 | + .withCredentials(USERNAME, PASSWORD) |
| 71 | + .to(TO_EMAIL) |
| 72 | + .withSubject("This is a test subject") |
| 73 | + .withText("This is a test text.") |
| 74 | + .send(); |
| 75 | + assertEquals("{\"message\": \"error\", \"errors\": [\"Empty from email address (required)\"]}", result); |
| 76 | + } |
77 | 77 | }
|
0 commit comments