Repository navigation
Expand file tree
/
Copy pathSendGridTest.java
More file actions
142 lines (97 loc) · 3.13 KB
/
Copy pathSendGridTest.java
File metadata and controls
142 lines (97 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package com.sendgrid;
import org.json.JSONException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.io.File;
import java.io.InputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import org.junit.Test;
import org.junit.Before;
import static org.junit.Assert.*;
import static org.junit.matchers.JUnitMatchers.hasItems;
public class SendGridTest {
SendGrid.Email email;
private static final String USERNAME = "USERNAME";
private static final String PASSWORD = "PASSWORD";
@Test public void testAddTo() {
email = new SendGrid.Email();
String address = "email@example.com";
String address2 = "email2@example.com";
email.addTo(address);
email.addTo(address2);
String[] correct = {address, address2};
assertArrayEquals(correct, email.getTos());
}
@Test public void testAddToWithAFrom() {
email = new SendGrid.Email();
String address = "email@example.com";
String fromaddress = "from@mailinator.com";
email.addTo(address);
email.setFrom(fromaddress);
String[] correct = {address};
assertArrayEquals(correct, email.getTos());
assertEquals(fromaddress, email.getFrom());
}
@Test public void testAddToName() {
email = new SendGrid.Email();
String name = "John";
email.addToName(name);
String[] correct = {name};
assertArrayEquals(correct, email.getToNames());
}
@Test public void testSetFrom() {
email = new SendGrid.Email();
String address = "email@example.com";
email.setFrom(address);
assertEquals(address, email.getFrom());
}
@Test public void testSetFromName() {
email = new SendGrid.Email();
String fromname = "Uncle Bob";
email.setFromName(fromname);
assertEquals(fromname, email.getFromName());
}
@Test public void testSetReplyTo() {
email = new SendGrid.Email();
String address = "email@example.com";
email.setReplyTo(address);
assertEquals(address, email.getReplyTo());
}
@Test public void testAddBcc() {
email = new SendGrid.Email();
String address = "email@example.com";
email.addBcc(address);
String[] correct = {address};
assertArrayEquals(correct, email.getBccs());
}
@Test public void testSetSubject() {
email = new SendGrid.Email();
String subject = "This is a subject";
email.setSubject(subject);
assertEquals(subject, email.getSubject());
}
@Test public void testSetText() {
email = new SendGrid.Email();
String text = "This is some email text.";
email.setText(text);
assertEquals(text, email.getText());
}
@Test public void testSetHtml() {
email = new SendGrid.Email();
String html = "This is some email text.";
email.setHtml(html);
assertEquals(html, email.getHtml());
}
@Test public void testAddHeader() {
email = new SendGrid.Email();
email.addHeader("key", "value");
email.addHeader("other", "other-value");
Map<String, String> correct = new HashMap<String, String>();
correct.put("key", "value");
correct.put("other", "other-value");
assertEquals(correct, email.getHeaders());
}
}