Search in sources :

Example 31 with Device

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));
}
Also used : Device(com.fitpay.android.api.models.device.Device) Collections(com.fitpay.android.api.models.collection.Collections) CreditCard(com.fitpay.android.api.models.card.CreditCard) Test(org.junit.Test)

Example 32 with Device

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());
}
Also used : PaymentDevice(com.fitpay.android.api.models.device.PaymentDevice) Device(com.fitpay.android.api.models.device.Device) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 33 with Device

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);
}
Also used : PaymentDevice(com.fitpay.android.api.models.device.PaymentDevice) Device(com.fitpay.android.api.models.device.Device) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 34 with Device

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());
}
Also used : PaymentDevice(com.fitpay.android.api.models.device.PaymentDevice) Device(com.fitpay.android.api.models.device.Device) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 35 with Device

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()));
}
Also used : Device(com.fitpay.android.api.models.device.Device) Collections(com.fitpay.android.api.models.collection.Collections) Test(org.junit.Test)

Aggregations

Device (com.fitpay.android.api.models.device.Device)39 Test (org.junit.Test)28 Collections (com.fitpay.android.api.models.collection.Collections)22 CreditCard (com.fitpay.android.api.models.card.CreditCard)19 CountDownLatch (java.util.concurrent.CountDownLatch)15 PaymentDevice (com.fitpay.android.api.models.device.PaymentDevice)9 ResultProvidingCallback (com.fitpay.android.api.callbacks.ResultProvidingCallback)8 Commit (com.fitpay.android.api.models.device.Commit)3 ApiCallback (com.fitpay.android.api.callbacks.ApiCallback)2 UserStreamEvent (com.fitpay.android.api.models.UserStreamEvent)2 User (com.fitpay.android.api.models.user.User)2 UserEventStreamListener (com.fitpay.android.api.sse.UserEventStreamListener)2 SyncRequest (com.fitpay.android.paymentdevice.models.SyncRequest)2 Activity (android.app.Activity)1 Image (android.media.Image)1 ApiManager (com.fitpay.android.api.ApiManager)1 SyncInitiator (com.fitpay.android.api.enums.SyncInitiator)1 Transaction (com.fitpay.android.api.models.Transaction)1 Reason (com.fitpay.android.api.models.card.Reason)1 VerificationMethod (com.fitpay.android.api.models.card.VerificationMethod)1