Search in sources :

Example 11 with ResultProvidingCallback

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

the class TestActions method getTransaction.

protected Transaction getTransaction(Transaction transaction) throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<Transaction> callback = new ResultProvidingCallback<>(latch);
    transaction.self(callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    assertEquals("get device transaction error code.  (message: " + callback.getErrorMessage() + ")", -1, callback.getErrorCode());
    return callback.getResult();
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) Transaction(com.fitpay.android.api.models.Transaction) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 12 with ResultProvidingCallback

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

the class TestActions method createUser.

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

Example 13 with ResultProvidingCallback

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

the class DeviceTest2 method testCanGetDeviceFromCollection.

@Test
public void testCanGetDeviceFromCollection() throws Exception {
    Device device = getTestDevice();
    Device createdDevice = createDevice(user, device);
    assertNotNull("device", createdDevice);
    Collections.DeviceCollection devices = getDevices(user);
    assertNotNull("retrieved devices", devices);
    assertEquals("number of devices", 1, devices.getTotalResults());
    Device firstDevice = devices.getResults().get(0);
    assertNotNull("first device", firstDevice);
    final CountDownLatch latch4 = new CountDownLatch(1);
    ResultProvidingCallback<Device> callback4 = new ResultProvidingCallback<>(latch4);
    createdDevice.self(callback4);
    latch4.await(TIMEOUT, TimeUnit.SECONDS);
    Device retrievedDevice = callback4.getResult();
    assertNotNull("retrieved device", retrievedDevice);
    assertEquals("device id", firstDevice.getDeviceIdentifier(), retrievedDevice.getDeviceIdentifier());
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) Device(com.fitpay.android.api.models.device.Device) Collections(com.fitpay.android.api.models.collection.Collections) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 14 with ResultProvidingCallback

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

the class DeviceTest2 method testCanGetDevice.

@Test
public void testCanGetDevice() 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);
    createdDevice.self(callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    Device retrievedDevice = callback.getResult();
    assertNotNull("retrieved device", 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 15 with ResultProvidingCallback

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

the class DeviceTest2 method testCanDeleteDeviceFromCollection.

@Test
public void testCanDeleteDeviceFromCollection() throws Exception {
    Device phone = getTestDevice(false);
    Device watch = getTestDevice(true);
    Device createdDevice = createDevice(user, phone);
    assertNotNull("device", createdDevice);
    Device anotherCreatedDevice = createDevice(user, watch);
    assertNotNull("device", anotherCreatedDevice);
    Collections.DeviceCollection devices = getDevices(user);
    assertNotNull("retrieved devices", devices);
    assertEquals("number of devices", 2, devices.getTotalResults());
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<Void> callback = new ResultProvidingCallback<>(latch);
    createdDevice.deleteDevice(callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    assertEquals("delete device error code", -1, callback.getErrorCode());
    devices = getDevices(user);
    assertNotNull("retrieved devices", devices);
    assertEquals("number of devices after delete of 1", 1, devices.getTotalResults());
    assertEquals("remaining device in collection", anotherCreatedDevice.getDeviceIdentifier(), devices.getResults().get(0).getDeviceIdentifier());
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) Device(com.fitpay.android.api.models.device.Device) Collections(com.fitpay.android.api.models.collection.Collections) 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