forked from lob/lob-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckEditableTest.java
More file actions
executable file
·146 lines (139 loc) · 5.33 KB
/
Copy pathCheckEditableTest.java
File metadata and controls
executable file
·146 lines (139 loc) · 5.33 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
143
144
145
146
package Model;
import com.lob.model.CheckEditable;
import com.lob.model.AddressDomestic;
import com.lob.model.AddressEditable;
import java.util.HashMap;
import java.util.Map;
import com.google.gson.Gson;
import org.testng.annotations.*;
import java.time.OffsetDateTime;
import org.testng.Assert;
public class CheckEditableTest {
@DataProvider (name = "check-editable-data-provider")
public Object[][] checkEditableDpMethod(){
return new Object[][] {
{"from", new AddressDomestic()},
{"to", new AddressDomestic()},
{"bank_account", "fake account"},
{"amount", 147480.18d},
{"logo", "fake logo"},
{"check_bottom", "fake bottom"},
{"attachment", "fake attachment"},
{"description", "fake description"},
{"metadata", new HashMap<String, String>()},
{"merge_variables", new Object()},
{"send_date",OffsetDateTime.now()},
{"mail_type", CheckEditable.MailTypeEnum.USPS_FIRST_CLASS},
{"memo", "fake memo"},
{"check_number", 123456},
{"message", "fake message"},
{"billing_group_id", "fake billing group"},
};
}
@Test(enabled=true, dataProvider = "check-editable-data-provider")
public void checkEditableTestWithProvidedValue(String prop, Object val) throws Exception {
CheckEditable rec = new CheckEditable();
Gson gson = new Gson();
switch (prop) {
case "from": {
AddressDomestic castedVal = (AddressDomestic)val;
rec.setFrom(castedVal);
Assert.assertEquals(rec.getFrom(), gson.toJson(castedVal));
break;
}
case "to": {
AddressDomestic castedVal = (AddressDomestic)val;
rec.setTo(castedVal);
Assert.assertEquals(rec.getTo(), gson.toJson(castedVal));
break;
}
case "bank_account": {
String castedVal = (String)val;
rec.setBankAccount(castedVal);
Assert.assertEquals(rec.getBankAccount(), castedVal);
break;
}
case "amount": {
Double castedVal = (Double)val;
rec.setAmount(castedVal);
Assert.assertEquals(rec.getAmount(), castedVal);
break;
}
case "logo": {
String castedVal = (String)val;
rec.setLogo(castedVal);
Assert.assertEquals(rec.getLogo(), castedVal);
break;
}
case "check_bottom": {
String castedVal = (String)val;
rec.setCheckBottom(castedVal);
Assert.assertEquals(rec.getCheckBottom(), castedVal);
break;
}
case "attachment": {
String castedVal = (String)val;
rec.setAttachment(castedVal);
Assert.assertEquals(rec.getAttachment(), castedVal);
break;
}
case "description": {
String castedVal = (String)val;
rec.setDescription(castedVal);
Assert.assertEquals(rec.getDescription(), castedVal);
break;
}
case "metadata": {
@SuppressWarnings("unchecked")
Map<String, String> castedVal = (HashMap<String, String>)val;
rec.setMetadata(castedVal);
Assert.assertEquals(rec.getMetadata(), castedVal);
break;
}
case "merge_variables": {
Object castedVal = (Object)val;
rec.setMergeVariables(castedVal);
Assert.assertEquals(rec.getMergeVariables(), castedVal);
break;
}
case "mail_type": {
CheckEditable.MailTypeEnum castedVal = (CheckEditable.MailTypeEnum)val;
rec.setMailType(castedVal);
Assert.assertEquals(rec.getMailType(), castedVal);
break;
}
case "memo": {
String castedVal = (String)val;
rec.setMemo(castedVal);
Assert.assertEquals(rec.getMemo(), castedVal);
break;
}
case "check_number": {
Integer castedVal = (Integer)val;
rec.setCheckNumber(castedVal);
Assert.assertEquals(rec.getCheckNumber(), castedVal);
break;
}
case "message": {
String castedVal = (String)val;
rec.setMessage(castedVal);
Assert.assertEquals(rec.getMessage(), castedVal);
break;
}
case "billing_group_id": {
String castedVal = (String)val;
rec.setBillingGroupId(castedVal);
Assert.assertEquals(rec.getBillingGroupId(), castedVal);
break;
}
case "send_date": {
OffsetDateTime castedVal = (OffsetDateTime) val;
rec.setSendDate(castedVal);
Assert.assertEquals(rec.getSendDate(), castedVal);
break;
}
default:
throw new Exception("Wrong prop name");
}
}
}