Search in sources :

Example 1 with ResultProvidingCallback

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

the class CreditCardTest2 method testCanAddCreditCard.

@Test
public void testCanAddCreditCard() 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);
    verifyCardContents(creditCard, createdCard);
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<Image> callback = new ResultProvidingCallback<>(latch);
    createdCard.getCardMetaData().getBrandLogo().get(0).self(callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
// TODO enable test for image retrieval
// assertEquals(-1, callback.getErrorCode());
}
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) Image(android.media.Image) CreditCard(com.fitpay.android.api.models.card.CreditCard) Test(org.junit.Test)

Example 2 with ResultProvidingCallback

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

the class TestActions method doLogin.

protected boolean doLogin(LoginIdentity loginIdentity) throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<OAuthToken> callback = new ResultProvidingCallback<>(latch);
    ApiManager.getInstance().loginUser(loginIdentity, callback);
    boolean completed = latch.await(TIMEOUT, TimeUnit.SECONDS);
    assertTrue("login did not complete successfully", completed);
    assertEquals("login error code. (message: " + callback.getErrorMessage() + ")", -1, callback.getErrorCode());
    return completed;
}
Also used : OAuthToken(com.fitpay.android.api.models.security.OAuthToken) ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 3 with ResultProvidingCallback

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

the class TestActions method selectVerificationMethod.

protected VerificationMethod selectVerificationMethod(VerificationMethod method) throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<VerificationMethod> callback = new ResultProvidingCallback<>(latch);
    method.select(callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    return callback.getResult();
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) VerificationMethod(com.fitpay.android.api.models.card.VerificationMethod) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 4 with ResultProvidingCallback

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

the class TestActions method declineTerms.

protected CreditCard declineTerms(CreditCard creditCard) throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<CreditCard> callback = new ResultProvidingCallback<>(latch);
    creditCard.declineTerms(callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    return callback.getResult();
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) CountDownLatch(java.util.concurrent.CountDownLatch) CreditCard(com.fitpay.android.api.models.card.CreditCard)

Example 5 with ResultProvidingCallback

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

the class TestActions method reactivateCard.

protected CreditCard reactivateCard(CreditCard creditCard, Reason reason) throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<CreditCard> callback = new ResultProvidingCallback<>(latch);
    creditCard.reactivate(reason, callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    return callback.getResult();
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) CountDownLatch(java.util.concurrent.CountDownLatch) CreditCard(com.fitpay.android.api.models.card.CreditCard)

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