-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathBankAccountTest.java
More file actions
executable file
·168 lines (157 loc) · 6.06 KB
/
Copy pathBankAccountTest.java
File metadata and controls
executable file
·168 lines (157 loc) · 6.06 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package Model;
import com.lob.model.BankAccount;
import org.testng.annotations.*;
import org.testng.Assert;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
import Helper.*;
@SuppressWarnings("unchecked")
public class BankAccountTest {
@DataProvider (name = "bank-account-data-provider")
public Object[][] bankAccountDpMethod() {
return new Object[][] {
{"id", "bank_fakeId"},
{"description", "fake description"},
{"routing_number", "fake routing"},
{"account_number", "fake account"},
{"account_type", BankAccount.AccountTypeEnum.COMPANY},
{"account_type", BankAccount.AccountTypeEnum.INDIVIDUAL},
{"signatory", "fake signatory"},
{"metadata", new HashMap<String, String>()},
{"signature_url", new TestFixtures().get_URL_VALID()},
{"bank_name", "Bank"},
{"verified", false},
{"verified", true},
{"date_created", OffsetDateTime.now()},
{"date_modified", OffsetDateTime.now()},
{"deleted", false},
{"deleted", true},
{"object", BankAccount.ObjectEnum.BANK_ACCOUNT},
{"microdeposit_type", "amounts"},
{"microdeposit_type", "descriptor_code"},
};
}
@Test(enabled=true, dataProvider = "bank-account-data-provider")
public void bankAccountTestWithProvidedValue(String prop, Object val) throws Exception {
BankAccount rec = new BankAccount();
switch (prop) {
case "id": {
String castedVal = (String)val;
rec.setId(castedVal);
Assert.assertEquals(rec.getId(), castedVal);
break;
}
case "description": {
String castedVal = (String)val;
rec.setDescription(castedVal);
Assert.assertEquals(rec.getDescription(), castedVal);
break;
}
case "routing_number": {
String castedVal = (String)val;
rec.setRoutingNumber(castedVal);
Assert.assertEquals(rec.getRoutingNumber(), castedVal);
break;
}
case "account_number": {
String castedVal = (String)val;
rec.setAccountNumber(castedVal);
Assert.assertEquals(rec.getAccountNumber(), castedVal);
break;
}
case "account_type": {
BankAccount.AccountTypeEnum castedVal = (BankAccount.AccountTypeEnum)val;
rec.setAccountType(castedVal);
Assert.assertEquals(rec.getAccountType(), castedVal);
break;
}
case "signatory": {
String castedVal = (String)val;
rec.setSignatory(castedVal);
Assert.assertEquals(rec.getSignatory(), castedVal);
break;
}
case "metadata": {
Map<String, String> castedVal = (HashMap<String, String>)val;
rec.setMetadata(castedVal);
Assert.assertEquals(rec.getMetadata(), castedVal);
break;
}
case "signature_url": {
String castedVal = (String)val;
rec.setSignatureUrl(castedVal);
Assert.assertEquals(rec.getSignatureUrl(), castedVal);
break;
}
case "bank_name": {
String castedVal = (String)val;
rec.setBankName(castedVal);
Assert.assertEquals(rec.getBankName(), castedVal);
break;
}
case "verified": {
Boolean castedVal = (Boolean)val;
rec.setVerified(castedVal);
Assert.assertEquals(rec.getVerified(), castedVal);
break;
}
case "date_created": {
OffsetDateTime castedVal = (OffsetDateTime)val;
rec.setDateCreated(castedVal);
Assert.assertEquals(rec.getDateCreated(), castedVal);
break;
}
case "date_modified": {
OffsetDateTime castedVal = (OffsetDateTime)val;
rec.setDateModified(castedVal);
Assert.assertEquals(rec.getDateModified(), castedVal);
break;
}
case "deleted": {
Boolean castedVal = (Boolean)val;
rec.setDeleted(castedVal);
Assert.assertEquals(rec.getDeleted(), castedVal);
break;
}
case "object": {
BankAccount.ObjectEnum castedVal = (BankAccount.ObjectEnum)val;
rec.setObject(castedVal);
Assert.assertEquals(rec.getObject(), castedVal);
break;
}
case "microdeposit_type": {
String castedVal = (String)val;
rec.setMicrodepositType(castedVal);
Assert.assertEquals(rec.getMicrodepositType(), castedVal);
break;
}
default:
throw new Exception("Wrong prop name: " + prop);
}
}
@Test(enabled=true)
public void bankAccountTestCatchesInvalidId() {
BankAccount rec = new BankAccount();
Assert.assertNull(rec.getId());
String invalidValue = "Nope";
try {
rec.setId(invalidValue);
throw new Exception("Should Throw");
} catch (Exception err) {
Assert.assertEquals(err.getMessage(), "Invalid id provided");
}
}
@Test(enabled=true)
public void bankAccountTestCatchesInvalidSignatureUrl() {
BankAccount rec = new BankAccount();
Assert.assertNull(rec.getSignatureUrl());
String invalidValue = "Nope";
try {
rec.setSignatureUrl(invalidValue);
throw new Exception("Should Throw");
} catch (Exception err) {
Assert.assertEquals(err.getMessage(), "Invalid signature_url provided");
}
}
}