use of com.fitpay.android.api.models.card.CreditCard in project fitpay-android-sdk by fitpay.
the class CreditCardTest2 method testDeleteCard.
@Test
public void testDeleteCard() throws Exception {
Device device = getTestDevice();
Device createdDevice = createDevice(user, device);
assertNotNull("created device", createdDevice);
Collections.DeviceCollection devices = getDevices(user);
assertNotNull("devices collection should not be null", devices);
assertEquals("should have one device", 1, devices.getTotalResults());
String pan = "9999504454545450";
CreditCard creditCard = getTestCreditCard(pan);
CreditCard createdCard = createCreditCard(user, creditCard);
assertNotNull("card not created", createdCard);
deleteCard(createdCard);
Collections.CreditCardCollection creditCards = getCreditCards(user);
assertNotNull("credit cards collection", creditCards);
assertEquals("number of credit cards", 0, creditCards.getTotalResults());
}
use of com.fitpay.android.api.models.card.CreditCard in project fitpay-android-sdk by fitpay.
the class CreditCardTest2 method testCantAddCreditCardWithNoDevice.
@Test
public void testCantAddCreditCardWithNoDevice() throws Exception {
String pan = "9999545454545454";
CreditCard creditCard = getTestCreditCard(pan);
final CountDownLatch latch = new CountDownLatch(1);
ResultProvidingCallback<CreditCard> callback = new ResultProvidingCallback<>(latch);
user.createCreditCard(creditCard, callback);
latch.await(TIMEOUT, TimeUnit.SECONDS);
CreditCard createdCard = callback.getResult();
assertNull("created card", createdCard);
assertEquals("error code", 400, callback.getErrorCode());
}
use of com.fitpay.android.api.models.card.CreditCard in project fitpay-android-sdk by fitpay.
the class CreditCardTest2 method testCanGetCards1.
@Test
public void testCanGetCards1() throws Exception {
Device device = getTestDevice();
Device createdDevice = createDevice(user, device);
assertNotNull("created device", createdDevice);
Collections.DeviceCollection devices = getDevices(user);
assertNotNull("devices collection should not be null", devices);
assertEquals("should have one device", 1, devices.getTotalResults());
String pan = "9999504454545450";
CreditCard creditCard = getTestCreditCard(pan);
CreditCard createdCard = createCreditCard(user, creditCard);
assertNotNull("card not created", createdCard);
Collections.CreditCardCollection creditCards = getCreditCards(user);
assertNotNull("credit cards collection", creditCards);
assertEquals("number of credit cards", 1, creditCards.getTotalResults());
assertEquals("credit card id", createdCard.getCreditCardId(), creditCards.getResults().get(0).getCreditCardId());
verifyCardContents(creditCard, creditCards.getResults().get(0));
}
use of com.fitpay.android.api.models.card.CreditCard in project fitpay-android-sdk by fitpay.
the class Steps method waitForActivation.
public void waitForActivation() throws InterruptedException {
Assert.assertNotNull("no currentCard is available to waitForActivation on", currentCard);
final List<String> errors = new ArrayList<>();
final boolean[] isCompleted = { false };
for (int x = 0; x < 20; x++) {
final CountDownLatch latch = new CountDownLatch(1);
currentCard.self(new ApiCallback<CreditCard>() {
@Override
public void onSuccess(CreditCard result) {
currentCard = result;
if ("ACTIVE".equals(result.getState())) {
isCompleted[0] = true;
}
latch.countDown();
}
@Override
public void onFailure(@ResultCode.Code int errorCode, String errorMessage) {
errors.add("error code: " + errorCode + ", message: " + errorMessage);
latch.countDown();
}
});
latch.await(TIMEOUT, TimeUnit.SECONDS);
assertTrue("error waiting on activation: " + errors, errors.size() == 0);
if (isCompleted[0]) {
return;
} else {
Thread.sleep(1000);
}
}
fail(currentCard + " never transitioned to ACTIVE");
}
use of com.fitpay.android.api.models.card.CreditCard in project fitpay-android-sdk by fitpay.
the class Steps method deleteTestCards.
public void deleteTestCards() throws InterruptedException {
getCards();
List<CreditCard> cards = cardsCollection.getResults();
int size = cards.size();
final CountDownLatch latch = new CountDownLatch(size);
final int[] success = { 0 };
int isNotTestCard = 0;
for (int i = 0; i < size; i++) {
CreditCard card = cards.get(i);
if (card.getName() == null || !card.getName().equals("TEST CARD")) {
isNotTestCard++;
latch.countDown();
} else {
card.deleteCard(new ApiCallback<Void>() {
@Override
public void onSuccess(Void result) {
success[0]++;
latch.countDown();
}
@Override
public void onFailure(@ResultCode.Code int errorCode, String errorMessage) {
latch.countDown();
}
});
}
}
latch.await(TIMEOUT * size, TimeUnit.SECONDS);
getCards();
Assert.assertEquals(isNotTestCard, cardsCollection.getResults().size());
}
Aggregations