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();
}
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();
}
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());
}
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());
}
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());
}
Aggregations