|
| 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 | +} |
0 commit comments