Search in sources :

Example 26 with ResultProvidingCallback

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

the class TestActions method getCommits.

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

Example 27 with ResultProvidingCallback

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

the class UserTest2 method testCantGetDeletedUser.

@Test
@Ignore
public // TODO Comparing to edge tests, should not be able to get user after delete.   Why can we here?
void testCantGetDeletedUser() throws Exception {
    this.user = getUser();
    assertNotNull(user);
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<Void> callback = new ResultProvidingCallback<>(latch);
    this.user.deleteUser(callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    assertEquals("delete error code", -1, callback.getErrorCode());
    User deletedUser = getUser();
    assertNull("user should not exist", deletedUser);
    this.user = null;
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) User(com.fitpay.android.api.models.user.User) CountDownLatch(java.util.concurrent.CountDownLatch) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 28 with ResultProvidingCallback

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

the class UserTest2 method testCantLoginWithDifferentPassword.

@Test
// this test does not work in demo environment since does auto-login
@Ignore
public void testCantLoginWithDifferentPassword() throws Exception {
    this.user = getUser();
    assertNotNull(user);
    LoginIdentity badCredentials = getTestLoginIdentity(userName, TestUtils.getRandomLengthNumber(4, 4));
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<OAuthToken> callback = new ResultProvidingCallback<>(latch);
    ApiManager.getInstance().loginUser(badCredentials, callback);
    boolean completed = latch.await(TIMEOUT, TimeUnit.SECONDS);
    assertTrue("login did not complete successfully", completed);
    assertEquals("login error code. (message: " + callback.getErrorMessage() + ")", 401, callback.getErrorCode());
}
Also used : OAuthToken(com.fitpay.android.api.models.security.OAuthToken) ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) CountDownLatch(java.util.concurrent.CountDownLatch) LoginIdentity(com.fitpay.android.api.models.user.LoginIdentity) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 29 with ResultProvidingCallback

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

the class UserTest2 method testUserCanGetSelf.

@Test
public void testUserCanGetSelf() throws Exception {
    this.user = getUser();
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<User> callback = new ResultProvidingCallback<>(latch);
    user.self(callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    User user2 = callback.getResult();
    assertEquals("user self had error code (message: " + callback.getErrorMessage() + ")", -1, callback.getErrorCode());
    assertEquals("user id", user.getId(), user2.getId());
    assertEquals("email", user.getEmail(), user2.getEmail());
    assertEquals("user name", user.getUsername(), user2.getUsername());
    assertEquals("build ts", user.getCreatedTsEpoch(), user2.getCreatedTsEpoch());
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) User(com.fitpay.android.api.models.user.User) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 30 with ResultProvidingCallback

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

the class CreditCardTest2 method testCantAddCreditCardWithNoDevice.

@Test
public void testCantAddCreditCardWithNoDevice() throws Exception {
    String pan = "9999545454545454";
    CreditCard creditCard = getTestCreditCard(pan);
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<CreditCard> callback = new ResultProvidingCallback<>(latch);
    user.createCreditCard(creditCard, callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    CreditCard createdCard = callback.getResult();
    assertNull("created card", createdCard);
    assertEquals("error code", 400, callback.getErrorCode());
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) CountDownLatch(java.util.concurrent.CountDownLatch) CreditCard(com.fitpay.android.api.models.card.CreditCard) 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