-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathSelfMailerEditableTest.java
More file actions
115 lines (109 loc) · 4.21 KB
/
Copy pathSelfMailerEditableTest.java
File metadata and controls
115 lines (109 loc) · 4.21 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
package Model;
import java.util.HashMap;
import java.util.Map;
import com.google.gson.Gson;
import com.lob.model.AddressEditable;
import com.lob.model.MailType;
import com.lob.model.SelfMailerEditable;
import com.lob.model.SelfMailerSize;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.time.OffsetDateTime;
@SuppressWarnings("unchecked")
public class SelfMailerEditableTest {
@DataProvider (name = "self-mailer-editable-data-provider")
public Object[][] selfMailerEditableDpMethod(){
return new Object[][] {
{"to", new AddressEditable()},
{"from", new AddressEditable()},
{"size", SelfMailerSize._11X9_BIFOLD},
{"size", SelfMailerSize._12X9_BIFOLD},
{"size", SelfMailerSize._6X18_BIFOLD},
{"description", "fake description"},
{"metadata", new HashMap<String, String>()},
{"mail_type", MailType.STANDARD},
{"mail_type", MailType.FIRST_CLASS},
{"merge_variables", new Object()},
{"send_date", OffsetDateTime.now()},
{"inside", "fake inside"},
{"outside", "fake outside"},
{"billing_group_id", "fake billing_group_id"},
};
}
@Test(enabled=true, dataProvider = "self-mailer-editable-data-provider")
public void selfMailerEditableTestWithProvidedValue(String prop, Object val) throws Exception {
SelfMailerEditable rec = new SelfMailerEditable();
Gson gson = new Gson();
switch (prop) {
case "to": {
AddressEditable castedVal = (AddressEditable)val;
rec.setTo(castedVal);
Assert.assertEquals(rec.getTo(), gson.toJson(castedVal));
break;
}
case "from": {
AddressEditable castedVal = (AddressEditable)val;
rec.setFrom(castedVal);
Assert.assertEquals(rec.getFrom(), gson.toJson(castedVal));
break;
}
case "size": {
SelfMailerSize castedVal = (SelfMailerSize)val;
rec.setSize(castedVal);
Assert.assertEquals(rec.getSize(), castedVal);
break;
}
case "description": {
String castedVal = (String)val;
rec.setDescription(castedVal);
Assert.assertEquals(rec.getDescription(), castedVal);
break;
}
case "metadata": {
Map<String, String> castedVal = (HashMap<String, String>)val;
rec.setMetadata(castedVal);
Assert.assertEquals(rec.getMetadata(), castedVal);
break;
}
case "mail_type": {
MailType castedVal = (MailType)val;
rec.setMailType(castedVal);
Assert.assertEquals(rec.getMailType(), castedVal);
break;
}
case "merge_variables": {
Object castedVal = (Object)val;
rec.setMergeVariables(castedVal);
Assert.assertEquals(rec.getMergeVariables(), castedVal);
break;
}
case "send_date": {
OffsetDateTime castedVal = (OffsetDateTime) val;
rec.setSendDate(castedVal);
Assert.assertEquals(rec.getSendDate(), castedVal);
break;
}
case "inside": {
String castedVal = (String)val;
rec.setInside(castedVal);
Assert.assertEquals(rec.getInside(), castedVal);
break;
}
case "outside": {
String castedVal = (String)val;
rec.setOutside(castedVal);
Assert.assertEquals(rec.getOutside(), castedVal);
break;
}
case "billing_group_id": {
String castedVal = (String)val;
rec.setBillingGroupId(castedVal);
Assert.assertEquals(rec.getBillingGroupId(), castedVal);
break;
}
default:
throw new Exception("Wrong prop name: " + prop);
}
}
}