Search in sources :

Example 16 with ResultProvidingCallback

use of com.fitpay.android.api.callbacks.ResultProvidingCallback in project fitpay-android-sdk by fitpay.

the class DeviceTest2 method testCanGetDeviceById.

@Test
public void testCanGetDeviceById() throws Exception {
    Device device = getTestDevice();
    Device createdDevice = createDevice(user, device);
    assertNotNull("device", createdDevice);
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<Device> callback = new ResultProvidingCallback<>(latch);
    user.getDevice(createdDevice.getDeviceIdentifier(), callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    Device retrievedDevice = callback.getResult();
    assertNotNull("device should have been retrieved", retrievedDevice);
    assertEquals("device id", createdDevice.getDeviceIdentifier(), retrievedDevice.getDeviceIdentifier());
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) Device(com.fitpay.android.api.models.device.Device) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 17 with ResultProvidingCallback

use of com.fitpay.android.api.callbacks.ResultProvidingCallback in project fitpay-android-sdk by fitpay.

the class TestActions method createCreditCard.

protected CreditCard createCreditCard(User user, CreditCard creditCard) throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<CreditCard> callback = new ResultProvidingCallback<>(latch);
    user.createCreditCard(creditCard, callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    return callback.getResult();
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) CountDownLatch(java.util.concurrent.CountDownLatch) CreditCard(com.fitpay.android.api.models.card.CreditCard)

Example 18 with ResultProvidingCallback

use of com.fitpay.android.api.callbacks.ResultProvidingCallback in project fitpay-android-sdk by fitpay.

the class TestActions method makeDefaultCard.

protected void makeDefaultCard(CreditCard creditCard) throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<Void> callback = new ResultProvidingCallback<>(latch);
    creditCard.makeDefault(callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    assertEquals("make default error code", -1, callback.getErrorCode());
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 19 with ResultProvidingCallback

use of com.fitpay.android.api.callbacks.ResultProvidingCallback in project fitpay-android-sdk by fitpay.

the class TestActions method deleteCard.

protected void deleteCard(CreditCard creditCard) throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<Void> callback = new ResultProvidingCallback<>(latch);
    creditCard.deleteCard(callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    assertEquals("delete error code", -1, callback.getErrorCode());
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 20 with ResultProvidingCallback

use of com.fitpay.android.api.callbacks.ResultProvidingCallback in project fitpay-android-sdk by fitpay.

the class TestActions method deactivateCard.

protected CreditCard deactivateCard(CreditCard creditCard, Reason reason) throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<CreditCard> callback = new ResultProvidingCallback<>(latch);
    creditCard.deactivate(reason, callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    return callback.getResult();
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) CountDownLatch(java.util.concurrent.CountDownLatch) CreditCard(com.fitpay.android.api.models.card.CreditCard)

Aggregations

ResultProvidingCallback (com.fitpay.android.api.callbacks.ResultProvidingCallback)32 CountDownLatch (java.util.concurrent.CountDownLatch)32 Test (org.junit.Test)11 CreditCard (com.fitpay.android.api.models.card.CreditCard)8 Device (com.fitpay.android.api.models.device.Device)8 User (com.fitpay.android.api.models.user.User)4 Collections (com.fitpay.android.api.models.collection.Collections)3 VerificationMethod (com.fitpay.android.api.models.card.VerificationMethod)2 OAuthToken (com.fitpay.android.api.models.security.OAuthToken)2 Ignore (org.junit.Ignore)2 Image (android.media.Image)1 Transaction (com.fitpay.android.api.models.Transaction)1 PaymentDevice (com.fitpay.android.api.models.device.PaymentDevice)1 LoginIdentity (com.fitpay.android.api.models.user.LoginIdentity)1 After (org.junit.After)1