Skip to content

Commit 96d559c

Browse files
authored
Merge pull request #93 from crystal-chung/develop
Increasing code coverage #hacktoberfest
2 parents f2c730c + 0fef4e8 commit 96d559c

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.intuit.payment.data;
2+
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
3+
import org.testng.Assert;
4+
import org.testng.annotations.BeforeMethod;
5+
import org.testng.annotations.BeforeTest;
6+
import org.testng.annotations.Test;
7+
8+
import java.util.ArrayList;
9+
import java.util.List;
10+
11+
/**
12+
* @author crystal-chung
13+
*/
14+
public class QueryResponseTest {
15+
16+
private List<BankAccount> bankAccounts;
17+
private List<Card> cards;
18+
private QueryResponse queryResponse;
19+
20+
@BeforeTest
21+
public void init() {
22+
bankAccounts = new ArrayList<>();
23+
cards = new ArrayList<>();
24+
}
25+
26+
@BeforeMethod
27+
public void setUp() {
28+
queryResponse = new QueryResponse.Builder()
29+
.bankAccounts(bankAccounts)
30+
.cards(cards)
31+
.build();
32+
}
33+
34+
@Test
35+
public void testAllGetters() {
36+
Assert.assertEquals(queryResponse.getBankAccounts(), bankAccounts);
37+
Assert.assertEquals(queryResponse.getCards(), cards);
38+
}
39+
40+
@Test
41+
public void testAllSetters() {
42+
List<BankAccount> newBankAccounts = new ArrayList<>();
43+
List<Card> newCards = new ArrayList<>();
44+
45+
BankAccount newBankAccount = new BankAccount();
46+
Card newCard = new Card.Builder().expYear("2020").expMonth("02").build();
47+
48+
newBankAccounts.add(newBankAccount);
49+
newCards.add(newCard);
50+
51+
queryResponse.setBankAccounts(newBankAccounts);
52+
queryResponse.setCards(newCards);
53+
54+
Assert.assertEquals(queryResponse.getBankAccounts(), newBankAccounts);
55+
Assert.assertEquals(queryResponse.getCards(), newCards);
56+
}
57+
58+
@Test
59+
public void testToString() {
60+
String expectedResult = ReflectionToStringBuilder.toString(queryResponse);
61+
String actualResult = queryResponse.toString();
62+
Assert.assertTrue(actualResult.contains(expectedResult));
63+
}
64+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.intuit.payment.data;
2+
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
3+
import org.testng.Assert;
4+
import org.testng.annotations.BeforeMethod;
5+
import org.testng.annotations.BeforeTest;
6+
import org.testng.annotations.Test;
7+
8+
/**
9+
* @author crystal-chung
10+
*/
11+
public class TokenTest {
12+
private Card card;
13+
private BankAccount bankAccount;
14+
private String value;
15+
private Token token;
16+
17+
@BeforeTest
18+
public void init() {
19+
card = new Card();
20+
bankAccount = new BankAccount();
21+
value = "token value";
22+
}
23+
24+
@BeforeMethod
25+
public void setUp() {
26+
token = new Token.Builder()
27+
.card(card)
28+
.bankAccount(bankAccount)
29+
.value(value)
30+
.build();
31+
}
32+
33+
@Test
34+
public void testAllGetters() {
35+
Assert.assertEquals(token.getCard(), card);
36+
Assert.assertEquals(token.getBankAccount(), bankAccount);
37+
Assert.assertEquals(token.getValue(), value);
38+
}
39+
40+
@Test
41+
public void testAllSetters() {
42+
Card newCard = new Card.Builder().expYear("2020").expMonth("02").build();
43+
BankAccount newBankAccount = new BankAccount();
44+
String newValue = "new token value";
45+
46+
token.setCard(newCard);
47+
token.setBankAccount(newBankAccount);
48+
token.setValue(newValue);
49+
50+
Assert.assertEquals(token.getCard(), newCard);
51+
Assert.assertEquals(token.getBankAccount(), newBankAccount);
52+
Assert.assertEquals(token.getValue(), newValue);
53+
}
54+
55+
@Test
56+
public void testToString() {
57+
String expectedResult = ReflectionToStringBuilder.toString(token);
58+
String actualResult = token.toString();
59+
Assert.assertTrue(actualResult.contains(expectedResult));
60+
}
61+
}

0 commit comments

Comments
 (0)