Search in sources :

Example 6 with User

use of com.fitpay.android.api.models.user.User in project fitpay-android-sdk by fitpay.

the class TestActions method getUser.

protected User getUser() throws Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    ResultProvidingCallback<User> callback = new ResultProvidingCallback<>(latch);
    ApiManager.getInstance().getUser(callback);
    latch.await(TIMEOUT, TimeUnit.SECONDS);
    User user = callback.getResult();
    Assert.assertNotNull(user);
    return user;
}
Also used : ResultProvidingCallback(com.fitpay.android.api.callbacks.ResultProvidingCallback) User(com.fitpay.android.api.models.user.User) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 7 with User

use of com.fitpay.android.api.models.user.User in project fitpay-android-sdk by fitpay.

the class UserServiceTest method canCreateUser.

@Test
public void canCreateUser() throws Exception {
    userName = TestUtils.getRandomLengthString(5, 10) + "@" + TestUtils.getRandomLengthString(5, 10) + "." + TestUtils.getRandomLengthString(4, 10);
    pin = TestUtils.getRandomLengthNumber(4, 4);
    UserCreateRequest user = getNewTestUser(userName, pin);
    User createdUser = createUser(user);
    assertNotNull("user should have been created", createdUser);
}
Also used : User(com.fitpay.android.api.models.user.User) UserCreateRequest(com.fitpay.android.api.models.user.UserCreateRequest) Test(org.junit.Test)

Example 8 with User

use of com.fitpay.android.api.models.user.User in project fitpay-android-sdk by fitpay.

the class UserServiceTest method canCreateFullyDefinedUser.

@Test
public void canCreateFullyDefinedUser() throws Exception {
    userName = TestUtils.getRandomLengthString(5, 10) + "@" + TestUtils.getRandomLengthString(5, 10) + "." + TestUtils.getRandomLengthString(4, 10);
    pin = TestUtils.getRandomLengthNumber(4, 4);
    UserCreateRequest user = new UserCreateRequest.Builder().email(userName).pin(pin).birthDate("2015-09-15").firstName(TestUtils.getRandomLengthString(5, 10)).lastName(TestUtils.getRandomLengthString(5, 10)).origin("fitpay").originAccountCreatedAtEpoch(new Date().getTime()).termsVersion("01").termsAcceptedAtEpoch(new Date().getTime()).build();
    User createdUser = createUser(user);
    assertNotNull("user should have been created", createdUser);
}
Also used : User(com.fitpay.android.api.models.user.User) Date(java.util.Date) UserCreateRequest(com.fitpay.android.api.models.user.UserCreateRequest) Test(org.junit.Test)

Example 9 with User

use of com.fitpay.android.api.models.user.User 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 10 with User

use of com.fitpay.android.api.models.user.User 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)

Aggregations

User (com.fitpay.android.api.models.user.User)15 CountDownLatch (java.util.concurrent.CountDownLatch)10 Test (org.junit.Test)6 ResultProvidingCallback (com.fitpay.android.api.callbacks.ResultProvidingCallback)4 UserCreateRequest (com.fitpay.android.api.models.user.UserCreateRequest)4 Device (com.fitpay.android.api.models.device.Device)2 ApiCallback (com.fitpay.android.api.callbacks.ApiCallback)1 UserStreamEvent (com.fitpay.android.api.models.UserStreamEvent)1 OAuthToken (com.fitpay.android.api.models.security.OAuthToken)1 UserEventStreamListener (com.fitpay.android.api.sse.UserEventStreamListener)1 NotificationSyncRequest (com.fitpay.android.paymentdevice.events.NotificationSyncRequest)1 SyncInfo (com.fitpay.android.paymentdevice.models.SyncInfo)1 SyncRequest (com.fitpay.android.paymentdevice.models.SyncRequest)1 EventCallback (com.fitpay.android.utils.EventCallback)1 UserReceived (com.fitpay.android.webview.events.UserReceived)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Before (org.junit.Before)1 Ignore (org.junit.Ignore)1