Skip to content

Commit ebe2021

Browse files
authored
Merge pull request #96 from tfung/hacktoberfest-tfung
Increasing code coverage #hacktoberfest
2 parents 4984d8a + 4980327 commit ebe2021

File tree

2 files changed

+226
-0
lines changed

2 files changed

+226
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2019 Intuit
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*******************************************************************************/
16+
package com.intuit.payment.data;
17+
18+
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
19+
import org.testng.Assert;
20+
import org.testng.annotations.BeforeMethod;
21+
import org.testng.annotations.BeforeTest;
22+
import org.testng.annotations.Test;
23+
24+
import java.util.Date;
25+
26+
/**
27+
* @author tfung
28+
*/
29+
public class CvcVerificationTest {
30+
31+
private String result;
32+
private Date date;
33+
34+
private CvcVerification cvcVerification;
35+
36+
@BeforeTest
37+
public void init() {
38+
this.result = "result";
39+
this.date = new Date(01/31/2019);
40+
}
41+
42+
@BeforeMethod
43+
public void setUp() {
44+
cvcVerification = new CvcVerification.Builder()
45+
.result(result)
46+
.date(date)
47+
.build();
48+
}
49+
50+
@Test
51+
public void testAllGetters() {
52+
Assert.assertEquals(cvcVerification.getResult(), result);
53+
Assert.assertEquals(cvcVerification.getDate(), date);
54+
}
55+
56+
@Test
57+
public void testAllSetters() {
58+
String newResult = "new result";
59+
Date newDate = new Date(02/28/2019);
60+
61+
cvcVerification.setResult(newResult);
62+
cvcVerification.setDate(newDate);
63+
64+
Assert.assertEquals(cvcVerification.getResult(), newResult);
65+
Assert.assertEquals(cvcVerification.getDate(), newDate);
66+
}
67+
68+
@Test
69+
public void testToString() {
70+
String expectedResult = ReflectionToStringBuilder.toString(cvcVerification);
71+
String actualResult = cvcVerification.toString();
72+
Assert.assertTrue(actualResult.contains(expectedResult));
73+
}
74+
}
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2019 Intuit
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*******************************************************************************/
16+
package com.intuit.payment.data;
17+
18+
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
19+
import org.testng.Assert;
20+
import org.testng.annotations.BeforeMethod;
21+
import org.testng.annotations.BeforeTest;
22+
import org.testng.annotations.Test;
23+
24+
import java.math.BigDecimal;
25+
import java.util.Date;
26+
27+
/**
28+
* @author tfung
29+
*/
30+
public class ECheckTest {
31+
private String id;
32+
private Date created;
33+
private String authCode;
34+
private ECheck.ECheckStatus status;
35+
private BigDecimal amount;
36+
private BankAccount bankAccount;
37+
private String token;
38+
private String bankAccountOnFile;
39+
private CheckContext context;
40+
private ECheck.PaymentModeType paymentMode;
41+
private String description;
42+
private String checkNumber;
43+
44+
private ECheck echeck;
45+
46+
@BeforeTest
47+
public void init() {
48+
id = "id";
49+
created = new Date(01/31/2019);
50+
authCode = "authCode";
51+
status = ECheck.ECheckStatus.SUCCEEDED;
52+
amount = new BigDecimal(100000);
53+
token = "token";
54+
bankAccountOnFile = "bankAccountOnFile";
55+
context = new CheckContext();
56+
paymentMode = ECheck.PaymentModeType.WEB;
57+
description = "description";
58+
checkNumber = "checkNumber";
59+
60+
bankAccount = new BankAccount.Builder()
61+
.id("bankAccountId")
62+
.build();
63+
}
64+
65+
@BeforeMethod
66+
public void setUp() {
67+
echeck = new ECheck.Builder()
68+
.id(id)
69+
.created(created)
70+
.authCode(authCode)
71+
.status(status)
72+
.amount(amount)
73+
.bankAccount(bankAccount)
74+
.token(token)
75+
.bankAccountOnFile(bankAccountOnFile)
76+
.context(context)
77+
.paymentMode(paymentMode)
78+
.description(description)
79+
.checkNumber(checkNumber)
80+
.build();
81+
}
82+
83+
@Test
84+
public void testAllGetters() {
85+
Assert.assertEquals(echeck.getId(), id);
86+
Assert.assertEquals(echeck.getCreated(), created);
87+
Assert.assertEquals(echeck.getAuthCode(), authCode);
88+
Assert.assertEquals(echeck.getStatus(), status);
89+
Assert.assertEquals(echeck.getAmount(), amount);
90+
Assert.assertEquals(echeck.getBankAccount(), bankAccount);
91+
Assert.assertEquals(echeck.getToken(), token);
92+
Assert.assertEquals(echeck.getBankAccountOnFile(), bankAccountOnFile);
93+
Assert.assertEquals(echeck.getContext(), context);
94+
Assert.assertEquals(echeck.getPaymentMode(), paymentMode);
95+
Assert.assertEquals(echeck.getDescription(), description);
96+
Assert.assertEquals(echeck.getCheckNumber(), checkNumber);
97+
}
98+
99+
@Test
100+
public void testAllSetters() {
101+
String newId = "new id";
102+
Date newCreated = new Date(02/28/2019);
103+
String newAuthCode = "new authCode";
104+
ECheck.ECheckStatus newStatus = ECheck.ECheckStatus.DECLINED;
105+
BigDecimal newAmount = new BigDecimal(200000);
106+
String newToken = "new token";
107+
String newBankAccountOnFile = "new bankAccountOnFile";
108+
ECheck.PaymentModeType newPaymentMode = null;
109+
String newDescription = "new description";
110+
String newCheckNumber = "new checkNumber";
111+
112+
CheckContext newContext = new CheckContext();
113+
newContext.setRequestId("requestId");
114+
115+
BankAccount newBankAccount = new BankAccount.Builder()
116+
.id("bankAccountId 2")
117+
.build();
118+
119+
echeck.setId(newId);
120+
echeck.setCreated(newCreated);
121+
echeck.setAuthCode(newAuthCode);
122+
echeck.setStatus(newStatus);
123+
echeck.setAmount(newAmount);
124+
echeck.setBankAccount(newBankAccount);
125+
echeck.setToken(newToken);
126+
echeck.setBankAccountOnFile(newBankAccountOnFile);
127+
echeck.setContext(newContext);
128+
echeck.setPaymentMode(newPaymentMode);
129+
echeck.setDescription(newDescription);
130+
echeck.setCheckNumber(newCheckNumber);
131+
132+
Assert.assertEquals(echeck.getId(), newId);
133+
Assert.assertEquals(echeck.getCreated(), newCreated);
134+
Assert.assertEquals(echeck.getAuthCode(), newAuthCode);
135+
Assert.assertEquals(echeck.getStatus(), newStatus);
136+
Assert.assertEquals(echeck.getAmount(), newAmount);
137+
Assert.assertEquals(echeck.getBankAccount(), newBankAccount);
138+
Assert.assertEquals(echeck.getToken(), newToken);
139+
Assert.assertEquals(echeck.getBankAccountOnFile(), newBankAccountOnFile);
140+
Assert.assertEquals(echeck.getContext(), newContext);
141+
Assert.assertEquals(echeck.getPaymentMode(), newPaymentMode);
142+
Assert.assertEquals(echeck.getDescription(), newDescription);
143+
Assert.assertEquals(echeck.getCheckNumber(), newCheckNumber);
144+
}
145+
146+
@Test
147+
public void testToString() {
148+
String expectedResult = ReflectionToStringBuilder.toString(echeck);
149+
String actualResult = echeck.toString();
150+
Assert.assertTrue(actualResult.contains(expectedResult));
151+
}
152+
}

0 commit comments

Comments
 (0)