1+ package com .intuit .payment .data ;
2+
3+ import org .apache .commons .lang .builder .ReflectionToStringBuilder ;
4+ import org .testng .Assert ;
5+ import org .testng .annotations .BeforeMethod ;
6+ import org .testng .annotations .BeforeTest ;
7+ import org .testng .annotations .Test ;
8+
9+ import java .util .Date ;
10+ import com .intuit .payment .data .BankAccount .BankAccountInputTypeEnum ;
11+ import com .intuit .payment .data .BankAccount .AccountType ;
12+
13+ /**
14+ * @author enzozafra
15+ */
16+ public class BankAccountTest {
17+ private String id ;
18+ private String name ;
19+ private Date created ;
20+ private Date updated ;
21+ private BankAccountInputTypeEnum inputType ;
22+ private String routingNumber ;
23+ private String accountNumber ;
24+ private AccountType accountType ;
25+ private String phone ;
26+ private Boolean defaultValue ;
27+ private String country ;
28+ private String bankCode ;
29+ private String entityId ;
30+ private String entityType ;
31+ private String entityVersion ;
32+
33+ private BankAccount bankAccount ;
34+
35+ @ BeforeTest
36+ public void init () {
37+ id = "id" ;
38+ name = "name" ;
39+ created = new Date (1220227200 );
40+ updated = new Date (1220832000 );
41+ inputType = BankAccountInputTypeEnum .KEYED ;
42+ routingNumber = "12311" ;
43+ accountNumber = "123123123" ;
44+ accountType = AccountType .PERSONAL_CHECKING ;
45+ phone = "5871231234" ;
46+ defaultValue = true ;
47+ country = "country" ;
48+ bankCode = "1221" ;
49+ entityId = "entityId" ;
50+ entityType = "entityType" ;
51+ entityVersion = "entityVersion" ;
52+ }
53+
54+ @ BeforeMethod
55+ public void setUp () {
56+ bankAccount = new BankAccount .Builder ()
57+ .id (id )
58+ .name (name )
59+ .created (created )
60+ .updated (updated )
61+ .inputType (inputType )
62+ .routingNumber (routingNumber )
63+ .accountNumber (accountNumber )
64+ .accountType (accountType )
65+ .phone (phone )
66+ .defaultValue (defaultValue )
67+ .country (country )
68+ .bankCode (bankCode )
69+ .entityId (entityId )
70+ .entityType (entityType )
71+ .entityVersion (entityVersion )
72+ .build ();
73+
74+ }
75+
76+ @ Test
77+ public void testAllGetters () {
78+ Assert .assertEquals (bankAccount .getId (), id );
79+ Assert .assertEquals (bankAccount .getName (), name );
80+ Assert .assertEquals (bankAccount .getCreated (), created );
81+ Assert .assertEquals (bankAccount .getUpdated (), updated );
82+ Assert .assertEquals (bankAccount .getInputType (), inputType );
83+ Assert .assertEquals (bankAccount .getRoutingNumber (), routingNumber );
84+ Assert .assertEquals (bankAccount .getAccountNumber (), accountNumber );
85+ Assert .assertEquals (bankAccount .getPhone (), phone );
86+ Assert .assertEquals (bankAccount .getDefaultValue (), defaultValue );
87+ Assert .assertEquals (bankAccount .getCountry (), country );
88+ Assert .assertEquals (bankAccount .getBankCode (), bankCode );
89+ Assert .assertEquals (bankAccount .getEntityId (), entityId );
90+ Assert .assertEquals (bankAccount .getEntityType (), entityType );
91+ Assert .assertEquals (bankAccount .getEntityVersion (), entityVersion );
92+ }
93+
94+ @ Test
95+ public void testAllSetters () {
96+ String newId = "new id" ;
97+ String newName = "new name" ;
98+ Date newCreated = new Date (1220832000 );
99+ Date newUpdated = new Date (1220227200 );
100+ // set to null because there is no second option
101+ BankAccountInputTypeEnum newInputType = null ;
102+ String newRoutingNumber = "11321" ;
103+ String newAccountNumber = "45655623" ;
104+ AccountType newAccountType = AccountType .PERSONAL_SAVINGS ;
105+ String newPhone = "1231231231" ;
106+ Boolean newDefaultValue = false ;
107+ String newCountry = "new country" ;
108+ String newBankCode = "1234" ;
109+ String newEntityId = "new entityId" ;
110+ String newEntityType = "new entityType" ;
111+ String newEntityVersion = "new entityVersion" ;
112+
113+ bankAccount .setId (newId );
114+ bankAccount .setName (newName );
115+ bankAccount .setCreated (newCreated );
116+ bankAccount .setUpdated (newUpdated );
117+ bankAccount .setInputType (newInputType );
118+ bankAccount .setRoutingNumber (newRoutingNumber );
119+ bankAccount .setAccountNumber (newAccountNumber );
120+ bankAccount .setAccountType (newAccountType );
121+ bankAccount .setPhone (newPhone );
122+ bankAccount .setDefaultValue (newDefaultValue );
123+ bankAccount .setCountry (newCountry );
124+ bankAccount .setBankCode (newBankCode );
125+ bankAccount .setEntityId (newEntityId );
126+ bankAccount .setEntityType (newEntityType );
127+ bankAccount .setEntityVersion (newEntityVersion );
128+
129+ Assert .assertEquals (bankAccount .getId (), newId );
130+ Assert .assertEquals (bankAccount .getName (), newName );
131+ Assert .assertEquals (bankAccount .getCreated (), newCreated );
132+ Assert .assertEquals (bankAccount .getUpdated (), newUpdated );
133+ Assert .assertEquals (bankAccount .getInputType (), newInputType );
134+ Assert .assertEquals (bankAccount .getRoutingNumber (), newRoutingNumber );
135+ Assert .assertEquals (bankAccount .getAccountNumber (), newAccountNumber );
136+ Assert .assertEquals (bankAccount .getPhone (), newPhone );
137+ Assert .assertEquals (bankAccount .getDefaultValue (), newDefaultValue );
138+ Assert .assertEquals (bankAccount .getCountry (), newCountry );
139+ Assert .assertEquals (bankAccount .getBankCode (), newBankCode );
140+ Assert .assertEquals (bankAccount .getEntityId (), newEntityId );
141+ Assert .assertEquals (bankAccount .getEntityType (), newEntityType );
142+ Assert .assertEquals (bankAccount .getEntityVersion (), newEntityVersion );
143+ }
144+
145+ @ Test
146+ public void testToString () {
147+ // Since we cant mock ReflectionToStringBuilder without powermock
148+ String expectedResult = ReflectionToStringBuilder .toString (bankAccount );
149+ String actualResult = bankAccount .toString ();
150+ Assert .assertTrue (actualResult .contains (expectedResult ));
151+ }
152+ }
0 commit comments