Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.intuit.payment.data;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.List;

/**
* @author crystal-chung
*/
public class QueryResponseTest {

private List<BankAccount> bankAccounts;
private List<Card> cards;
private QueryResponse queryResponse;

@BeforeTest
public void init() {
bankAccounts = new ArrayList<>();
cards = new ArrayList<>();
}

@BeforeMethod
public void setUp() {
queryResponse = new QueryResponse.Builder()
.bankAccounts(bankAccounts)
.cards(cards)
.build();
}

@Test
public void testAllGetters() {
Assert.assertEquals(queryResponse.getBankAccounts(), bankAccounts);
Assert.assertEquals(queryResponse.getCards(), cards);
}

@Test
public void testAllSetters() {
List<BankAccount> newBankAccounts = new ArrayList<>();
List<Card> newCards = new ArrayList<>();

BankAccount newBankAccount = new BankAccount();
Card newCard = new Card.Builder().expYear("2020").expMonth("02").build();

newBankAccounts.add(newBankAccount);
newCards.add(newCard);

queryResponse.setBankAccounts(newBankAccounts);
queryResponse.setCards(newCards);

Assert.assertEquals(queryResponse.getBankAccounts(), newBankAccounts);
Assert.assertEquals(queryResponse.getCards(), newCards);
}

@Test
public void testToString() {
String expectedResult = ReflectionToStringBuilder.toString(queryResponse);
String actualResult = queryResponse.toString();
Assert.assertTrue(actualResult.contains(expectedResult));
}
}
61 changes: 61 additions & 0 deletions payments-api/src/test/java/com/intuit/payment/data/TokenTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.intuit.payment.data;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

/**
* @author crystal-chung
*/
public class TokenTest {
private Card card;
private BankAccount bankAccount;
private String value;
private Token token;

@BeforeTest
public void init() {
card = new Card();
bankAccount = new BankAccount();
value = "token value";
}

@BeforeMethod
public void setUp() {
token = new Token.Builder()
.card(card)
.bankAccount(bankAccount)
.value(value)
.build();
}

@Test
public void testAllGetters() {
Assert.assertEquals(token.getCard(), card);
Assert.assertEquals(token.getBankAccount(), bankAccount);
Assert.assertEquals(token.getValue(), value);
}

@Test
public void testAllSetters() {
Card newCard = new Card.Builder().expYear("2020").expMonth("02").build();
BankAccount newBankAccount = new BankAccount();
String newValue = "new token value";

token.setCard(newCard);
token.setBankAccount(newBankAccount);
token.setValue(newValue);

Assert.assertEquals(token.getCard(), newCard);
Assert.assertEquals(token.getBankAccount(), newBankAccount);
Assert.assertEquals(token.getValue(), newValue);
}

@Test
public void testToString() {
String expectedResult = ReflectionToStringBuilder.toString(token);
String actualResult = token.toString();
Assert.assertTrue(actualResult.contains(expectedResult));
}
}