Search in sources :

Example 31 with ResultProvidingCallback

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

the class DeviceTest2 method testCantAddDeviceWithMissingType.

@Test
public void testCantAddDeviceWithMissingType() throws Exception {
    Device device = getPoorlyDefinedDevice();
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<Device> callback = new ResultProvidingCallback<>(latch);
    user.createDevice(device, callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    Device createdDevice = callback.getResult();
    assertNull("created device", createdDevice);
    assertEquals("error code", 400, callback.getErrorCode());
}
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 32 with ResultProvidingCallback

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

the class DeviceTest2 method testCantAddDeviceWithMissingInfo.

@Test
public void testCantAddDeviceWithMissingInfo() throws Exception {
    Device device = getPoorlyDeviceTestSmartStrapDevice();
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<Device> callback = new ResultProvidingCallback<>(latch);
    user.createDevice(device, callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    Device createdDevice = callback.getResult();
    assertNull("created device", createdDevice);
    assertEquals("error code", 400, callback.getErrorCode());
}
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)

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