use of com.fitpay.android.api.models.device.Device 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.device.Device in project fitpay-android-sdk by fitpay.
the class Steps method deleteTestDevices.
public void deleteTestDevices() throws InterruptedException {
getDevices();
List<Device> devices = devicesCollection.getResults();
int size = devices.size();
final CountDownLatch latch = new CountDownLatch(size);
final int[] success = { 0 };
int isNotTestDevice = 0;
for (int i = 0; i < size; i++) {
Device device = devices.get(i);
if ("TEST_DEVICE".equals(device.getDeviceName())) {
device.deleteDevice(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();
}
});
} else {
isNotTestDevice++;
latch.countDown();
}
}
latch.await(TIMEOUT * size, TimeUnit.SECONDS);
getDevices();
Assert.assertEquals(isNotTestDevice, devicesCollection.getResults().size());
}
use of com.fitpay.android.api.models.device.Device in project fitpay-android-sdk by fitpay.
the class Steps method getPaymentDevice.
public void getPaymentDevice() throws InterruptedException {
Assert.assertNotNull(currentUser);
final CountDownLatch latch = new CountDownLatch(1);
currentUser.getPaymentDevice(new ApiCallback<Device>() {
@Override
public void onSuccess(Device result) {
paymentDevice = result;
latch.countDown();
}
@Override
public void onFailure(@ResultCode.Code int errorCode, String errorMessage) {
latch.countDown();
}
});
latch.await(TIMEOUT, TimeUnit.SECONDS);
Assert.assertNotNull("paymentDevice should not be null", paymentDevice);
}
use of com.fitpay.android.api.models.device.Device in project fitpay-android-sdk by fitpay.
the class Steps method updateDevice.
public void updateDevice() throws InterruptedException {
Assert.assertNotNull(currentDevice);
final CountDownLatch latch = new CountDownLatch(1);
final boolean[] isRequestSuccess = { false };
String firmwareRevision = "222.222";
String softwareRevision = "2.2.2";
Device newDevice = new Device.Builder().setFirmwareRevision(firmwareRevision).setSoftwareRevision(softwareRevision).build();
currentDevice.updateDevice(newDevice, new ApiCallback<Device>() {
@Override
public void onSuccess(Device result) {
isRequestSuccess[0] = true;
currentDevice = result;
latch.countDown();
}
@Override
public void onFailure(@ResultCode.Code int errorCode, String errorMessage) {
latch.countDown();
}
});
latch.await(TIMEOUT, TimeUnit.SECONDS);
Assert.assertTrue(isRequestSuccess[0]);
Assert.assertNotNull(currentDevice);
Assert.assertEquals(firmwareRevision, currentDevice.getFirmwareRevision());
Assert.assertEquals(softwareRevision, currentDevice.getSoftwareRevision());
}
use of com.fitpay.android.api.models.device.Device in project fitpay-android-sdk by fitpay.
the class DeviceTest2 method testCanDevicesWhenTwoInCollection.
@Test
public void testCanDevicesWhenTwoInCollection() 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());
Device firstDevice = devices.getResults().get(0);
assertNotNull("first device", firstDevice);
assertEquals("device id", createdDevice.getDeviceIdentifier(), firstDevice.getDeviceIdentifier());
Device secondDevice = devices.getResults().get(1);
assertNotNull("second device", secondDevice);
assertFalse("device ids in collection should not be equal", firstDevice.getDeviceIdentifier().equals(secondDevice.getDeviceIdentifier()));
}
Aggregations